40937810e1
bfd/ Add TLS support for 64-bit Sparc ELF. * elf64-sparc.c (sparc64_elf_dyn_relocs, sparc64_elf_link_hash_entry, sparc64_elf_obj_tdata): New structs. (GOT_UNKNOWN, GOT_NORMAL, GOT_TLD_GD, GOT_TLD_IE, sparc64_elf_hash_entry, sparc64_elf_tdata, sparc64_elf_local_got_tls_type): New defines. (sparc64_elf_mkobject): New function. (sparc64_elf_link_hash_table): Add members for dynamic linker sections PLT, RELPLT, DYNBSS, and RELBSS. Add tls_ldm_got uion to track TLS GOT references. Add sym_sec to cache mappings from local sym to section. (link_hash_newfunc): New function. (sparc64_elf_bfd_link_hash_table_create): Rename to sparc64_elf_link_hash_table_create for consistency. Pass link_hash_newfunc to _bfd_elf_link_hash_table_init. (sparc64_elf_create_dynamic_sections): Initialize new section members of sparc64_elf_link_hash_table. Only init srelbss if not-shared. (sparc64_elf_copy_indirect_symbol, sparc64_elf_tls_transition): New functions. (SPARC_NOP): Define. (sparc64_elf_build_plt, sparc64_elf_plt_entry_offset, sparc64_elf_plt_ptr_offset): Delete. (sparc64_plt_entry_build): New function to build PLT entries gradually instread of all at once at the end of linking. (sparc64_elf_check_relocs): Delete dynobj, sgot, and srelgot local vars. Get them from sparc64_elf_hash_table instead. Check early on if r_symndx is in bounds. Handle TLS transitions. Account for TLS GOT references and DF_STATIC_TLS, as needed. For TLS relocs, record the tls_type in either sparc64_elf_local_got_tls_type or sparc64_elf_hash_entry as appropriate. For R_SPARC_TLS_{GD,LDM}_CALL, emit a reference to the __tls_get_addr symbol. For PLT relocs, track references via h->plt.refcount. When R_SPARC_{PC10,PC22,PC_HH22,PC_HM10, PC_LM22} and h not-NULL, set h->non_got_ref. For global data symbol references, count the number of relocations needed for that symbol. For default switch case, don't error, this lets the TLS relocs not explicitly handled by this function get accepted. (sparc64_elf_gc_mark_hook, sparc64_gc_sweep_hook): New functions. (sparc64_elf_adjust_dynamic_symbol): Remove dynobj local var, get it from sparc64_elf_hash_table. Store the real PLT offset in h->plt.offset, and build PLT entries one at a time. Also get .dynbss section pointer from htab. (allocate_dynrelocs, readonly_dynrelocs, sparc64_omit_section_dynsym): New functions. (sparc64_elf_omit_section_dynsym): Use these new functions as helpers. (dtpoff_base, tpoff): New functions. (sparc64_elf_relocate_section): Kill dynobj, sgot, and splt locals, get them from sparc64_elf_hash_table. Handle TLS relocations and refcounting in main relocation loop. (sparc64_elf_finish_dynamic_symbol): Use sparc64_elf_link_hash_table. Build PLT entries as we see them. Handle TLS GOT relocations. (sparc64_elf_finish_dynamic_sections): Get sgot and dynobj from sparc64_elf_hash_table. Initialize only PLT header not all entries since we not build PLT entries one by one. (elf_backend_copy_indirect_symbol, bfd_elf64_mkobject, elf_backend_gc_mark_hook, elf_backend_gc_sweep_hook, elf_backend_can_gc_sections, elf_backend_can_refcount): Define. ld/testsuite/ * ld-selective/sel-dump.exp: Do not exclude sparc64-*. * ld-selective/selective.exp: Likewise. * ld-sparc/sparc.exp: Add {32,64}-bit prefix to test names so we know which one is failing. Run sparc64 TLS tests on multi-arch sparc platforms. * ld-sparc/tls64.sd, ld-sparc/tlssunbin64.dd, ld-sparc/tlssunbin64.rd, ld/testsuite/ld-sparc/tlssunbin64.sd, ld-sparc/tlssunbin64.td, ld-sparc/tlssunnopic64.dd, ld-sparc/tlssunnopic64.rd, ld-sparc/tlssunnopic64.sd, ld-sparc/tlssunpic64.dd, ld-sparc/tlssunpic64.rd, ld-sparc/tlssunpic64.sd, ld-sparc/tlssunpic64.td): Update now that sparc64 ELF does support TLS.
221 lines
7.4 KiB
Plaintext
221 lines
7.4 KiB
Plaintext
#source: tlssunpic64.s
|
|
#source: tlspic.s
|
|
#as: --64 -Av9 -K PIC
|
|
#ld: -shared -melf64_sparc
|
|
#objdump: -drj.text
|
|
#target: sparc*-*-*
|
|
|
|
.*: +file format elf64-sparc
|
|
|
|
Disassembly of section .text:
|
|
|
|
0+1000 <fn1-0x8>:
|
|
+1000: 81 c3 e0 08 retl *
|
|
+1004: ae 03 c0 17 add %o7, %l7, %l7
|
|
|
|
0+1008 <fn1>:
|
|
+1008: 9d e3 bf 60 save %sp, -160, %sp
|
|
+100c: 2f 00 04 04 sethi %hi\(0x101000\), %l7
|
|
+1010: 7f ff ff fc call 1000 <.*>
|
|
+1014: ae 05 e1 80 add %l7, 0x180, %l7 ! 101180 <.*>
|
|
+1018: 01 00 00 00 nop *
|
|
+101c: 01 00 00 00 nop *
|
|
+1020: 01 00 00 00 nop *
|
|
+1024: 01 00 00 00 nop *
|
|
+1028: 23 00 00 00 sethi %hi\(0\), %l1
|
|
+102c: 01 00 00 00 nop *
|
|
+1030: a4 04 60 58 add %l1, 0x58, %l2
|
|
+1034: 01 00 00 00 nop *
|
|
+1038: 90 05 c0 12 add %l7, %l2, %o0
|
|
+103c: 01 00 00 00 nop *
|
|
+1040: 40 04 04 d0 call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+1044: 01 00 00 00 nop *
|
|
+1048: 01 00 00 00 nop *
|
|
+104c: 01 00 00 00 nop *
|
|
+1050: 01 00 00 00 nop *
|
|
+1054: 01 00 00 00 nop *
|
|
+1058: 11 00 00 00 sethi %hi\(0\), %o0
|
|
+105c: 92 02 20 78 add %o0, 0x78, %o1 ! 78 <.*>
|
|
+1060: d0 5d c0 09 ldx \[ %l7 \+ %o1 \], %o0
|
|
+1064: 90 01 c0 08 add %g7, %o0, %o0
|
|
+1068: 01 00 00 00 nop *
|
|
+106c: 01 00 00 00 nop *
|
|
+1070: 01 00 00 00 nop *
|
|
+1074: 01 00 00 00 nop *
|
|
+1078: 01 00 00 00 nop *
|
|
+107c: 19 00 00 00 sethi %hi\(0\), %o4
|
|
+1080: 98 03 20 08 add %o4, 8, %o4 ! 8 <.*>
|
|
+1084: 90 05 c0 0c add %l7, %o4, %o0
|
|
+1088: 40 04 04 be call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+108c: 01 00 00 00 nop *
|
|
+1090: 01 00 00 00 nop *
|
|
+1094: 01 00 00 00 nop *
|
|
+1098: 01 00 00 00 nop *
|
|
+109c: 01 00 00 00 nop *
|
|
+10a0: 11 00 00 00 sethi %hi\(0\), %o0
|
|
+10a4: 90 02 20 18 add %o0, 0x18, %o0 ! 18 <.*>
|
|
+10a8: d0 5d c0 08 ldx \[ %l7 \+ %o0 \], %o0
|
|
+10ac: 90 01 c0 08 add %g7, %o0, %o0
|
|
+10b0: 01 00 00 00 nop *
|
|
+10b4: 01 00 00 00 nop *
|
|
+10b8: 01 00 00 00 nop *
|
|
+10bc: 01 00 00 00 nop *
|
|
+10c0: 01 00 00 00 nop *
|
|
+10c4: 19 00 00 00 sethi %hi\(0\), %o4
|
|
+10c8: 98 03 20 80 add %o4, 0x80, %o4 ! 80 <.*>
|
|
+10cc: 90 05 c0 0c add %l7, %o4, %o0
|
|
+10d0: 40 04 04 ac call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+10d4: 01 00 00 00 nop *
|
|
+10d8: 01 00 00 00 nop *
|
|
+10dc: 01 00 00 00 nop *
|
|
+10e0: 01 00 00 00 nop *
|
|
+10e4: 01 00 00 00 nop *
|
|
+10e8: 11 00 00 00 sethi %hi\(0\), %o0
|
|
+10ec: 90 02 20 90 add %o0, 0x90, %o0 ! 90 <.*>
|
|
+10f0: d0 5d c0 08 ldx \[ %l7 \+ %o0 \], %o0
|
|
+10f4: 90 01 c0 08 add %g7, %o0, %o0
|
|
+10f8: 01 00 00 00 nop *
|
|
+10fc: 01 00 00 00 nop *
|
|
+1100: 01 00 00 00 nop *
|
|
+1104: 01 00 00 00 nop *
|
|
+1108: 01 00 00 00 nop *
|
|
+110c: 19 00 00 00 sethi %hi\(0\), %o4
|
|
+1110: 98 03 20 38 add %o4, 0x38, %o4 ! 38 <.*>
|
|
+1114: 90 05 c0 0c add %l7, %o4, %o0
|
|
+1118: 40 04 04 9a call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+111c: 01 00 00 00 nop *
|
|
+1120: 01 00 00 00 nop *
|
|
+1124: 01 00 00 00 nop *
|
|
+1128: 01 00 00 00 nop *
|
|
+112c: 01 00 00 00 nop *
|
|
+1130: 11 00 00 00 sethi %hi\(0\), %o0
|
|
+1134: 90 02 20 48 add %o0, 0x48, %o0 ! 48 <.*>
|
|
+1138: d0 5d c0 08 ldx \[ %l7 \+ %o0 \], %o0
|
|
+113c: 90 01 c0 08 add %g7, %o0, %o0
|
|
+1140: 01 00 00 00 nop *
|
|
+1144: 01 00 00 00 nop *
|
|
+1148: 01 00 00 00 nop *
|
|
+114c: 01 00 00 00 nop *
|
|
+1150: 01 00 00 00 nop *
|
|
+1154: 23 00 00 00 sethi %hi\(0\), %l1
|
|
+1158: 01 00 00 00 nop *
|
|
+115c: a4 04 60 28 add %l1, 0x28, %l2
|
|
+1160: 01 00 00 00 nop *
|
|
+1164: 90 05 c0 12 add %l7, %l2, %o0
|
|
+1168: 01 00 00 00 nop *
|
|
+116c: 40 04 04 85 call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+1170: 01 00 00 00 nop *
|
|
+1174: 27 00 00 00 sethi %hi\(0\), %l3
|
|
+1178: 01 00 00 00 nop *
|
|
+117c: a8 1c e0 20 xor %l3, 0x20, %l4
|
|
+1180: 01 00 00 00 nop *
|
|
+1184: aa 02 00 14 add %o0, %l4, %l5
|
|
+1188: 01 00 00 00 nop *
|
|
+118c: 25 00 00 00 sethi %hi\(0\), %l2
|
|
+1190: 01 00 00 00 nop *
|
|
+1194: a6 1c a0 26 xor %l2, 0x26, %l3
|
|
+1198: 01 00 00 00 nop *
|
|
+119c: ec 12 00 13 lduh \[ %o0 \+ %l3 \], %l6
|
|
+11a0: 01 00 00 00 nop *
|
|
+11a4: 01 00 00 00 nop *
|
|
+11a8: 01 00 00 00 nop *
|
|
+11ac: 01 00 00 00 nop *
|
|
+11b0: 13 00 00 00 sethi %hi\(0\), %o1
|
|
+11b4: 27 00 00 00 sethi %hi\(0\), %l3
|
|
+11b8: 94 02 60 28 add %o1, 0x28, %o2
|
|
+11bc: 25 00 00 00 sethi %hi\(0\), %l2
|
|
+11c0: 90 05 c0 0a add %l7, %o2, %o0
|
|
+11c4: a8 1c e0 40 xor %l3, 0x40, %l4
|
|
+11c8: 40 04 04 6e call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+11cc: a6 1c a0 45 xor %l2, 0x45, %l3
|
|
+11d0: ea 5a 00 14 ldx \[ %o0 \+ %l4 \], %l5
|
|
+11d4: ac 02 00 13 add %o0, %l3, %l6
|
|
+11d8: 01 00 00 00 nop *
|
|
+11dc: 01 00 00 00 nop *
|
|
+11e0: 01 00 00 00 nop *
|
|
+11e4: 01 00 00 00 nop *
|
|
+11e8: 13 00 00 00 sethi %hi\(0\), %o1
|
|
+11ec: 27 00 00 00 sethi %hi\(0\), %l3
|
|
+11f0: 94 02 60 28 add %o1, 0x28, %o2
|
|
+11f4: 25 00 00 00 sethi %hi\(0\), %l2
|
|
+11f8: 90 05 c0 0a add %l7, %o2, %o0
|
|
+11fc: a8 1c e0 63 xor %l3, 0x63, %l4
|
|
+1200: 40 04 04 60 call [0-9a-f]+ <__tls_get_addr@plt>
|
|
+1204: a6 1c a0 64 xor %l2, 0x64, %l3
|
|
+1208: aa 02 00 14 add %o0, %l4, %l5
|
|
+120c: ec 02 00 13 ld \[ %o0 \+ %l3 \], %l6
|
|
+1210: 01 00 00 00 nop *
|
|
+1214: 01 00 00 00 nop *
|
|
+1218: 01 00 00 00 nop *
|
|
+121c: 01 00 00 00 nop *
|
|
+1220: 23 00 00 00 sethi %hi\(0\), %l1
|
|
+1224: 01 00 00 00 nop *
|
|
+1228: a4 04 60 78 add %l1, 0x78, %l2
|
|
+122c: 01 00 00 00 nop *
|
|
+1230: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
|
|
+1234: 01 00 00 00 nop *
|
|
+1238: a4 01 c0 12 add %g7, %l2, %l2
|
|
+123c: 01 00 00 00 nop *
|
|
+1240: 01 00 00 00 nop *
|
|
+1244: 01 00 00 00 nop *
|
|
+1248: 01 00 00 00 nop *
|
|
+124c: 17 00 00 00 sethi %hi\(0\), %o3
|
|
+1250: 96 02 e0 18 add %o3, 0x18, %o3 ! 18 <.*>
|
|
+1254: d4 5d c0 0b ldx \[ %l7 \+ %o3 \], %o2
|
|
+1258: 98 01 c0 0a add %g7, %o2, %o4
|
|
+125c: 01 00 00 00 nop *
|
|
+1260: 01 00 00 00 nop *
|
|
+1264: 01 00 00 00 nop *
|
|
+1268: 01 00 00 00 nop *
|
|
+126c: 23 00 00 00 sethi %hi\(0\), %l1
|
|
+1270: a4 04 60 90 add %l1, 0x90, %l2 ! 90 <.*>
|
|
+1274: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
|
|
+1278: a4 01 c0 12 add %g7, %l2, %l2
|
|
+127c: 01 00 00 00 nop *
|
|
+1280: 01 00 00 00 nop *
|
|
+1284: 01 00 00 00 nop *
|
|
+1288: 01 00 00 00 nop *
|
|
+128c: 23 00 00 00 sethi %hi\(0\), %l1
|
|
+1290: a4 04 60 48 add %l1, 0x48, %l2 ! 48 <.*>
|
|
+1294: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
|
|
+1298: a4 01 c0 12 add %g7, %l2, %l2
|
|
+129c: 01 00 00 00 nop *
|
|
+12a0: 01 00 00 00 nop *
|
|
+12a4: 01 00 00 00 nop *
|
|
+12a8: 01 00 00 00 nop *
|
|
+12ac: 23 00 00 00 sethi %hi\(0\), %l1
|
|
+12b0: a4 04 60 50 add %l1, 0x50, %l2 ! 50 <.*>
|
|
+12b4: e4 5d c0 12 ldx \[ %l7 \+ %l2 \], %l2
|
|
+12b8: e4 59 c0 12 ldx \[ %g7 \+ %l2 \], %l2
|
|
+12bc: 01 00 00 00 nop *
|
|
+12c0: 01 00 00 00 nop *
|
|
+12c4: 01 00 00 00 nop *
|
|
+12c8: 01 00 00 00 nop *
|
|
+12cc: 17 00 00 00 sethi %hi\(0\), %o3
|
|
+12d0: 98 02 e0 20 add %o3, 0x20, %o4 ! 20 <.*>
|
|
+12d4: da 5d c0 0c ldx \[ %l7 \+ %o4 \], %o5
|
|
+12d8: e4 29 c0 0d stb %l2, \[ %g7 \+ %o5 \]
|
|
+12dc: 01 00 00 00 nop *
|
|
+12e0: 01 00 00 00 nop *
|
|
+12e4: 01 00 00 00 nop *
|
|
+12e8: 01 00 00 00 nop *
|
|
+12ec: 17 00 00 00 sethi %hi\(0\), %o3
|
|
+12f0: 98 02 e0 68 add %o3, 0x68, %o4 ! 68 <.*>
|
|
+12f4: da 5d c0 0c ldx \[ %l7 \+ %o4 \], %o5
|
|
+12f8: e4 71 c0 0d stx %l2, \[ %g7 \+ %o5 \]
|
|
+12fc: 01 00 00 00 nop *
|
|
+1300: 01 00 00 00 nop *
|
|
+1304: 01 00 00 00 nop *
|
|
+1308: 01 00 00 00 nop *
|
|
+130c: 17 00 00 00 sethi %hi\(0\), %o3
|
|
+1310: 98 02 e0 70 add %o3, 0x70, %o4 ! 70 <.*>
|
|
+1314: da 5d c0 0c ldx \[ %l7 \+ %o4 \], %o5
|
|
+1318: e4 21 c0 0d st %l2, \[ %g7 \+ %o5 \]
|
|
+131c: 01 00 00 00 nop *
|
|
+1320: 01 00 00 00 nop *
|
|
+1324: 01 00 00 00 nop *
|
|
+1328: 01 00 00 00 nop *
|
|
+132c: 81 cf e0 08 rett %i7 \+ 8
|
|
+1330: 01 00 00 00 nop *
|
|
#pass
|