Summary: | sys-libs/uclibc: SYS_utime is defined for EABI targets when __NR_utime does not exist | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Kiichiro <nflazzer> |
Component: | Sandbox | Assignee: | Embedded Gentoo Team <embedded> |
Status: | RESOLVED FIXED | ||
Severity: | minor | CC: | blueness, sandbox |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | ARM | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
generated trace_syscalls.h
build.log Remove utime syscall tracing in sandbox |
Description
Kiichiro
2012-07-06 03:40:46 UTC
Created attachment 317384 [details]
generated trace_syscalls.h
Created attachment 317386 [details]
build.log
*** Bug 427816 has been marked as a duplicate of this bug. *** This bug has bugged me long enough! I keep hitting it during a catalyst build of arm uclibc. Here's what's going on. In bits/sysnum.h (included by sys/syscalls.h) there are a few syscalls which are not implemented. They are "defined" as follows: #define __NR_time __NR_time #define __NR_umount __NR_umount #define __NR_stime __NR_stime #define __NR_alarm __NR_alarm #define __NR_utime __NR_utime #define __NR_getrlimit __NR_getrlimit #define __NR_select __NR_select #define __NR_readdir __NR_readdir #define __NR_mmap __NR_mmap #define __NR_socketcall __NR_socketcall #define __NR_syscall __NR_syscall #define __NR_ipc __NR_ipc Compare this to the usual, eg SYS_write: #define __NR_write (0 + 4) Of these "undefined defines", only __NR_utime is in sandbox's libsandbox/symbols.h.in and gets brought into the build via scripts/gen_trace_header.awk, etc. When building, this leads to the undeclared in trace_syscalls.h The easiest thing to do is just patch all utime stuff out. The better thing would be to implement utime in arm-uclibc. You could probably just take this out of glibc, but I haven't looked. I'll attach the "lazy" patch in my next post. Created attachment 331338 [details, diff]
Remove utime syscall tracing in sandbox
(In reply to comment #3) > *** Bug 427816 has been marked as a duplicate of this bug. *** Oh wow, I just looked at the dup and I already did this like 5 months ago but have no recollection of having opened that bug! Sorry for the spam. (In reply to comment #4) i think you misunderstand the syscall stuff. the C library can't "implement" syscalls that the kernel omits. the issue is that uClibc is defining SYS_xxx stuff that it shouldn't. in this case, there is no __NR_utime, but it is still exporting SYS_utime. simple workaround: sed -i '/SYS_utime __NR_utime$/d' /usr/include/bits/sysnum.h (In reply to comment #7) > (In reply to comment #4) > > i think you misunderstand the syscall stuff. the C library can't > "implement" syscalls that the kernel omits. > > the issue is that uClibc is defining SYS_xxx stuff that it shouldn't. in > this case, there is no __NR_utime, but it is still exporting SYS_utime. > > simple workaround: > sed -i '/SYS_utime __NR_utime$/d' /usr/include/bits/sysnum.h When I wrote that I forgot arm eabi dropped utime and thought the kernel provided it but uclibc just didn't have the syscall wrapper (like dup3 recently), or that it was a stub or something. There clearly is something wrong because `readelf -s /lib/libc.so.0 | grep utime` gives 217: 00010c5c 56 FUNC GLOBAL DEFAULT 8 utime 749: 000119a8 152 FUNC GLOBAL DEFAULT 8 lutimes 949: 00013264 52 FUNC GLOBAL DEFAULT 8 utimes 1001: 0001147c 52 FUNC GLOBAL DEFAULT 8 utimensat 1009: 000120f0 52 FUNC GLOBAL DEFAULT 8 futimesat 1243: 000130d4 16 FUNC GLOBAL DEFAULT 8 futimens which is why gen_symbol_header.awk spits it into symbols.h. Let me see if I can figure out why uclibc is exporting utime(). (In reply to comment #8) the ABI provided by the C library is not restricted by the ABI provided by the kernel. as an example, with newer ports, the kernel only provides the *at style funcs. so openat, fstatat, etc... but uClibc still must provide the full API as dictated by POSIX. so it implements open() by calling openat(), stat() by calling fstatat(), etc... utime() is part of POSIX, thus uClibc provides it: http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html the kernel ABI has no such restrictions -- it merely needs to provide enough so that some userland ABI can fully implement POSIX. (In reply to comment #9) > (In reply to comment #8) > > the ABI provided by the C library is not restricted by the ABI provided by > the kernel. as an example, with newer ports, the kernel only provides the > *at style funcs. so openat, fstatat, etc... but uClibc still must provide > the full API as dictated by POSIX. so it implements open() by calling > openat(), stat() by calling fstatat(), etc... > > utime() is part of POSIX, thus uClibc provides it: > http://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html > > the kernel ABI has no such restrictions -- it merely needs to provide enough > so that some userland ABI can fully implement POSIX. ligh bulb goes off! so what if we provide utime by calling utimes, which is there. we have to convert a struct utimbuf to a struct timeval which seems like the only hard part, and make sure the return value and errno are properly set. (In reply to comment #10) i'm not sure if you were asking a question, but in case you were, sandbox has to wrap utime() (both at the C and kernel level if it exists) since it modifies things via pathname. we can't wrap just utimes(). as a short term fix, the trace logic can probably be refactored slightly so that we don't even include trace_syscalls.h when SB_NO_TRACE_OS is defined (which it currently is for arm targets). that won't help though when i get around to implementing the arm/ptrace layer ... looks like it happens to a bunch of syscalls: #define __NR_time __NR_time #define __NR_umount __NR_umount #define __NR_stime __NR_stime #define __NR_alarm __NR_alarm #define __NR_utime __NR_utime #define __NR_getrlimit __NR_getrlimit #define __NR_select __NR_select #define __NR_readdir __NR_readdir #define __NR_mmap __NR_mmap #define __NR_socketcall __NR_socketcall #define __NR_syscall __NR_syscall #define __NR_ipc __NR_ipc should be all set now in the tree; thanks for the report! Commit message: Add fix from upstream for cleaning up undefined syscalls. http://sources.gentoo.org/sys-libs/uclibc/uclibc-0.9.33.2-r3.ebuild?r1=1.1&r2=1.2 (In reply to comment #13) > should be all set now in the tree; thanks for the report! > > Commit message: Add fix from upstream for cleaning up undefined syscalls. > http://sources.gentoo.org/sys-libs/uclibc/uclibc-0.9.33.2-r3.ebuild?r1=1. > 1&r2=1.2 Thanks I'll be testing this soon as I do another catalyst round of arm-uclibc images. (Which I'm crunching on the sambsung arm chromebook that someone told me about :) I'm pushing those images to the tree under /experimental/arm/uclibc. |