binutils-gdb/ld/testsuite/ld-powerpc/elfv2so.d
Alan Modra 2d7ad24e87 Support PLT16 relocs against local symbols
Necessary if gcc is to use PLT16 relocs to implement -mlongcall, and
there isn't a good technical reason why local symbols should be
excluded from PLT16 support.  Non-ifunc local symbol PLT entries go in
a separate section to other PLT entries.  In a fixed position
executable they won't need to be relocated, and in a PIE or shared
library I chose to not implement lazy relocation.

bfd/
	* elf64-ppc.c (LOCAL_PLT_ENTRY_SIZE): Define.
	(struct ppc_stub_hash_entry): Add symtype field.
	(PLT_KEEP): Define.
	(struct ppc_link_hash_table): Add pltlocal and relpltlocal.
	(create_linkage_sections): Create pltlocal and relpltlocal.
	(ppc64_elf_check_relocs): Allow PLT relocs on local symbols.
	Set PLT_KEEP.
	(ppc64_elf_adjust_dynamic_symbol): Keep PLT entries for inline calls.
	(allocate_dynrelocs): Allocate pltlocal and relpltlocal.
	(ppc64_elf_size_dynamic_sections): Size pltlocal and relpltlocal.
	Keep PLT entries for inline calls against locals.
	(ppc_build_one_stub): Use pltlocal as appropriate.
	(ppc_size_one_stub): Likewise.
	(ppc64_elf_size_stubs): Set symtype.
	(build_global_entry_stubs_and_plt): Init pltlocal and write
	relpltlocal for globals.
	(write_plt_relocs_for_local_syms): Likewise for local syms.
	(ppc64_elf_relocate_section): Support PLT for local syms.
	* elf32-ppc.c (PLT_KEEP): Define.
	(struct ppc_elf_link_hash_table): Add pltlocal and relpltlocal.
	(ppc_elf_create_glink): Create pltlocal and relpltlocal.
	(ppc_elf_check_relocs): Allow PLT relocs on local symbols.
	Set PLT_KEEP.  Adjust update_local_sym_info call.
	(ppc_elf_adjust_dynamic_symbol): Keep PLT entries for inline calls.
	(allocate_dynrelocs): Allocate pltlocal and relpltlocal.
	(ppc_elf_size_dynamic_sections): Size pltlocal and relpltlocal.
	(ppc_elf_relocate_section): Support PLT16 relocs for local syms.
	(write_global_sym_plt): Init pltlocal and write relpltlocal.
	(ppc_finish_symbols): Likewise for locals.
ld/
	* emulparams/elf32ppc.sh (OTHER_RELRO_SECTIONS_2): Add .branch_lt.
	(OTHER_GOT_RELOC_SECTIONS): Add .rela.branch_lt.
	* testsuite/ld-powerpc/elfv2so.d: Update for symbol/stub reordering.
	* testsuite/ld-powerpc/relbrlt.d: Likewise.
	* testsuite/ld-powerpc/relbrlt.s: Likewise.
	* testsuite/ld-powerpc/tlsso.r: Likewise.
	* testsuite/ld-powerpc/tlstocso.r: Likewise.
gold/
	* powerpc.cc (Target_powerpc::lplt_): New variable.
	(Target_powerpc::lplt_section): Associated accessor.
	(Target_powerpc::plt_off): Handle local non-ifunc symbols.
	(Target_powerpc::make_lplt_section): New function.
	(Target_powerpc::make_local_plt_entry): New function.
	(Powerpc_relobj::do_relocate_sections): Write out lplt.
	(Output_data_plt_powerpc::first_plt_entry_offset): Zero for lplt.
	(Output_data_plt_powerpc::add_local_entry): New function.
	(Output_data_plt_powerpc::do_write): Ignore lplt.
	(Target_powerpc::make_iplt_section): Make lplt first.
	(Target_powerpc::make_brlt_section): Make .branch_lt relro.
	(Target_powerpc::Scan::local): Handle PLT16 relocs.
2018-04-09 17:05:09 +09:30

87 lines
2.8 KiB
Makefile

