Alternative to gen_bits_syscall_h.sh

Jeffrey Walton noloader at gmail.com
Thu Feb 28 18:10:03 UTC 2013


Hi All,

I've been attempting to build uClibc on Ubuntu 12 (x64) so I can get
some familiar tools on it. I've been having some issues, and they are
expected.

Attached is a small program that reads unistd.h (from
<linux>/asm/unistd.h) and writes it to sysnum.h (in <uClibc>/bits) for
use by uClibc's build process. It's offered to others who might also
find it useful.

The program attempts to fill the gap of incomplete parsing by
gen_bits_syscall_h.sh. In my particular case, a number of syscalls
were missing, including __NR_open, __NR_dup, __NR_fstat, and
__NR_pipe.

The trick to using the program (uclibc-syscall) is to run `make`, wait
for the errors due to missing __NR_* defines, and then run
`uclibc-syscall.exe`. You wait for the errors from the build process
because `make` creates a number of directories and symlinks, so its
easiest to allow make to do the work (and create the bits/ directory).

I hard coded the values for UNISTD_IN and SYSNUM_OUT. Please adjust to
suite your taste. It would probably be best to read these from argv[1]
and argv[2], but that would mean a lot more defensive programming due
to the possible taint of argv[]. The defensive programming would
include complete validation and compiler/linker hardening
(https://www.owasp.org/index.php/C-Based_Toolchain_Hardening).

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uclibc-syscall.cpp
Type: text/x-c++src
Size: 6766 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20130228/44917a42/attachment.cpp>


More information about the uClibc mailing list