Skip to content

Commit 3a53193

Browse files
author
Jing Yu
committed
Add tls support to gold aarch64 backend.
elfcpp/ChangeLog: 2014-09-17 Han Shen <shenhan@google.com> * aarch64.h (R_AARCH64_TLS_DTPREL64): Switch enum value with ... (R_AARCH64_TLS_DTPMOD64): ... enum value. gold/ChangeLog: 2014-09-17 Han Shen <shenhan@google.com> Jing Yu <jingyu@google.com> * aarch64-reloc.def: Add TLSGD_ADR_PAGE21, TLSGD_ADD_LO12_NC, TLSDESC_ADR_PAGE21, TLSDESC_LD64_LO12, TLSDESC_ADD_LO12, TLSDESC_CALL. * aarch64.cc (Target_aarch64): Add data members got_irelative_, got_tlsdesc_, rela_irelative_, got_mod_index_offset_, tlsdesc_reloc_info_, tls_base_symbol_defined_. Initialize them in constructor. (Target_aarch64::do_reloc_symbol_index): New method. (Target_aarch64::do_reloc_addend): New method. (Target_aarch64::add_tlsdesc_info): New method. (Target_aarch64::do_dynsym_value): New method. (Target_aarch64::do_make_data_plt): Add new parameters: got, got_irelative. Pass them to Output_data_plt_aarch64_standard. (Target_aarch64::make_data_plt): Add new parameters: got, got_irelative. Pass them to do_make_data_plt. (Target_aarch64::Relocate): Add skip_call_tls_get_addr_ variable. (Target_aarch64::Relocate:tls_gd_to_le): New method. (Target_aarch64::Relocate:tls_ie_to_le): New method. (Target_aarch64::Relocate:tls_desc_gd_to_le): New method. (Target_aarch64::Relocate:tls_desc_gd_to_ie): New method. (Target_aarch64::got_tlsdesc_section): New method. (Target_aarch64::make_local_ifunc_plt_entry): New method. (Target_aarch64::define_tls_base_symbol): New method. (Target_aarch64::reserve_tlsdesc_entries): New method. (Target_aarch64::got_mod_index_entry): New method. (Target_aarch64::rela_tlsdesc_section): New method. (Target_aarch64::rela_irelative_section): New method. (Target_aarch64::Tlsdesc_info): New struct. (Target_aarch64::got_section): Create .got.plt space for IRELATIVE relocations and tlsdesc relocations. (Target_aarch64::optimize_tls_reloc): Implement method. (Output_data_plt_aarch64): Add member variables: tlsdesc_rel_, got_, got_irelative_, irelative_count_, tlsdesc_got_offset_. Initialize them in constructor. (Output_data_plt_aarch64::reserve_tlsdesc_entry): New method. (Output_data_plt_aarch64::has_tlsdesc_entry): New method. (Output_data_plt_aarch64::get_tlsdesc_got_offset): New method. (Output_data_plt_aarch64::get_tlsdesc_plt_offset): New method. (Output_data_plt_aarch64::rela_tlsdesc): New method. (Output_data_plt_aarch64::rela_irelative): New method. (Output_data_plt_aarch64::entry_count): Count IRELATIVE relocations. (Output_data_plt_aarch64::first_plt_entry_offset): Add const attribute. (Output_data_plt_aarch64::get_plt_tlsdesc_entry_size): New method. (Output_data_plt_aarch64::fill_tlsdesc_entry): New method. (Output_data_plt_aarch64::do_get_plt_tlsdesc_entry_size): New method. (Output_data_plt_aarch64::do_fill_tlsdesc_entry): New method. (Output_data_plt_aarch64_standard): New member variables: plt_tlsdesc_entry_size, tlsdesc_plt_entry. (Output_data_plt_aarch64_standard::Output_data_plt_aarch64_standard): New parameter: got, got_irelative. (Output_data_plt_aarch64_standard::do_get_plt_entry_size): New method. (Output_data_plt_aarch64_standard::do_fill_tlsdesc_entry): New method. (Output_data_plt_aarch64::do_write): Replace got_address with gotplt_address. Add irelative_count_ to count. Write tlsdesc entry. (AArch64_relocate_functions::update_movnz): New method. (AArch64_relocate_functions): Correct format. (AArch64_relocate_functions::movnz): New method. (Target_aarch64::Scan::local): Correct format. Move r_sym, got to before the switch. Add new cases to switch. Check ie_to_le relaxation on tlsie relocations. Add code handling tlsgd tlsdesc cases. (Target_aarch64::Scan::global): Move arp to front. Do copy_reloc when needed. Add new cases to switch. Insert dynamic RELATIVE relocation when needed. Add code handling tlsgd, tlsie, tlsdesc cases. Call reloc_name_in_error_message to print unsupported reloc. (Target_aarch64::make_plt_section): Pass got_ and got_irelative_ to make_data_plt. (Target_aarch64::do_finalize_sections): Emit relocs to save COPY relocs. Fill in some more dynamic tags. (Target_aarch64::Relocate::relocate): Handle tlsgd, tlsdesc relocs. Skip call tls_get_addr when tlsgd is relaxed. (Target_aarch64::Relocate::relocate_tls): Correct format. Add code handling tlsgd, tlsdesc relocs, and tls gd->le, ie->le, tlsdesc->le, tlsdesc->ie relaxation.
1 parent 5e43d46 commit 3a53193

