Hi Riku,
Thanks for your response.
(1) I tried correcting the klibc definition of struct stat with the kernel definition of stat64, but still I don't get the correct results. e.g. root@genericarmv8:~/anilss/AArch64/klibc-aarch64/usr/klibc/tests# ./stat test.out Path = test.out st_dev = 0x11 (0,17) st_ino = 4194908 st_mode = 0 st_nlink = 0 st_uid = 0 st_gid = 0 st_rdev = 0xf (0,15) st_size = 8 st_blksize = 1380795825 st_blocks = 129482584 st_atim = 1380537164.223008806 st.mtim = 1380537164.223008806
*New definition of stat that I tried is:* /* This matches struct stat64 in glibc2.1, hence the absolutely * insane amounts of padding around dev_t's. * Note: The kernel zero's the padded region because glibc might read them * in the hope that the kernel has stretched to using larger sizes. */ struct stat { __stdev64 (st_dev); unsigned char __pad0[4];
unsigned long __st_ino; unsigned int st_mode; unsigned int st_nlink;
unsigned long st_uid; unsigned long st_gid;
__stdev64 (st_rdev); unsigned char __pad3[4];
long long st_size; unsigned long st_blksize;
unsigned long long st_blocks; /* Number 512-byte blocks allocated. */
struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim;
unsigned long long st_ino; };
This is same as that in ARM.
Plus I noticed that the original definition that was in klibc for aarch64 (the one with which I have issues) is exactly same as that in x86_64 and there the test works fine. That is bit confusing. On x86_64 it gives the following result (with the same definition that was in aarch64): anilss@anilss:~/Native/klibc-2.0.1/usr/klibc/tests$ ./stat test.out Path = test.out st_dev = 0x801 (8,1) st_ino = 4857342 st_mode = 0100664 st_nlink = 1 st_uid = 1000 st_gid = 1000 st_rdev = 0x0 (0,0) st_size = 8399061 st_blksize = 4096 st_blocks = 16408 st_atim = 1380802488.081739059 st.mtim = 1379586488.807291875 st.ctim = 1379586488.807291875
(2) Per what I have gathered from elsewhere on web, the value of Ttext in KLIBCSHAREDFLAGS should prevent klibc.so from occupying same virtual address space as some other module. May be this understanding is not sufficient.
# Extra linkflags when building the shared version of the library # This address needs to be reachable using normal inter-module # calls, and work on the memory models for this architecture KLIBCSHAREDFLAGS = -Ttext 0x01800200 #KLIBCREQFLAGS += #KLIBCOPTFLAGS += -mgeneral-regs-only
Thanks and Regards, Anil
On 3 October 2013 12:29, Riku Voipio riku.voipio@linaro.org wrote:
On 1 October 2013 15:19, Anil Singhar anil.singhar@linaro.org wrote:
Hi,
I am trying to port klibc to aarch64. My code is available from:
git clone git://git.linaro.org/people/anil.singhar/klibc-aarch64.git
At this point, I am trying to fix the following issues. Any help /
comment /
advice / suggestion is highly appreciated.
- Need to find the correct value for KLIBCSHAREDFLAGS (What value
should I
set Ttext to in the aarch64 specific MCONFIG file?). Right now the
MCONFIG
looks as follows:
It is hard to answer to this question as I don't know what klibc uses KLIBCSHAREDFLAGS for.
S += -mgeneral-regs-only
- The stat family of syscalls don't work correctly. There is only one
actual syscall: fstat, which is used by lstat and stat. The syscall
doesn't
seem to return valid values for target files. e.g. The following fields
are
wrong:
toot@genericarmv8:~/anilss/AArch64/klibc-aarch64/usr/klibc/tests# ./stat test.out Path = test.out st_dev = 0x11 (0,17) st_ino = 5910539 st_mode = 0 st_nlink = 4295000484 <-- This is wrong st_uid = 0 st_gid = 0 st_rdev = 0x0 (0,0) st_size = 15 st_blksize = 1380537164 st_blocks = 223008806 st_atim = 1048576.000000008 st.mtim = 1380612975.029926968 st.ctim = 1380537164.223008806
Because the fields are wrong, the parsed values are also wrong.
Applications
such as ls, gzip etc. fail to work because they rely on this syscall.
This would imply that the struct stat is defined incorrectly for Aarch64. Looking into the kernel sources ( ./arch/arm64/include/uapi/asm/stat.h points to ./include/uapi/asm-generic/stat.h ) the definition in klibc sources ( ./usr/include/arch/aarch64/klibc/archstat.h ) is indeed incorrect. Once you fix the "struct stat" definition to match what is in the kernel, you should se better results.
Since I am doing the development on ARMv8 Foundation model using linaro openembedded image, is there a debug version of the kernel (the one img-foundation.axf) that I can use to debug the syscall itself in kernel mode using kgdb? Any other debugging ideas..?
Generally speaking it is better to first read the kernel sources related to system call failing before attempting to step in debugger.