Many tests fail when gcc passes --no-add-needed to linker
H.J. Lu
hjl.tools@gmail.com
Tue Apr 20 00:08:00 GMT 2010
On Mon, Apr 19, 2010 at 3:15 PM, Ulrich Drepper <drepper@redhat.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 04/19/2010 02:03 PM, H.J. Lu wrote:
>> That is not the case for elf/tst-tls12. It is liked against tst-tlsmod12.so:
>
> Might be that I missed something. I'll look at it again once you fixed
> the linker to handle the other cases.
>
>
The problem is
[hjl@gnu-15 needed-1]$ gcc -nostdlib -nostartfiles -o
/export/build/gnu/glibc/build-i686-linux/elf/tst-tls1
-Wl,-dynamic-linker=/lib/ld-linux.so.2 -Wl,-z,combreloc -Wl,-z,relro
-Wl,--hash-style=both
/export/build/gnu/glibc/build-i686-linux/csu/crt1.o
/export/build/gnu/glibc/build-i686-linux/csu/crti.o `gcc
--print-file-name=crtbegin.o`
/export/build/gnu/glibc/build-i686-linux/elf/tst-tls1.o
-Wl,-rpath-link=/export/build/gnu/glibc/build-i686-linux:/export/build/gnu/glibc/build-i686-linux/math:/export/build/gnu/glibc/build-i686-linux/elf:/export/build/gnu/glibc/build-i686-linux/dlfcn:/export/build/gnu/glibc/build-i686-linux/nss:/export/build/gnu/glibc/build-i686-linux/nis:/export/build/gnu/glibc/build-i686-linux/rt:/export/build/gnu/glibc/build-i686-linux/resolv:/export/build/gnu/glibc/build-i686-linux/crypt:/export/build/gnu/glibc/build-i686-linux/nptl
/export/build/gnu/glibc/build-i686-linux/libc.so.6
/export/build/gnu/glibc/build-i686-linux/libc_nonshared.a -lgcc
-Wl,--as-needed -lgcc_s -Wl,--no-as-needed `gcc
--print-file-name=crtend.o`
/export/build/gnu/glibc/build-i686-linux/csu/crtn.o
/usr/local/bin/ld:
/export/build/gnu/glibc/build-i686-linux/elf/tst-tls1.o: undefined
reference to symbol '___tls_get_addr@@GLIBC_2.3'
/usr/local/bin/ld: note: '___tls_get_addr@@GLIBC_2.3' is defined in
DSO /export/build/gnu/glibc/build-i686-linux/elf/ld-linux.so.2 so try
adding it to the linker command line
/export/build/gnu/glibc/build-i686-linux/elf/ld-linux.so.2: could not
read symbols: Invalid operation
collect2: ld returned 1 exit status
The normal libc.so has
[hjl@gnu-15 needed-1]$ cat /usr/lib/libc.so
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED (
/lib/ld-linux.so.2 ) )
[hjl@gnu-15 needed-1]$
We don't have "AS_NEEDED ( /lib/ld-linux.so.2 )" This patch adds it.
--
H.J.
-------------- next part --------------
2010-03-24 H.J. Lu <hongjiu.lu@intel.com>
* Makeconfig (link-libc): Add ld.so if linker supports --as-needed.
diff --git a/Makeconfig b/Makeconfig
index 15cd4ca..cdd2e38 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -504,6 +504,10 @@ LDFLAGS-rpath-ORIGIN = -Wl,-rpath,'$$ORIGIN'
LDFLAGS-soname-fname = -Wl,-soname,$(@F)
LDFLAGS-rdynamic = -rdynamic
LDFLAGS-Bsymbolic = -Bsymbolic
+
+ifeq ($(build-shared)$(have-as-needed),yesyes)
+link-libc += -Wl,--as-needed $(elf-objpfx)$(rtld-installed-name) -Wl,--no-as-needed
+endif
endif
# Choose the default search path for the dynamic linker based on
More information about the Libc-alpha
mailing list