From a12fad50d28b9251893c6709ac4374773350c21a Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Tue, 11 Aug 2015 17:15:56 +0100 Subject: [PATCH] [AArch64][5/8] GAS support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC 2015-08-11 Jiong Wang bfd/ * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC): New entry. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC. gas/ * config/tc-aarch64.c (reloc_table): New relocation modifiers. (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC. (aarch64_force_relocation): Likewise. gas/testsuite/ * gas/aarch64/reloc-tlsldm_lo12_nc-1.s: New testcase. * gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s: Likewise. * gas/aarch64/reloc-tlsldm_lo12_nc-1.d: New expectation file. * gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d: Likewise. --- bfd/ChangeLog | 8 ++++++++ bfd/bfd-in2.h | 5 +++++ bfd/elfnn-aarch64.c | 15 +++++++++++++++ bfd/libbfd.h | 1 + bfd/reloc.c | 6 ++++++ gas/ChangeLog | 6 ++++++ gas/config/tc-aarch64.c | 11 +++++++++++ gas/testsuite/ChangeLog | 7 +++++++ .../gas/aarch64/reloc-tlsldm_lo12_nc-1.d | 10 ++++++++++ .../gas/aarch64/reloc-tlsldm_lo12_nc-1.s | 5 +++++ .../gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d | 11 +++++++++++ .../gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s | 5 +++++ 12 files changed, 90 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.d create mode 100644 gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.s create mode 100644 gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d create mode 100644 gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 01a29c8422..6e12da30ef 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2015-08-11 Jiong Wang + + * reloc.c (BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC): New entry. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for + BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC. + 2015-08-11 Jiong Wang * elfnn-aarch64.c (IS_AARCH64_TLS_RELOC): Recognize diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 43e1324cce..350b9551a4 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -5794,6 +5794,11 @@ BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21. */ /* AArch64 TLS INITIAL EXEC relocation. */ BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19, +/* Unsigned 12 bit byte offset to global offset table entry for a symbols +tls_index structure. Used in conjunction with +BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. */ + BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC, + /* GOT entry page address for AArch64 TLS Local Dynamic, used with ADRP instruction. */ BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21, diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index ff56701614..12c1220fb9 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -1026,6 +1026,21 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0x1ffffc, /* dst_mask */ FALSE), /* pcrel_offset */ + /* ADD: GOT offset G(S) & 0xff8 [no overflow check] */ + HOWTO (AARCH64_R (TLSLD_ADD_LO12_NC), /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 12, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + AARCH64_R_STR (TLSLD_ADD_LO12_NC), /* name */ + FALSE, /* partial_inplace */ + 0xfff, /* src_mask */ + 0xfff, /* dst_mask */ + FALSE), /* pcrel_offset */ + /* Get to the page for the GOT entry for the symbol (G(S) - P) using an ADRP instruction. */ HOWTO (AARCH64_R (TLSLD_ADR_PAGE21), /* type */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 03e9393cfe..d6ed8fda89 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -2759,6 +2759,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC", "BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC", "BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19", + "BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC", "BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21", "BFD_RELOC_AARCH64_TLSLD_ADR_PREL21", "BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2", diff --git a/bfd/reloc.c b/bfd/reloc.c index d6252c8506..df22f9bf28 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -6843,6 +6843,12 @@ ENUM BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19 ENUMDOC AArch64 TLS INITIAL EXEC relocation. +ENUM + BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC +ENUMDOC + Unsigned 12 bit byte offset to global offset table entry for a symbols + tls_index structure. Used in conjunction with + BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21. ENUM BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21 ENUMDOC diff --git a/gas/ChangeLog b/gas/ChangeLog index a97108a5f2..314735a527 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2015-08-11 Jiong Wang + + * config/tc-aarch64.c (reloc_table): New relocation modifiers. + (md_apply_fix): Support BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC. + (aarch64_force_relocation): Likewise. + 2015-08-11 Jiong Wang * config/tc-aarch64.c (reloc_table): New relocation modifiers. diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index c01ec6dbd0..a633b04fd8 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2513,6 +2513,15 @@ static struct reloc_table_entry reloc_table[] = { 0, 0}, + /* 12 bit offset into the page containing GOT TLS entry for a symbol */ + {"tlsldm_lo12_nc", 0, + 0, /* adr_type */ + 0, + 0, + BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC, + 0, + 0}, + /* Get to the page containing GOT TLS entry for a symbol */ {"gottprel", 0, 0, /* adr_type */ @@ -6778,6 +6787,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC: case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19: + case BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC: case BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12: @@ -6989,6 +6999,7 @@ aarch64_force_relocation (struct fix *fixp) case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC: case BFD_RELOC_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: case BFD_RELOC_AARCH64_TLSIE_LD_GOTTPREL_PREL19: + case BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC: case BFD_RELOC_AARCH64_TLSLD_ADR_PAGE21: case BFD_RELOC_AARCH64_TLSLD_ADR_PREL21: case BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_HI12: diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index b790d4a8ad..9449f1d4ed 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2015-08-11 Jiong Wang + + * gas/aarch64/reloc-tlsldm_lo12_nc-1.s: New testcase. + * gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s: Likewise. + * gas/aarch64/reloc-tlsldm_lo12_nc-1.d: New expectation file. + * gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d: Likewise. + 2015-08-11 Jiong Wang * gas/aarch64/reloc-tlsldm-page-1.s: New testcase. diff --git a/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.d b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.d new file mode 100644 index 0000000000..905403686d --- /dev/null +++ b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.d @@ -0,0 +1,10 @@ +#objdump: -dr + +.*: file format .* + +Disassembly of section \.text: + +0000000000000000 <.*>: + 0: 91000000 add x0, x0, #0x0 + 0: R_AARCH64_TLSLD_ADD_LO12_NC x + diff --git a/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.s b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.s new file mode 100644 index 0000000000..676bbfc62e --- /dev/null +++ b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-1.s @@ -0,0 +1,5 @@ +// Test file for AArch64 GAS -- reloc 519 + +func: + // BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC + add x0, x0, #:tlsldm_lo12_nc:x diff --git a/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d new file mode 100644 index 0000000000..f068cfb85b --- /dev/null +++ b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.d @@ -0,0 +1,11 @@ +#as: -mabi=ilp32 +#objdump: -dr + +.*: file format .* + +Disassembly of section \.text: + +00000000 <.*>: + 0: 91000000 add x0, x0, #0x0 + 0: R_AARCH64_P32_TLSLD_ADD_LO12_NC x + diff --git a/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s new file mode 100644 index 0000000000..2556276bc0 --- /dev/null +++ b/gas/testsuite/gas/aarch64/reloc-tlsldm_lo12_nc-ilp32-1.s @@ -0,0 +1,5 @@ +// Test file for AArch64 GAS -- reloc 85 + +func: + // BFD_RELOC_AARCH64_TLSLD_ADD_LO12_NC + add x0, x0, #:tlsldm_lo12_nc:x -- 2.34.1