Run ld.so through check-localplt, check-textrel, and check-execstack.
Commit Message
On 10/24/2014 05:40 PM, Roland McGrath wrote:
> It's a surprise to me too, and I had to check to convince myself it really
> wasn't tested somehow. I don't see any reason it shouldn't be per se. Add
> it to the list and verify nothing goes wrong. But there are reasons it's
> far less likely ever to be a problem. ld.so has no dependencies and is
> built with -z defs, so it can never have undefined references and can never
> have PLT entries for anything but its own exported symbols (unless the
> linker grows new bugs). There is a very small set of exported symbols
> (elf/Versions) that almost never changes.
How is this then?
I've added ld.so to the check-localplt, check-textrel, and check-execstack
tests. It fails only in check-localplt because there are 6 symbols which
need to be accounted.
Based on my analysis every architecture that has TLS will have:
__tls_get_addr, with the exception of i386 which has ___tls_get_addr,
and ppc64* which doesn't have it at all as a consequence of the ABI.
All machines should also have __libc_memalign, malloc, calloc, realloc,
and free in ld.so's PLT entry list.
No regressions on x86-64 and i386.
Not tested on any other machines. I expect the machine maintainers
to cleanup and I'll email them.
OK?
Cheers,
Carlos.
2014-10-29 Carlos O'Donell <carlos@redhat.com>
* elf/Makefile (all-built-dso): Add $(common-objpfx)elf/ld.so.
(localplt-build-dso): Add elf/ld.so.
* sysdeps/unix/sysv/linux/i386/localplt.data: Add ___tls_get_addr,
__libc_memalign, malloc, calloc, realloc, and free for ld.so.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/localplt.data: Add
__libc_memalign, malloc, calloc, realloc, and free for ld.so.
* sysdeps/generic/localplt.data: Add __tls_get_addr, __libc_memalign,
malloc, calloc, realloc and free for ld.so.
* sysdeps/unix/sysv/linux/aarch64/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/alpha/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/arm/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/ia64/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/m68k/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/microblaze/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/localplt.data:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/localplt.data:
Likewise.
* sysdeps/unix/sysv/linux/s390/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/localplt.data: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/localplt.data: Likewise.
---
Cheers,
Carlos.
Comments
@@ -904,7 +904,7 @@ CFLAGS-tst-pie2.c += $(pie-ccflag)
$(objpfx)tst-pie1: $(objpfx)tst-piemod1.so
ifeq (yes,$(build-shared))
-all-built-dso := $(common-objpfx)libc.so \
+all-built-dso := $(common-objpfx)elf/ld.so $(common-objpfx)libc.so \
$(filter-out $(common-objpfx)linkobj/libc.so, \
$(sort $(wildcard $(addprefix $(common-objpfx), \
*/lib*.so \
@@ -963,6 +963,7 @@ common-generated += $(all-built-dso:$(common-objpfx)%=%.jmprel)
localplt-built-dso := $(addprefix $(common-objpfx),\
libc.so \
+ elf/ld.so \
math/libm.so \
rt/librt.so \
dlfcn/libdl.so \
@@ -7,3 +7,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -12,3 +12,12 @@ libm.so: matherr
libm.so: __signbit
libm.so: __signbitf
libm.so: __signbitl
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -24,3 +24,12 @@ libm.so: matherr
# We used to offer inline functions that used this, so it must be exported.
# Ought to reorg things such that carg isn't thus forced to use a plt.
libm.so: __atan2
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -11,3 +11,12 @@ libm.so: __signbitf
libm.so: matherr
libpthread.so: __errno_location
libpthread.so: raise
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -5,3 +5,14 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs ___tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+# Note that it is triple underscore for ___tls_get_addr e.g. the alternate
+# ABI.
+ld.so: ___tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -6,3 +6,12 @@ libc.so: realloc
libm.so: matherr
libm.so: matherrf
libm.so: matherrl
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -6,3 +6,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -9,3 +9,12 @@ libm.so: __signbit
libm.so: __signbitf
libm.so: matherr
libpthread.so: __errno_location
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -5,3 +5,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -38,3 +38,12 @@ libm.so: __signbitl
libm.so: copysignl ?
libm.so: fabsl
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -4,3 +4,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader uses __libc_memalign internally to allocate aligned
+# TLS storage. The other malloc family of functions are expected to
+# allow user symbol interposition. Note that because of the way the TLS
+# ABI works there is no PLT call to __tls_get_addr on ppc64 and ppc64le.
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -5,3 +5,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -15,3 +15,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free
@@ -17,3 +17,12 @@ libc.so: malloc
libc.so: memalign
libc.so: realloc
libm.so: matherr
+# The dynamic loader needs __tls_get_addr for TLS, and uses __libc_memalign
+# internally to allocate aligned TLS storage. The other malloc family of
+# functions are expected to allow user symbol interposition.
+ld.so: __tls_get_addr
+ld.so: __libc_memalign
+ld.so: malloc
+ld.so: calloc
+ld.so: realloc
+ld.so: free