5 files changed

Lines changed: 1600 additions & 155 deletions

File tree

‎elfcpp/ChangeLog‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2014-09-17 Han Shen <shenhan@google.com>
2+
3+
* aarch64.h (R_AARCH64_TLS_DTPREL64): Switch enum value with ...
4+
(R_AARCH64_TLS_DTPMOD64): ... enum value.
5+
16
2014-09-15 Andrew Bennett <andrew.bennett@imgtec.com>
27
Matthew Fortune <matthew.fortune@imgtec.com>
38

‎elfcpp/aarch64.h‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,12 @@ enum
171171
R_AARCH64_GLOB_DAT = 1025, // S + A
172172
R_AARCH64_JUMP_SLOT = 1026, // S + A
173173
R_AARCH64_RELATIVE = 1027, // Delta(S) + A
174-
R_AARCH64_TLS_DTPREL64 = 1028, // DTPREL(S+A)
175-
R_AARCH64_TLS_DTPMOD64 = 1029, // LDM(S)
174+
// Note (shenhan): the following 2 relocs are different from elf spec from
175+
// arm. In elf docs, TLS_DTPMOD64 is defined as 1029, TLS_DTPREL64 1028.
176+
// While actually the bfd linker (and the dynamic linker) treates TLS_DTPMOD64
177+
// as 1028, TLS_DTPREL64 1029. See binutils-gdb/include/elf/aarch64.h.
178+
R_AARCH64_TLS_DTPMOD64 = 1028, // LDM(S)
179+
R_AARCH64_TLS_DTPREL64 = 1029, // DTPREL(S+A)
176180
R_AARCH64_TLS_TPREL64 = 1030, // TPREL(S+A)
177181
R_AARCH64_TLSDESC = 1031, // TLSDESC(S+A)
178182
R_AARCH64_IRELATIVE = 1032, // Indirect(Delta(S) + A)

