This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

gold doesn't accept object file as script


Hi Ian,

According "man ld" "If the linker cannot recognize the format
of an object file, it will assume that it is a linker script."

But gold doesn't follow above. For details, see test case below.

Briefly, the command "gcc -fuse-ld=gold -o a.4 -shared exports.ld a.a"
if exports.ld is linker script leads to warning
"exports.ld:1:8: ignoring command OPTION; OPTION is only valid for
scripts specified via -T/--script" and resulted shared library
doesn't contain func_a.
exports.ld contains only EXTERN(func_a)

This feature is used to link func_a (located in static library)
into shared one.

Is it by gold design or a bug?
Should I file it or it is duplicate?

What is the best way to workaround the problem?
--Wl,--undefined=func_a?

Thank you in advance
Vladimir Simonov

$ cat exports.ld
EXTERN(func_a)
$ cat b.sh
#!/bin/bash

PREF=/opt/gcc-4.4.3-glibc-2.3.2/bin/i686-unknown-linux-gnu-

rm -f a.o a.a a.1 a.2 a.3 a.4

${PREF}gcc -c -o a.o -fPIC a.c
${PREF}ar rcs a.a a.o

echo Build shared from obj by bfd
${PREF}gcc -o a.1 -shared a.o
${PREF}readelf -a a.1 | grep func_a

echo Build shared from lib by bfd
${PREF}gcc -o a.2 -shared exports.ld a.a
${PREF}readelf -a a.2 | grep func_a

echo Build shared from obj by gold
${PREF}gcc -fuse-ld=gold -o a.3 -shared a.o
${PREF}readelf -a a.3 | grep func_a

echo Build shared from lib by gold
${PREF}gcc -fuse-ld=gold -o a.4 -shared exports.ld a.a
${PREF}readelf -a a.4 | grep func_a
echo DONE

$ ./b.sh
Build shared from obj by bfd
1: 000003dc 38 FUNC GLOBAL DEFAULT 10 func_a
44: 000003dc 38 FUNC GLOBAL DEFAULT 10 func_a
Build shared from lib by bfd
1: 000003dc 38 FUNC GLOBAL DEFAULT 10 func_a
44: 000003dc 38 FUNC GLOBAL DEFAULT 10 func_a
Build shared from obj by gold
6: 0000043c 38 FUNC GLOBAL DEFAULT 11 func_a
27: 0000043c 38 FUNC GLOBAL DEFAULT 11 func_a
Build shared from lib by gold
/opt/gcc-4.4.3-glibc-2.3.2/bin/../lib/gcc/i686-unknown-linux-gnu/4.4.3/../../../../i686-unknown-linux-gnu/bin/ld.gold: warning: exports.ld:1:8: ignoring command OPTION; OPTION is only valid for scripts specified via -T/--script
DONE



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