Bug 12479 - 'ld' looks for stuff in default places despite -nostdlib on command line
Summary: 'ld' looks for stuff in default places despite -nostdlib on command line
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-10 18:24 UTC by Sergei Steshenko
Modified: 2011-02-10 23:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
the 'conftest.log' file (2.70 KB, text/x-log)
2011-02-10 18:24 UTC, Sergei Steshenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Steshenko 2011-02-10 18:24:30 UTC
Created attachment 5234 [details]
the 'conftest.log' file

I have built glibc-2.13 which contains a number of crt*.o files:

"
find /mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/ -name "crt*.o"
/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/crt1.o
/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/crti.o
/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/crtn.o
sergei@amdam2:~>  
"

- I guess they are in the right place.

When I run the following command:

"
/mnt/sdb8/sergei/AFSWD_debug/install/gcc-4.4.5/binsh/gcc  -I/mnt/sdb8/sergei/AFSWD_debug/install/autogen-5.10/include -I/mnt/sdb8/sergei/AFSWD_debug/install/binutils-2.21/include -I/mnt/sdb8/sergei/AFSWD_debug/install/dejagnu-1.4.4/include -I/mnt/sdb8/sergei/AFSWD_debug/install/expect-5.44.1.14/include -I/mnt/sdb8/sergei/AFSWD_debug/install/flex-2.5.35/include -I/mnt/sdb8/sergei/AFSWD_debug/install/gcc-4.4.5/include -I/mnt/sdb8/sergei/AFSWD_debug/install/gettext-0.18/include -I/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/include -I/mnt/sdb8/sergei/AFSWD_debug/install/gmp-4.3.2/include -I/mnt/sdb8/sergei/AFSWD_debug/install/guile-1.8.7/include -I/mnt/sdb8/sergei/AFSWD_debug/install/libiconv_pre-1.13.1/include -I/mnt/sdb8/sergei/AFSWD_debug/install/libtool-2.4/include -I/mnt/sdb8/sergei/AFSWD_debug/install/mpfr-2.4.2/include -I/mnt/sdb8/sergei/AFSWD_debug/install/ncurses-5.7/include -I/mnt/sdb8/sergei/AFSWD_debug/install/ncurses-5.7/include/ncurses -I/mnt/sdb8/sergei/AFSWD_debug/install/readline-6.1/include -I/mnt/sdb8/sergei/AFSWD_debug/install/tcl-8.5.9/include -I/mnt/sdb8/sergei/AFSWD_debug/install/zlib-1.2.5/include -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/autogen-5.10/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/binutils-2.21/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/bison-2.4.3/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/flex-2.5.35/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/gcc-4.4.5/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/gettext-0.18/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/gcc-4.4.5/lib/gcc/i686-pc-linux-gnu/4.4.5 -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/gettext-0.18/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/gconv -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/gmp-4.3.2/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/guile-1.8.7/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/libiconv_pre-1.13.1/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/libtool-2.4/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/mpfr-2.4.2/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/ncurses-5.7/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/readline-6.1/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/tcl-8.5.9/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/tcl-8.5.9/lib/expect5.44.1.14 -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/zlib-1.2.5/lib  -Xlinker --verbose -Xlinker -nostdlib conftest.c 1> conftest.log 2>&1
",

containing among other things

-Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/gettext-0.18/lib -Wl,-L/mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib

, i.e. path to the crt*.o files, I'm getting in to be attached 'conftest.log' file the following:

"
sergei@amdam2:~/junk> cat -n conftest.log | grep /usr/lib
    14  SEARCH_DIR("/mnt/sdb8/sergei/AFSWD_debug/install/binutils-2.21/i686-pc-linux-gnu/lib"); SEARCH_DIR("/mnt/sdb8/sergei/AFSWD_debug/install/binutils-2.21/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
   208  attempt to open /usr/lib/crt1.o succeeded
   209  /usr/lib/crt1.o
   210  attempt to open /usr/lib/crti.o succeeded
   211  /usr/lib/crti.o
   261  attempt to open /usr/lib/crtn.o succeeded
   262  /usr/lib/crtn.o
sergei@amdam2:~/junk>     
",

i.e. the crt*.o files are taken from default rather than provided by me places.

OTOH, the linker does look for other stuff in provided by me places, e.g.:

"
sergei@amdam2:~/junk> cat -n conftest.log | grep succeeded | grep glibc-2.13
   242  attempt to open /mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/libc.so succeeded
   245  attempt to open /mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/libc.so.6 succeeded
   247  attempt to open /mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/libc_nonshared.a succeeded
   249  attempt to open /mnt/sdb8/sergei/AFSWD_debug/install/glibc-2.13/lib/ld-linux.so.2 succeeded
sergei@amdam2:~/junk>   
".
Comment 1 Sergei Steshenko 2011-02-10 18:25:42 UTC
The test program | I've used:
"
sergei@amdam2:~/junk> cat -n conftest.c
     1  #include <stdio.h>
     2
     3  int main()
     4    {
     5    printf("Hello!\n");
     6    return 0;
     7    }
sergei@amdam2:~/junk> 
".
Comment 2 Alan Modra 2011-02-10 23:04:09 UTC
pass -v to gcc and you'll likely see that the gcc driver is passing an absolute path to ld for the crt files.  ie. this has nothing to do with ld.