‎gold/ChangeLog‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,80 @@
1+
2014-09-17 Han Shen <shenhan@google.com>
2+
Jing Yu <jingyu@google.com>
3+
4+
* aarch64-reloc.def: Add TLSGD_ADR_PAGE21, TLSGD_ADD_LO12_NC,
5+
TLSDESC_ADR_PAGE21, TLSDESC_LD64_LO12, TLSDESC_ADD_LO12, TLSDESC_CALL.
6+
* aarch64.cc (Target_aarch64): Add data members
7+
got_irelative_, got_tlsdesc_, rela_irelative_, got_mod_index_offset_,
8+
tlsdesc_reloc_info_, tls_base_symbol_defined_. Initialize them in
9+
constructor.
10+
(Target_aarch64::do_reloc_symbol_index): New method.
11+
(Target_aarch64::do_reloc_addend): New method.
12+
(Target_aarch64::add_tlsdesc_info): New method.
13+
(Target_aarch64::do_dynsym_value): New method.
14+
(Target_aarch64::do_make_data_plt): Add new parameters: got,
15+
got_irelative. Pass them to Output_data_plt_aarch64_standard.
16+
(Target_aarch64::make_data_plt): Add new parameters: got,
17+
got_irelative. Pass them to do_make_data_plt.
18+
(Target_aarch64::Relocate): Add skip_call_tls_get_addr_ variable.
19+
(Target_aarch64::Relocate:tls_gd_to_le): New method.
20+
(Target_aarch64::Relocate:tls_ie_to_le): New method.
21+
(Target_aarch64::Relocate:tls_desc_gd_to_le): New method.
22+
(Target_aarch64::Relocate:tls_desc_gd_to_ie): New method.
23+
(Target_aarch64::got_tlsdesc_section): New method.
24+
(Target_aarch64::make_local_ifunc_plt_entry): New method.
25+
(Target_aarch64::define_tls_base_symbol): New method.
26+
(Target_aarch64::reserve_tlsdesc_entries): New method.
27+
(Target_aarch64::got_mod_index_entry): New method.
28+
(Target_aarch64::rela_tlsdesc_section): New method.
29+
(Target_aarch64::rela_irelative_section): New method.
30+
(Target_aarch64::Tlsdesc_info): New struct.
31+
(Target_aarch64::got_section): Create .got.plt space for IRELATIVE
32+
relocations and tlsdesc relocations.
33+
(Target_aarch64::optimize_tls_reloc): Implement method.
34+
(Output_data_plt_aarch64): Add member variables: tlsdesc_rel_, got_,
35+
got_irelative_, irelative_count_, tlsdesc_got_offset_. Initialize them
36+
in constructor.
37+
(Output_data_plt_aarch64::reserve_tlsdesc_entry): New method.
38+
(Output_data_plt_aarch64::has_tlsdesc_entry): New method.
39+
(Output_data_plt_aarch64::get_tlsdesc_got_offset): New method.
40+
(Output_data_plt_aarch64::get_tlsdesc_plt_offset): New method.
41+
(Output_data_plt_aarch64::rela_tlsdesc): New method.
42+
(Output_data_plt_aarch64::rela_irelative): New method.
43+
(Output_data_plt_aarch64::entry_count): Count IRELATIVE relocations.
44+
(Output_data_plt_aarch64::first_plt_entry_offset): Add const attribute.
45+
(Output_data_plt_aarch64::get_plt_tlsdesc_entry_size): New method.
46+
(Output_data_plt_aarch64::fill_tlsdesc_entry): New method.
47+
(Output_data_plt_aarch64::do_get_plt_tlsdesc_entry_size): New method.
48+
(Output_data_plt_aarch64::do_fill_tlsdesc_entry): New method.
49+
(Output_data_plt_aarch64_standard): New member variables:
50+
plt_tlsdesc_entry_size, tlsdesc_plt_entry.
51+
(Output_data_plt_aarch64_standard::Output_data_plt_aarch64_standard):
52+
New parameter: got, got_irelative.
53+
(Output_data_plt_aarch64_standard::do_get_plt_entry_size): New method.
54+
(Output_data_plt_aarch64_standard::do_fill_tlsdesc_entry): New method.
55+
(Output_data_plt_aarch64::do_write): Replace got_address with
56+
gotplt_address. Add irelative_count_ to count. Write tlsdesc entry.
57+
(AArch64_relocate_functions::update_movnz): New method.
58+
(AArch64_relocate_functions): Correct format.
59+
(AArch64_relocate_functions::movnz): New method.
60+
(Target_aarch64::Scan::local): Correct format. Move r_sym, got to
61+
before the switch. Add new cases to switch.
62+
Check ie_to_le relaxation on tlsie relocations. Add code handling
63+
tlsgd tlsdesc cases.
64+
(Target_aarch64::Scan::global): Move arp to front. Do copy_reloc when
65+
needed. Add new cases to switch. Insert dynamic RELATIVE relocation
66+
when needed. Add code handling tlsgd, tlsie, tlsdesc cases.
67+
Call reloc_name_in_error_message to print unsupported reloc.
68+
(Target_aarch64::make_plt_section): Pass got_ and got_irelative_ to
69+
make_data_plt.
70+
(Target_aarch64::do_finalize_sections): Emit relocs to save COPY
71+
relocs. Fill in some more dynamic tags.
72+
(Target_aarch64::Relocate::relocate): Handle tlsgd, tlsdesc relocs.
73+
Skip call tls_get_addr when tlsgd is relaxed.
74+
(Target_aarch64::Relocate::relocate_tls): Correct format. Add code
75+
handling tlsgd, tlsdesc relocs, and tls gd->le, ie->le, tlsdesc->le,
76+
tlsdesc->ie relaxation.
77+
178
2014-09-03 Sasa Stankovic <Sasa.Stankovic@imgtec.com>
279

