binutils-gdb/ld/testsuite/ld-powerpc
Alan Modra f0158f4416 PowerPC dynamic relocations
This patch fixes a number of issues with powerpc dynamic relocations.

1) Both ppc and ppc64 were emitting more dynamic symbols and
relocations than necessary, due to not supporting static linker
resolution of tls_index entries for __tls_get_addr_opt.  This meant
that any @got@tlsgd or @got@tlsld reloc needed to make their symbols
dynamic and generate dptmod and dtprel relocs for the dynamic linker.
That would have been passable, but what happened was that practically
all @got relocations resulted in their symbols being made dynamic and
dynamic relocations emitted against the GOT entries.  (Mostly visible
on ppc32 executables since ppc64 gcc really only uses @got style
relocs for TLS.)

2) The PowerOpen syntax was not supported with __tls_get_addr_opt.
DTPMOD/DTPREL relocs on tls_index TOC entries did not use the trick of
forcing dynamic symbols and relocations so those entries always
resulted in the full __tls_get_addr processing.  gcc doesn't use the
PowerOpen syntax for TLS, and normally such code would be optimized to
TLS IE or LE so the impact of missing this support was minimal.

3) In an executable, relocations against GNU indirect functions always
used the value of their PLT stub.   While this is correct, it is
better in some cases to use a dynamic relocation.  An extra dynamic
relocation can mean that calls via function pointers need not bounce
through the PLT stub at runtime.

The patch also tidies the PLT handling code in ppc32
allocate_dynrelocs.  Allocating PLT entries after other dynamic relocs
allows the PLT loop to omit special handling for undefined weak
symbols, and that in turn allows the loop to be simplified.

bfd/
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Merge two cases
	where dynamic relocs are preferable.  Allow ifunc too.
	(ensure_undefweak_dynamic): New function.
	(allocate_dynrelocs): Use it here.  Move plt handling last and
	don't make symbols dynamic, simplifying loop.  Only make undef
	weak symbols with GOT entries dynamic.  Correct condition
	for GOT relocs.  Handle dynamic relocs on ifuncs.  Correct
	comments.  Remove goto.
	(ppc_elf_relocate_section): Correct test for using dynamic
	symbol on GOT relocs.  Rearrange test for emitting GOT relocs
	to suit.  Set up explicit tls_index entries and implicit GOT
	tls_index entries resolvable at link time for
	__tls_get_addr_opt.  Simplify test to clear mem for prelink.
	* elf64-ppc.c (allocate_got): Correct condition for GOT relocs.
	(ensure_undefweak_dynamic): New function.
	(allocate_dynrelocs): Use it here.  Only make undef weak symbols
	with GOT entries dynamic.  Remove unnecessary test of
	WILL_CALL_FINISH_DYNAMIC_SYMBOL in PLT handling.
	(ppc64_elf_relocate_section): Correct test for using dynamic
	symbol on GOT relocs.  Rearrange test for emitting GOT relocs
	to suit.  Set up explicit tls_index entries and implicit GOT
	tls_index entries resolvable at link time for __tls_get_addr_opt.
	Simplify expression to clear mem for prelink.
ld/
	* testsuite/ld-powerpc/tlsexe.r: Update for fewer dynamic relocs
	and symbols.
	* testsuite/ld-powerpc/tlsexe.d: Likewise.
	* testsuite/ld-powerpc/tlsexe.g: Likewise.
