This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: _dl_profile_fixup & libc_p
Hi,
thanks for your advice. This is my sample program:
int main(){
struct passwd* p=getpwuid(1002);
printf("%s\n",p->pw_name);
return 0;
}
Than I compi it:
meox@ciop:~/parallel$ gcc -v -pg -static parallel.c -o parallel -lc_p
-lpthread_p -lm_p -L/home/meox/myglibc/lib/
and this is a result:
meox@ciop:~/parallel$ gcc -v -pg -static parallel.c -o parallel -lc_p
-lpthread_p -lm_p -L/home/meox/myglibc/lib/
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2
--enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-mpfr --disable-libmudflap --enable-targets=all
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu
--target=i486-linux-gnu
Thread model: posix
gcc version 4.2.3 (Debian 4.2.3-2)
/usr/lib/gcc/i486-linux-gnu/4.2.3/cc1 -quiet -v parallel.c -quiet
-dumpbase parallel.c -mtune=generic -auxbase parallel -version -p -o
/tmp/cchYrDPU.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.2.3/include
/usr/include
End of search list.
GNU C version 4.2.3 (Debian 4.2.3-2) (i486-linux-gnu)
compiled by GNU C version 4.2.3 (Debian 4.2.3-2).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4a23e4f7431ab2ec66fd927aedaef7c6
as -V -Qy -o /tmp/ccQGVdFH.o /tmp/cchYrDPU.s
GNU assembler version 2.18.0 (i486-linux-gnu) using BFD version (GNU
Binutils for Debian) 2.18.0.20080103
/usr/lib/gcc/i486-linux-gnu/4.2.3/collect2 -m elf_i386
--hash-style=both -static -o parallel
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/gcrt1.o
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.2.3/crtbeginT.o
-L/home/meox/myglibc/lib/ -L/usr/lib/gcc/i486-linux-gnu/4.2.3
-L/usr/lib/gcc/i486-linux-gnu/4.2.3
-L/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.2.3/../../..
/tmp/ccQGVdFH.o -lc_p -lpthread_p -lm_p --start-group -lgcc -lgcc_eh
-lc --end-group /usr/lib/gcc/i486-linux-gnu/4.2.3/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.2.3/../../../../lib/crtn.o
/tmp/ccQGVdFH.o: In function `main':
parallel.c:(.text+0x1e): warning: Using 'getpwuid' in statically
linked applications requires at runtime the shared libraries from the
glibc version used for linking
(NOTE the last warning !!!!!!!!!!!!)
Than I try this:
meox@ciop:~/parallel$ readelf -l parallel
Elf file type is EXEC (Executable file)
Entry point 0x8048130
There are 5 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000000 0x08048000 0x08048000 0x7f4ad 0x7f4ad R E 0x1000
LOAD 0x080000 0x080c8000 0x080c8000 0x007a8 0x07d80 RW 0x1000
NOTE 0x0000d4 0x080480d4 0x080480d4 0x00020 0x00020 R 0x4
TLS 0x080000 0x080c8000 0x080c8000 0x00014 0x0002c R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
Section to Segment mapping:
Segment Sections...
00 .note.ABI-tag .init .text __libc_freeres_fn
__libc_thread_freeres_fn .fini .rodata __libc_atexit __libc_subfreeres
__libc_thread_subfreeres .eh_frame .gcc_except_table
01 .tdata .ctors .dtors .jcr .data.rel.ro .got .got.plt .data
.bss __libc_freeres_ptrs
02 .note.ABI-tag
03 .tdata .tbss
04
There is no reference to ld.so, infact
meox@ciop:~/parallel$ ldd parallel
not a dynamic executable
When I compiled with -lc all work, but with -lc_p I always get
something like this:
Program received signal SIGSEGV, Segmentation fault.
0x08095ca7 in _dl_fixup (l=0x80c95bc, reloc_offset=3218069876) at
dl-runtime.c:70
70 const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
(gdb) bt
#0 0x08095ca7 in _dl_fixup (l=0x80c95bc, reloc_offset=3218069876) at
dl-runtime.c:70
#1 0x0807f7d0 in _dl_runtime_resolve ()
#2 0xb7f48b55 in _nss_compat_getpwuid_r (uid=1002, pwd=0x80c95bc,
buffer=0x80d1120 "", buflen=1024, errnop=0x80d0818)
at nss_compat/compat-pwd.c:1105
#3 0x0805014d in __getpwuid_r (uid=1002, resbuf=0x80c95bc,
buffer=0x80d1120 "", buflen=1024, result=0xbfcfda5c) at
../nss/getXXbyYY_r.c:226
#4 0x0804ff8c in getpwuid (uid=1002) at ../nss/getXXbyYY.c:119
#5 0x08048252 in main ()
Thanks a lot for yor help !!!
--
Gian Lorenzo Meocci
http://www.meocci.it