380
* mips.cc (Target_mips_nacl): New class.

‎gold/aarch64-reloc.def‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ ARD(JUMP26 , STATIC , CFLOW , Y, -1, 27,27
5757
// Above is from Table 4-10, Relocations for control-flow instructions,
5858
// 279-283.
5959

60+
ARD(TLSGD_ADR_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::ABSOLUTE_REF , ADRP )
61+
ARD(TLSGD_ADD_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD )
62+
6063
ARD(TLSIE_MOVW_GOTTPREL_G1 , STATIC , AARCH64 , N, -1, 0,0 , 16,31 , Symbol::ABSOLUTE_REF , MOVW )
6164
ARD(TLSIE_MOVW_GOTTPREL_G0_NC , STATIC , AARCH64 , N, -1, 0,0 , 0,15 , Symbol::ABSOLUTE_REF , MOVW )
6265
ARD(TLSIE_ADR_GOTTPREL_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::ABSOLUTE_REF , ADRP )
@@ -69,6 +72,12 @@ ARD(TLSLE_ADD_TPREL_LO12 , STATIC , AARCH64 , Y, -1, 0,12
6972
ARD(TLSLE_ADD_TPREL_LO12_NC , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD )
7073
// Above is from Table 4-18, Local Exec TLS relocations, 544-571.
7174

75+
ARD(TLSDESC_ADR_PAGE21 , STATIC , AARCH64 , Y, -1, 32,32 , 12,32 , Symbol::RELATIVE_REF , ADRP )
76+
ARD(TLSDESC_LD64_LO12 , STATIC , AARCH64 , Y, -1, 0,RL_CHECK_ALIGN8 , 3,11 , Symbol::ABSOLUTE_REF , LDST )
77+
ARD(TLSDESC_ADD_LO12 , STATIC , AARCH64 , Y, -1, 0,0 , 0,11 , Symbol::ABSOLUTE_REF , ADD )
78+
ARD(TLSDESC_CALL , STATIC , CFLOW , Y, -1, 0,0 , 0,0 , (Symbol::FUNCTION_CALL|Symbol::ABSOLUTE_REF) , CALL )
79+
// Above is from Table 4-19, TLS descriptor relocations, 560-569.
80+
7281
// Note -
7382
// A - Checking X, (L,U), if L == 0 && U == 0, no check. Otherwise, L!=0,
7483
// check that -2^L<=X<2^U. Also an extra alignment check could be embeded

0 commit comments

Comments
 (0)