2017-01-24 12:15:54 +10:30
..
addpcis.d
addpcis.s
aix52.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
aix-abs-branch-1.dd
aix-abs-branch-1.ex
aix-abs-branch-1.im
aix-abs-branch-1.nd
aix-abs-branch-1.s
aix-abs-reloc-1.ex
aix-abs-reloc-1.im
aix-abs-reloc-1.nd
aix-abs-reloc-1.od
aix-abs-reloc-1.s
aix-core-sec-1.ex
aix-core-sec-1.hd
aix-core-sec-1.s
aix-core-sec-2.ex
aix-core-sec-2.hd
aix-core-sec-2.s
aix-core-sec-3.ex
aix-core-sec-3.hd
aix-core-sec-3.s
aix-export-1-all.dd
aix-export-1-full.dd
aix-export-1a.s
aix-export-1b.s
aix-export-2.nd
aix-export-2.s
aix-gc-1-32.dd
aix-gc-1-64.dd
aix-gc-1.ex
aix-gc-1.nd
aix-gc-1.s
aix-glink-1-32.d
aix-glink-1-32.dd
aix-glink-1-64.d
aix-glink-1-64.dd
aix-glink-1.ex
aix-glink-1.s
aix-glink-2-32.dd
aix-glink-2-64.dd
aix-glink-2a.ex
aix-glink-2a.s
aix-glink-2b.s
aix-glink-2c.ex
aix-glink-2c.s
aix-glink-2d.s
aix-glink-3-32.d
aix-glink-3-64.d
aix-glink-3.dd
aix-glink-3.s
aix-glink-3a.s
aix-glink-3b.s
aix-lineno-1.s
aix-lineno-1.txt
aix-lineno-1a.dd
aix-lineno-1a.nd
aix-lineno-1b.dd
aix-lineno-1b.nd
aix-no-dup-syms-1-dso.dnd
aix-no-dup-syms-1-dso.drd
aix-no-dup-syms-1-dso.nd
aix-no-dup-syms-1-dso.rd
aix-no-dup-syms-1-rel.nd
aix-no-dup-syms-1-rel.rd
aix-no-dup-syms-1.ex
aix-no-dup-syms-1.im
aix-no-dup-syms-1a.s
aix-no-dup-syms-1b.s
aix-ref-1-32.od
aix-ref-1-64.od
aix-ref-1.s
aix-rel-1.od
aix-rel-1.s
aix-toc-1-32.dd
aix-toc-1-64.dd
aix-toc-1.ex
aix-toc-1a.s
aix-toc-1b.s
aix-weak-1-dso.dnd
aix-weak-1-dso.hd
aix-weak-1-dso.nd
aix-weak-1-gcdso.dnd
aix-weak-1-gcdso.hd
aix-weak-1-gcdso.nd
aix-weak-1-rel.hd
aix-weak-1-rel.nd
aix-weak-1.ex
aix-weak-1a.s
aix-weak-1b.s
aix-weak-2a.ex
aix-weak-2a.nd
aix-weak-2a.s
aix-weak-2b.nd
aix-weak-2b.s
aix-weak-2c.ex
aix-weak-2c.nd
aix-weak-2c.od
aix-weak-2c.s
aix-weak-3-32.d
aix-weak-3-32.dd
aix-weak-3-64.d
aix-weak-3-64.dd
aix-weak-3a.ex
aix-weak-3a.s
aix-weak-3b.ex
aix-weak-3b.s
ambiguousv1.d
ambiguousv1b.d
ambiguousv2.d
ambiguousv2b.d
apuinfo1.s PowerPC VLE 2016-06-07 22:04:38 +09:30
apuinfo2.s
apuinfo-nul1.s
apuinfo-nul.rd
apuinfo-nul.s
apuinfo-vle2.s PowerPC VLE 2016-06-07 22:04:38 +09:30
apuinfo-vle.rd
apuinfo-vle.s
apuinfo.rd
attr-gnu-4-0.s
attr-gnu-4-1.s
attr-gnu-4-2.s
attr-gnu-4-3.s
attr-gnu-4-00.d
attr-gnu-4-01.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-02.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-03.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-10.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-11.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-12.d
attr-gnu-4-13.d
attr-gnu-4-20.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-21.d
attr-gnu-4-22.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-23.d
attr-gnu-4-31.d
attr-gnu-4-32.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-4-33.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-8-1.s
attr-gnu-8-2.s
attr-gnu-8-3.s
attr-gnu-8-11.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-8-23.d PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
attr-gnu-8-31.d
attr-gnu-12-1.s
attr-gnu-12-2.s
attr-gnu-12-11.d
attr-gnu-12-21.d
defsym.d
defsym.s
dotsym1.d PowerPC64 dot-symbol compatibility bugfixes 2016-12-03 21:00:01 +10:30
dotsym2.d PowerPC64 dot-symbol compatibility bugfixes 2016-12-03 21:00:01 +10:30
dotsym3.d PowerPC64 dot-symbol compatibility bugfixes 2016-12-03 21:00:01 +10:30
dotsym4.d PowerPC64 dot-symbol compatibility bugfixes 2016-12-03 21:00:01 +10:30
dotsymref.s PowerPC64 dot-symbol compatibility bugfixes 2016-12-03 21:00:01 +10:30
elfv2-2a.s
elfv2-2b.s
elfv2-2exe.d
elfv2-2so.d
elfv2.s
elfv2exe.d PR20337, Objdump makes poor choice of symbols 2016-07-09 16:53:33 +09:30
elfv2so.d
export-class.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
funref2.s
funref.s
funv1.s
funv2.s
nodotsym.s PowerPC64 dot-symbol compatibility bugfixes 2016-12-03 21:00:01 +10:30
oldtlslib.s
plt1.d
plt1.s
powerpc-32-export-class.rd
powerpc-32-export-class.xd
powerpc-64-export-class.rd
powerpc-64-export-class.xd
powerpc.exp Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ppc476-shared2.d
ppc476-shared.d
ppc476-shared.lnk
ppc476-shared.s
relax.d
relax.s
relaxr.d
relbrlt.d
relbrlt.s
reloc.d
reloc.s
relocsort.d
relocsort.s
sdabase2.d
sdabase2.t
sdabase.d
sdabase.s
sdabase.t
sdadyn.d
sdadyn.s
sdalib.s
startv1.s
startv2.s
symtocbase-1.s
symtocbase-2.s
symtocbase.d
tls32.d
tls32.g
tls32.s
tls32.t
tls.d
tls.g
tls.s
tls.t
tlsdll_32.s ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsdll.s ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsdll.ver ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsexe32.d
tlsexe32.g
tlsexe32.r Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
tlsexe32.t
tlsexe.d PowerPC dynamic relocations 2017-01-24 12:15:54 +10:30
tlsexe.g PowerPC dynamic relocations 2017-01-24 12:15:54 +10:30
tlsexe.r PowerPC dynamic relocations 2017-01-24 12:15:54 +10:30
tlsexe.t
tlsexetoc.d
tlsexetoc.g
tlsexetoc.r Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
tlsexetoc.t
tlsld32.d
tlsld32.s
tlsld.d
tlsld.s
tlslib32.s
tlslib.s
tlsmark32.d
tlsmark32.s
tlsmark.d
tlsmark.s
tlsopt1_32.d
tlsopt1_32.s
tlsopt1.d
tlsopt1.s
tlsopt2_32.d
tlsopt2_32.s
tlsopt2.d
tlsopt2.s
tlsopt3_32.d
tlsopt3_32.s
tlsopt3.d
tlsopt3.s
tlsopt4_32.d
tlsopt4_32.s
tlsopt4.d
tlsopt4.s
tlsopt5_32.d ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsopt5_32.s ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsopt5.d ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsopt5.s ld --gc-sections fail with __tls_get_addr_opt 2016-05-11 22:40:09 +09:30
tlsso32.d
tlsso32.g
tlsso32.r Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
tlsso32.t
tlsso.d
tlsso.g
tlsso.r Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
tlsso.t
tlstoc.d
tlstoc.g
tlstoc.s
tlstoc.t
tlstocso.d
tlstocso.g
tlstocso.r Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
tlstocso.t
tocnovar.d
tocnovar.s
tocopt2.d
tocopt2.out
tocopt2.s
tocopt3.d
tocopt3.s
tocopt4.d
tocopt4a.s
tocopt4b.s
tocopt5.d
tocopt5.s
tocopt6-inc.s
tocopt6.d
tocopt6a.s
tocopt6b.s
tocopt6c.s
tocopt7.d PowerPC64 toc optimisation for power9 2016-12-06 18:25:14 +10:30
tocopt7.out PowerPC64 toc optimisation for power9 2016-12-06 18:25:14 +10:30
tocopt7.s PowerPC64 toc optimisation for power9 2016-12-06 18:25:14 +10:30
tocopt8.d PowerPC64 toc optimisation for power9 2016-12-06 18:25:14 +10:30
tocopt8.s PowerPC64 toc optimisation for power9 2016-12-06 18:25:14 +10:30
tocopt.d
tocopt.out
tocopt.s
tocvar.d
tocvar.s
vle-multiseg-1.d Adjust VLE testsuite 2016-08-31 14:05:44 +09:30
vle-multiseg-1.ld
vle-multiseg-2.d Adjust VLE testsuite 2016-08-31 14:05:44 +09:30
vle-multiseg-2.ld
vle-multiseg-3.d Adjust VLE testsuite 2016-08-31 14:05:44 +09:30
vle-multiseg-3.ld
vle-multiseg-4.d
vle-multiseg-4.ld
vle-multiseg-5.d Update linker tests after partial reversion of PR 20815 patch. 2016-11-28 17:51:57 +00:00
vle-multiseg-5.ld
vle-multiseg-6.d Adjust VLE testsuite 2016-08-31 14:05:44 +09:30
vle-multiseg-6.ld
vle-multiseg-6a.s
vle-multiseg-6b.s
vle-multiseg-6c.s
vle-multiseg-6d.s
vle-multiseg.s
vle-reloc-1.d
vle-reloc-1.s
vle-reloc-2.d Adjust VLE testsuite 2016-08-31 14:05:44 +09:30
vle-reloc-2.s
vle-reloc-3.d
vle-reloc-3.s
vle-reloc-def-1.s
vle-reloc-def-2.s
vle-reloc-def-3.s
vle.ld
vxworks1-lib.dd
vxworks1-lib.nd
vxworks1-lib.rd
vxworks1-lib.s
vxworks1-lib.sd
vxworks1-lib.td
vxworks1-static.d
vxworks1.dd
vxworks1.ld
vxworks1.rd
vxworks1.s
vxworks2-static.sd
vxworks2.s
vxworks2.sd Fix the linker so that it will not silently generate ELF binaries with invalid program headers. Fix readelf to report such invalid binaries. 2016-11-23 11:10:39 +00:00
vxworks-relax-2.rd
vxworks-relax-2.s
vxworks-relax.rd
vxworks-relax.s