Bug 11182

Summary: gold can't find a scripted INPUT when both script and input are in a subdirectory
Product: binutils Reporter: Rohan Hart <rohan.hart17>
Component: goldAssignee: Cary Coutant <ccoutant>
Status: ASSIGNED ---    
Severity: normal CC: bug-binutils, ccoutant, gideon, Ralf.Wildenhues
Priority: P2    
Version: 2.20   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: patch to remove path of INPUT'd file names

Description Rohan Hart 2010-01-19 00:59:06 UTC
Original ld could INPUT a file relative to the current directory.  For example
the script 'dist/ld.script' containing

  INPUT(dist/source1.o dist/source2.o)

can be linked using: ld dist/ld.script

Gold will work if the script is changed to contain
  
  INPUT(source1.o source2.o)

ie., it resolves relative to the script file, but then the old ld can not find
the files.
Comment 1 Rohan Hart 2010-01-20 10:32:14 UTC
Created attachment 4542 [details]
patch to remove path of INPUT'd file names
Comment 2 Ralf Wildenhues 2010-03-29 17:08:53 UTC
This issue occurs frequently with libtool when command lines are long, on
systems where the command line length limit is low.  The scripts usually look
like this (taken from the libtool pdemo tests):

$ cat .libs/libhello.la.lnkscript
INPUT (
.libs/longer_file_name_hello.o
.libs/longer_file_name_foo.o
.libs/longer_file_name_foo2.o
)

$ ls .libs
libhello.la.lnkscript  longer_file_name_foo2.o  longer_file_name_foo.o 
longer_file_name_hello.o

$ /bin/sh ./libtool --tag=CC   --mode=link gcc  -flto -O2 -no-undefined
-version-info 3:12:1  -o libhello.la -rpath /tmp/libtool/build/_inst-pdemo/lib
longer_file_name_hello.lo longer_file_name_foo.lo longer_file_name_foo2.lo -lm -ldl 
libtool: link: gcc -shared  -fPIC -DPIC .libs/libhello.la.lnkscript  -lm -ldl 
-flto -O2   -Wl,-soname -Wl,libhello.so.2 -o .libs/libhello.so.2.1.12
/opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../x86_64-unknown-linux-gnu/bin/ld:
error: cannot find .libs/longer_file_name_hello.o
/opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../x86_64-unknown-linux-gnu/bin/ld:
error: cannot find .libs/longer_file_name_foo.o
/opt/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.5.0/../../../../x86_64-unknown-linux-gnu/bin/ld:
error: cannot find .libs/longer_file_name_foo2.o
collect2: ld returned 1 exit status
make[5]: *** [libhello.la] Error 1

Now, my on-topic question: do you expect this issue to be fixed, and addressed
soonish?  I'm trying to gauge whether libtool should work around this by
treating BFD ld and gold differently (which would add a couple more configure
tests again).  Thanks.
Comment 3 Ian Lance Taylor 2010-03-29 21:02:54 UTC
I expect that I or somebody will fix this fairly soon but I don't know exactly 
when.

Obviously if anybody wants to send a patch, that would be great.
Comment 4 Ralf Wildenhues 2010-03-30 17:00:40 UTC
(In reply to comment #3)
> Obviously if anybody wants to send a patch, that would be great.

FWIW, the patch from comment #1 strips all directory parts, whereas BFD ld only
strips the version script name part; i.e., with

cat >sub/ld.script <<\EOF
INPUT(sub2/file.o)
EOF

BFD ld looks at sub2/file.o but not at file.o nor at sub/sub2/file.o.
Comment 5 Cary Coutant 2015-06-08 00:53:39 UTC
*** Bug 16341 has been marked as a duplicate of this bug. ***