[PATCH] support kernels without __ARCH_WANT_SYSCALL_OFF_T
Laurent Bercot
ska-dietlibc at skarnet.org
Mon Apr 30 11:27:15 UTC 2012
> Hi Laurent,
>
> If your static app does not use stdio then it will not be linked into the
> binary. If it is linked in, then you must be using a broken toolchain, so
> what versions of uClibc and GCC do you use?
Hi Bernhard and list,
I was curious so I did the most simple test there is.
Unfortunately, I'm not savvy enough with ELF and objdump to correctly
interpret the results, so I'll leave it to you guys.
This is gcc 4.2.1 and uClibc 0.9.32.1, all from the latest (i.e.
January 2012) native-compiler-i686 binary toolchain available at
Aboriginal Linux: http://landley.net/aboriginal/bin/
Platform is Linux 2.6.36 on i686.
What I did:
$ cat true.c
int main (void)
{
return 0 ;
}
$ gcc -o true -static true.c
$ objdump -x true > true.out
The objdump input is in attachment.
What strikes me as odd, but you guys tell me if this is normal:
* There are a few undefined symbols in that static executables. Among
them are symbols named _stdio_init and _stdio_term.
* There are defined _pthread* and __pthread* symbols, such as
__pthread_mutex_init; but the program is obviously single-threaded and
should definitely not have thread management overhead.
* Generally speaking, there are WAAAAAY too many symbols in that
binary, which is 9487 bytes long (unstripped).
Afterthought : it looks like the atexit() mechanism is pulling in a lot
of stuff. I did the following to compare:
$ cat true2.c
#include <unistd.h>
int main (void)
{
_exit(0) ;
}
$ gcc -o true2 -static true2.c
$ objdump -x true2 > true2.out
The second objdump input, also in attachment, is much more reasonable
and fits what I actually expect from an empty program. The true2 binary
is 748 bytes, unstripped.
So it seems that stdio is not pulled in when not needed; however,
there is still a lot of bloat that does get pulled in. I would like
to be able to simply return from main() instead of calling _exit() ;
I never, ever use the atexit mechanism, and believe the linker should
be able to figure that out (no explicit atexit, no stdio, no other
registration mechanisms or constructors) and optimize all that stuff away.
In particular, if I simply return from main(), I would like to be
certain that my single-threaded programs won't pull in pthread-enabled
mechanisms.
--
Laurent
-------------- next part --------------
true: file format elf32-i386
true
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x08048168
Program Header:
LOAD off 0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
filesz 0x0000089d memsz 0x0000089d flags r-x
LOAD off 0x000008a0 vaddr 0x080498a0 paddr 0x080498a0 align 2**12
filesz 0x0000006c memsz 0x000000b4 flags rw-
STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
filesz 0x00000000 memsz 0x00000000 flags rw-
Sections:
Idx Name Size VMA LMA File off Algn
0 .init 0000001c 08048094 08048094 00000094 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .text 000007cc 080480b0 080480b0 000000b0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .fini 00000017 0804887c 0804887c 0000087c 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .rodata 0000000a 08048893 08048893 00000893 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .eh_frame 00000004 080498a0 080498a0 000008a0 2**2
CONTENTS, ALLOC, LOAD, DATA
5 .ctors 00000008 080498a4 080498a4 000008a4 2**2
CONTENTS, ALLOC, LOAD, DATA
6 .dtors 00000008 080498ac 080498ac 000008ac 2**2
CONTENTS, ALLOC, LOAD, DATA
7 .jcr 00000004 080498b4 080498b4 000008b4 2**2
CONTENTS, ALLOC, LOAD, DATA
8 .got.plt 0000000c 080498b8 080498b8 000008b8 2**2
CONTENTS, ALLOC, LOAD, DATA
9 .data 00000048 080498c4 080498c4 000008c4 2**2
CONTENTS, ALLOC, LOAD, DATA
10 .bss 00000048 0804990c 0804990c 0000090c 2**2
ALLOC
11 .comment 0000019e 00000000 00000000 0000090c 2**0
CONTENTS, READONLY
SYMBOL TABLE:
08048094 l d .init 00000000 .init
080480b0 l d .text 00000000 .text
0804887c l d .fini 00000000 .fini
08048893 l d .rodata 00000000 .rodata
080498a0 l d .eh_frame 00000000 .eh_frame
080498a4 l d .ctors 00000000 .ctors
080498ac l d .dtors 00000000 .dtors
080498b4 l d .jcr 00000000 .jcr
080498b8 l d .got.plt 00000000 .got.plt
080498c4 l d .data 00000000 .data
0804990c l d .bss 00000000 .bss
00000000 l d .comment 00000000 .comment
00000000 l d *ABS* 00000000 .shstrtab
00000000 l d *ABS* 00000000 .symtab
00000000 l d *ABS* 00000000 .strtab
00000000 l df *ABS* 00000000 libc/sysdeps/linux/i386/crti.S
00000000 l df *ABS* 00000000 crtstuff.c
080498a4 l O .ctors 00000000 __CTOR_LIST__
080498ac l O .dtors 00000000 __DTOR_LIST__
080498a0 l O .eh_frame 00000000 __EH_FRAME_BEGIN__
080498b4 l O .jcr 00000000 __JCR_LIST__
080480c0 l F .text 00000000 __do_global_dtors_aux
0804990c l O .bss 00000001 completed.4802
080498c8 l O .data 00000000 p.4800
08048110 l F .text 00000000 frame_dummy
08049910 l O .bss 00000018 object.4814
00000000 l df *ABS* 00000000 crtstuff.c
080498a8 l O .ctors 00000000 __CTOR_END__
080498b0 l O .dtors 00000000 __DTOR_END__
080498a0 l O .eh_frame 00000000 __FRAME_END__
080498b4 l O .jcr 00000000 __JCR_END__
08048850 l F .text 00000000 __do_global_ctors_aux
00000000 l df *ABS* 00000000 initfini.c
00000000 l df *ABS* 00000000 libc/sysdeps/linux/i386/crtn.S
00000000 l df *ABS* 00000000 libc/sysdeps/linux/i386/crt1.S
00000000 l df *ABS* 00000000 true.c
00000000 l df *ABS* 00000000 __uClibc_main.c
080481a8 l F .text 00000003 __pthread_return_0
08048216 l F .text 00000034 __check_one_fd
00000000 l df *ABS* 00000000 open.c
00000000 l df *ABS* 00000000 getuid.c
00000000 l df *ABS* 00000000 getegid.c
00000000 l df *ABS* 00000000 geteuid.c
00000000 l df *ABS* 00000000 getgid.c
00000000 l df *ABS* 00000000 __syscall_fcntl.c
00000000 l df *ABS* 00000000 __errno_location.c
00000000 l df *ABS* 00000000 strrchr.c
00000000 l df *ABS* 00000000 abort.c
080498dc l O .data 00000018 mylock
0804993c l O .bss 00000001 been_there_done_that
00000000 l df *ABS* 00000000 exit.c
00000000 l df *ABS* 00000000 dl-support.c
00000000 l df *ABS* 00000000 sigaction.c
080486fc l .text 00000000 __restore_rt
08048703 l .text 00000000 __restore
00000000 l df *ABS* 00000000 __syscall_rt_sigaction.c
00000000 l df *ABS* 00000000 _exit.c
00000000 l df *ABS* 00000000 sigprocmask.c
00000000 l df *ABS* 00000000 errno.c
00000000 l df *ABS* 00000000 raise.c
00000000 l df *ABS* 00000000 getpid.c
00000000 l df *ABS* 00000000 kill.c
080498a4 l *ABS* 00000000 .hidden __fini_array_end
080498a4 l *ABS* 00000000 .hidden __fini_array_start
080498a4 l *ABS* 00000000 .hidden __init_array_end
080498a4 l *ABS* 00000000 .hidden __preinit_array_end
080498b8 l O .got.plt 00000000 .hidden _GLOBAL_OFFSET_TABLE_
080498a4 l *ABS* 00000000 .hidden __init_array_start
080498a4 l *ABS* 00000000 .hidden __preinit_array_start
0804870b g F .text 00000051 __libc_sigaction
0804870b w F .text 00000051 .hidden __GI_sigaction
080484d4 g F .text 00000008 getgid
08049948 g O .bss 00000004 .hidden __GI_h_errno
080481d7 g F .text 0000003f .hidden __GI___uClibc_fini
080481a8 w F .text 00000003 __pthread_mutex_lock
080481d7 g F .text 0000003f __uClibc_fini
080484cc g F .text 00000008 geteuid
08049928 g O .bss 00000004 __libc_stack_end
080484dc g F .text 00000057 __libc_fcntl
08049948 w O .bss 00000004 _h_errno
08049944 g O .bss 00000004 errno
080484c4 g F .text 00000008 getegid
0804824a g F .text 00000039 .hidden __GI___uClibc_init
08048814 w F .text 00000008 getpid
080481ab w F .text 00000003 __pthread_mutex_init
080484bc g F .text 00000008 getuid
080498c4 g O .data 00000000 .hidden __dso_handle
080481c0 w F .text 00000017 _pthread_cleanup_pop_restore
080484dc g F .text 00000057 .hidden __GI___libc_fcntl
08048474 g F .text 00000045 .hidden __GI_open
0804992c g O .bss 00000004 __environ
08048798 w F .text 00000027 _Exit
080485b0 g F .text 000000d0 abort
080484dc w F .text 00000057 .hidden __GI_fcntl
080484d4 g F .text 00000008 .hidden __GI_getgid
08048094 g F .init 00000000 _init
08048594 g F .text 0000001a strrchr
08049948 g O .bss 00000004 h_errno
080481a8 w F .text 00000003 __pthread_mutex_unlock
00000000 w *UND* 00000000 __register_frame_info_bases
08048680 g F .text 00000067 .hidden __GI_exit
08049934 g O .bss 00000004 .hidden __app_fini
08049940 g O .bss 00000004 .hidden __exit_cleanup
08048594 g F .text 0000001a rindex
0804992c w O .bss 00000004 environ
0804881c g F .text 00000031 kill
080481a8 w F .text 00000003 __pthread_mutex_trylock
080487c0 g F .text 0000003a .hidden __GI_sigprocmask
0804881c g F .text 00000031 .hidden __GI_kill
00000000 w *UND* 00000000 __pthread_initialize_minimal
080498d4 w O .data 00000004 __progname
08048168 g F .text 00000022 _start
00000000 w *UND* 00000000 __deregister_frame_info_bases
080498d4 g O .data 00000004 program_invocation_short_name
08048533 g F .text 00000057 .hidden __GI___fcntl_nocancel
0804870b w F .text 00000051 sigaction
0804994c g O .bss 00000004 _dl_phdr
0804824a g F .text 00000039 __uClibc_init
080498d0 g O .data 00000004 .hidden __uclibc_progname
080484c4 g F .text 00000008 .hidden __GI_getegid
08048283 g F .text 000001f1 __uClibc_main
08049938 g O .bss 00000004 .hidden __rtld_fini
08048814 g F .text 00000008 .hidden __GI_getpid
080481ae w F .text 00000012 _pthread_cleanup_push_defer
0804990c g *ABS* 00000000 __bss_start
08048474 g F .text 00000045 __libc_open
0804818c g F .text 00000019 main
0804875c g F .text 00000039 __syscall_rt_sigaction
080485b0 g F .text 000000d0 .hidden __GI_abort
08048798 g F .text 00000027 .hidden __GI__exit
08048594 g F .text 0000001a .hidden __GI_strrchr
080498cc w .data 00000000 data_start
00000000 w *UND* 00000000 __h_errno_location
0804887c g F .fini 00000000 _fini
080480b0 g F .text 00000000 .hidden __get_pc_thunk_bx
00000000 w *UND* 00000000 _stdio_term
080498f4 g O .data 00000018 __atexit_lock
08048533 g F .text 00000057 __fcntl_nocancel
08049930 g O .bss 00000004 __pagesize
0804990c g *ABS* 00000000 _edata
08049954 g *ABS* 00000000 _end
08049950 g O .bss 00000004 _dl_phnum
0804858c w F .text 00000006 __errno_location
08048680 g F .text 00000067 exit
00000000 w *UND* 00000000 _stdio_init
080484cc g F .text 00000008 .hidden __GI_geteuid
080486e8 g F .text 00000012 _dl_aux_init
08049944 w O .bss 00000004 _errno
08048798 g F .text 00000027 _exit
08048474 w F .text 00000045 open
080498d8 g O .data 00000004 program_invocation_name
080484bc g F .text 00000008 .hidden __GI_getuid
08049944 g O .bss 00000004 .hidden __GI_errno
080487fc g F .text 00000018 .hidden __GI_raise
080498cc g .data 00000000 __data_start
00000000 w *UND* 00000000 _Jv_RegisterClasses
0804858c g F .text 00000006 .hidden __GI___errno_location
080484dc w F .text 00000057 fcntl
080498d8 w O .data 00000004 __progname_full
080487fc g F .text 00000018 raise
080487c0 g F .text 0000003a sigprocmask
-------------- next part --------------
true2: file format elf32-i386
true2
architecture: i386, flags 0x00000011:
HAS_RELOC, HAS_SYMS
start address 0x00000000
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000001d 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 00000000 00000000 00000054 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000054 2**2
ALLOC
3 .comment 00000012 00000000 00000000 00000054 2**0
CONTENTS, READONLY
4 .note.GNU-stack 00000000 00000000 00000000 00000066 2**0
CONTENTS, READONLY
SYMBOL TABLE:
00000000 l df *ABS* 00000000 true.c
00000000 l d .text 00000000 .text
00000000 l d .data 00000000 .data
00000000 l d .bss 00000000 .bss
00000000 l d .note.GNU-stack 00000000 .note.GNU-stack
00000000 l d .comment 00000000 .comment
00000000 g F .text 0000001d main
00000000 *UND* 00000000 _exit
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
00000019 R_386_PC32 _exit
More information about the uClibc
mailing list