This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _dl_profile_fixup & libc_p


thanks for your advice. This is my sample program:

int main(){
	struct passwd* p=getpwuid(1002);
        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
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
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
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)
 /usr/lib/gcc/i486-linux-gnu/4.2.3/collect2 -m elf_i386
--hash-style=both -static -o parallel
-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/../../../../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
/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 .got .got.plt .data
.bss __libc_freeres_ptrs
   02     .note.ABI-tag
   03     .tdata .tbss

There is no reference to, 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
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
#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
#4  0x0804ff8c in getpwuid (uid=1002) at ../nss/getXXbyYY.c:119
#5  0x08048252 in main ()

Thanks a lot for yor help !!!

Gian Lorenzo Meocci

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]