#source: elfv2.s
#as: -a64
#ld: -melf64ppc -shared
#objdump: -dr
.*
Disassembly of section \.text:
.* <.*\.plt_call\.f4>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
.*: (e9 82 80 38|38 80 82 e9) ld r12,-32712\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f3>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
.*: (e9 82 80 28|28 80 82 e9) ld r12,-32728\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f1>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
.*: (e9 82 80 40|40 80 82 e9) ld r12,-32704\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <.*\.plt_call\.f2>:
.*: (f8 41 00 18|18 00 41 f8) std r2,24\(r1\)
.*: (e9 82 80 30|30 80 82 e9) ld r12,-32720\(r2\)
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (4e 80 04 20|20 04 80 4e) bctr
\.\.\.
.* <f1>:
.*: (3c 4c 00 02|02 00 4c 3c) addis r2,r12,2
.*: (38 42 .. ..|.. .. 42 38) addi r2,r2,.*
.*: (7c 08 02 a6|a6 02 08 7c) mflr r0
.*: (f8 21 ff e1|e1 ff 21 f8) stdu r1,-32\(r1\)
.*: (f8 01 00 30|30 00 01 f8) std r0,48\(r1\)
.*: (4b ff ff ad|ad ff ff 4b) bl .*\.plt_call\.f1>
.*: (e8 62 80 08|08 80 62 e8) ld r3,-32760\(r2\)
.*: (4b ff ff c5|c5 ff ff 4b) bl .*\.plt_call\.f2>
.*: (e8 41 00 18|18 00 41 e8) ld r2,24\(r1\)
.*: (e8 62 80 10|10 80 62 e8) ld r3,-32752\(r2\)
.*: (4b ff ff 79|79 ff ff 4b) bl .*\.plt_call\.f3>
.*: (e8 41 00 18|18 00 41 e8) ld r2,24\(r1\)
.*: (4b ff ff 51|51 ff ff 4b) bl .*\.plt_call\.f4>
.*: (e8 41 00 18|18 00 41 e8) ld r2,24\(r1\)
.*: (e8 01 00 30|30 00 01 e8) ld r0,48\(r1\)
.*: (38 21 00 20|20 00 21 38) addi r1,r1,32
.*: (7c 08 03 a6|a6 03 08 7c) mtlr r0
.*: (4e 80 00 20|20 00 80 4e) blr
.*
.*
.* <__glink_PLTresolve>:
.*: (7c 08 02 a6|a6 02 08 7c) mflr r0
.*: (42 9f 00 05|05 00 9f 42) bcl .*
.*: (7d 68 02 a6|a6 02 68 7d) mflr r11
.*: (18 00 41 f8|f8 41 00 18) std r2,24\(r1\)
.*: (e8 4b ff f0|f0 ff 4b e8) ld r2,-16\(r11\)
.*: (7c 08 03 a6|a6 03 08 7c) mtlr r0
.*: (7d 8b 60 50|50 60 8b 7d) subf r12,r11,r12
.*: (7d 62 5a 14|14 5a 62 7d) add r11,r2,r11
.*: (38 0c ff d0|d0 ff 0c 38) addi r0,r12,-48
.*: (e9 8b 00 00|00 00 8b e9) ld r12,0\(r11\)
.*: (78 00 f0 82|82 f0 00 78) rldicl r0,r0,62,2
.*: (7d 89 03 a6|a6 03 89 7d) mtctr r12
.*: (e9 6b 00 08|08 00 6b e9) ld r11,8\(r11\)
.*: (4e 80 04 20|20 04 80 4e) bctr
.* <f3@plt>:
.*: (4b ff ff c8|c8 ff ff 4b) b .* <__glink_PLTresolve>
.* <f2@plt>:
.*: (4b ff ff c4|c4 ff ff 4b) b .* <__glink_PLTresolve>
.* <f4@plt>:
.*: (4b ff ff c0|c0 ff ff 4b) b .* <__glink_PLTresolve>
.* <f1@plt>:
.*: (4b ff ff bc|bc ff ff 4b) b .* <__glink_PLTresolve>