glibc/sysdeps
Maciej W. Rozycki 9c82da17b5 [BZ #17078] ARM: R_ARM_TLS_DESC prelinker support
This is a change to the dynamic linker to add prelinker support for the
R_ARM_TLS_DESC relocation.  Two cases can be considered here, the usual
one where lazy binding is in use and the less frequent one, where
immediate binding is requested via the use of the DF_BIND_NOW dynamic
flag (e.g. by using the GNU linker's "-z now" option).

This change only handles the first case.  In this scenario the prelinker
does what the dynamic linker would do, that is it preinitialises
R_ARM_TLS_DESC relocations with a pointer to the lazy specialization as
provided with the DT_TLSDESC_PLT dynamic tag.  A conflict is
additionally created and in the conflict resolution path the dynamic
linker complements the work by initialising the object's pointer as
indicated by the DT_TLSDESC_GOT dynamic tag to the linker's internal
lazy specialization worker function and also providing the associated
link map in the second entry of the GOT.  This step is required, because
if prelinking is successful at the run time, then the dynamic linker's
elf_machine_runtime_setup() function isn't called that would normally do
so.

The second case remains unresolved, because support for that scenario
has not been implemented in the prelinker.  In this case the lazy
specialization is unavailable and the DT_TLSDESC_PLT dynamic tag is not
present.

The prelinker could assume the common case of static specialization and
resolve the relocation, but that would require the exposure of dynamic
linker's specialization worker function.  Furthermore the dynamic linker
would have to handle the relocation in the conflict resolution path and
see if the dynamic specialization should be used instead.  This however
would require access to data structures currently not made available to
the conflict resolution path and therefore a redesign of this part of
the dynamic linker.

Alternatively the prelinker could defer all processing to the dynamic
linker's conflict resolution path, but that would require similar access
to the said data structures.

Therefore the prelinker issues an error instead and the dynamic linker
has assertions to check that DT_TLSDESC_PLT and DT_TLSDESC_GOT are in
use in its conflict resolution path.

This change resolves all TLS failures in the prelinker testsuite, as
noted in the bug report, as well as the small test case provided there.
Unfortunately we don't seem to have any hooks to factor in the prelinker
(if present on a system) to testing, so at this time this fix has to
rely on using the prelinker test suite and enabling TLS descriptors
there for coverage.

	[BZ #17078]
	* sysdeps/arm/dl-machine.h (elf_machine_rela)
	[RESOLVE_CONFLICT_FIND_MAP]: Handle R_ARM_TLS_DESC relocation.
	(elf_machine_lazy_rel): Handle prelinked R_ARM_TLS_DESC entries.
2014-07-17 19:22:05 +01:00
..
aarch64 Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
alpha Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
arm [BZ #17078] ARM: R_ARM_TLS_DESC prelinker support 2014-07-17 19:22:05 +01:00
generic Fix Wundef warning for __cplusplus 2014-07-09 10:36:23 +05:30
gnu Refactor handling of /lib64 etc. cases, move out of sysdeps/gnu/configure.ac. 2014-07-17 14:35:48 +00:00
hppa Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
i386 Enable AVX2 optimized memset only if -mavx2 works 2014-07-14 07:58:27 -07:00
ia64 Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
ieee754 Fix ldbl-128 expm1l spurious underflow (bug 16539). 2014-06-30 17:38:16 +00:00
init_array Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
m68k Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
mach Fix -Wundef warning on PAGE_COPY_THRESHOLD 2014-07-03 01:49:43 +05:30
microblaze Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
mips Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
nptl Separate Linuxisms from lowlevellock.h, make a generic one 2014-07-15 15:23:06 -07:00
posix Fix typo in macro name 2014-07-02 15:09:39 +05:30
powerpc Fix missing newline in test output 2014-07-09 11:07:24 +02:00
pthread Restore subdir conditional for tst-timer dependency. 2014-07-03 18:52:51 -07:00
s390 S390: Quash unused variable warning due to no-op THREAD_SET_POINTER_GUARD. 2014-07-03 19:17:00 -07:00
sh Fix Wundef warning for ELF_MACHINE_NO_RELA 2014-06-26 22:30:40 +05:30
sparc Get rid of sparc specific NPTL internaltypes.h header. 2014-07-09 22:19:09 -07:00
tile Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
unix [PATCH 6/6] Split s390 out of main Linux kernel-features.h. 2014-07-17 17:55:44 +00:00
wordsize-32 Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
wordsize-64 Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
x86 x86: Consolidate unnecessary nptl/ subdirectories. 2014-06-24 19:17:43 -07:00
x86_64 Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00