From 654248e7f702887c5a43bf402cd6080734f57819 Mon Sep 17 00:00:00 2001 From: Renlin Li Date: Fri, 2 Oct 2015 15:18:51 +0100 Subject: [PATCH] [GAS][AARCH64]Add BFD_RELOC_AARCH64_MOVW_GOTOFF_G1 Support. bfd/ 2015-10-02 Renlin Li * reloc.c (BFD_RELOC_AARCH64_MOVW_GOTOFF_G1): New. * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for MOVW_GOTOFF_G1. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. gas/ 2015-10-02 Renlin Li * config/tc-aarch64.c (reloc_table): New relocation modifier gotoff_g1. (process_movw_reloc_info): Support newly added modifier. (md_apply_fix): Likewise. gas/testsuite/ 2015-10-02 Renlin Li * gas/aarch64/reloc-gotoff_g1.s: New. * gas/aarch64/reloc-gotoff_g1.d: New. --- bfd/ChangeLog | 8 ++++++++ bfd/bfd-in2.h | 4 ++++ bfd/elfnn-aarch64.c | 15 +++++++++++++++ bfd/libbfd.h | 1 + bfd/reloc.c | 5 +++++ gas/ChangeLog | 7 +++++++ gas/config/tc-aarch64.c | 12 ++++++++++++ gas/testsuite/ChangeLog | 5 +++++ gas/testsuite/gas/aarch64/reloc-gotoff_g1.d | 9 +++++++++ gas/testsuite/gas/aarch64/reloc-gotoff_g1.s | 5 +++++ 10 files changed, 71 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/reloc-gotoff_g1.d create mode 100644 gas/testsuite/gas/aarch64/reloc-gotoff_g1.s diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 1413d10491..c3b0cc9414 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2015-010-02 Renlin Li + + * reloc.c (BFD_RELOC_AARCH64_MOVW_GOTOFF_G1): New. + * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for + MOVW_GOTOFF_G1. + * libbfd.h: Regenerate. + * bfd-in2.h: Regenerate. + 2015-10-02 Renlin Li * elfnn-aarch64.c (aarch64_reloc_got_type): Add diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 0d096f9034..9c4b34927e 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -5754,6 +5754,10 @@ the GOT entry for this symbol. Used in conjunction with BFD_RELOC_AARCH64_ADR_GOTPAGE. Valid in ILP32 ABI only. */ BFD_RELOC_AARCH64_LD32_GOT_LO12_NC, +/* Unsigned 16 bit byte higher offset for 64 bit load/store from the GOT entry +for this symbol. Valid in LP64 ABI only. */ + BFD_RELOC_AARCH64_MOVW_GOTOFF_G1, + /* Unsigned 15 bit byte offset for 64 bit load/store from the page of the GOT entry for this symbol. Valid in LP64 ABI only. */ BFD_RELOC_AARCH64_LD64_GOTOFF_LO15, diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index adef278071..7349ad7b0f 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -884,6 +884,21 @@ static reloc_howto_type elfNN_aarch64_howto_table[] = 0xffc, /* dst_mask */ FALSE), /* pcrel_offset */ + /* Higher 16 bits of GOT offset for the symbol. */ + HOWTO64 (AARCH64_R (MOVW_GOTOFF_G1), /* type */ + 16, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + AARCH64_R_STR (MOVW_GOTOFF_G1), /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + /* LD64: GOT offset for the symbol. */ HOWTO64 (AARCH64_R (LD64_GOTOFF_LO15), /* type */ 3, /* rightshift */ diff --git a/bfd/libbfd.h b/bfd/libbfd.h index fc70e2920e..ae5b2b06ee 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -2747,6 +2747,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_AARCH64_ADR_GOT_PAGE", "BFD_RELOC_AARCH64_LD64_GOT_LO12_NC", "BFD_RELOC_AARCH64_LD32_GOT_LO12_NC", + "BFD_RELOC_AARCH64_MOVW_GOTOFF_G1", "BFD_RELOC_AARCH64_LD64_GOTOFF_LO15", "BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14", "BFD_RELOC_AARCH64_LD64_GOTPAGE_LO15", diff --git a/bfd/reloc.c b/bfd/reloc.c index caa6fb4f17..750a612368 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -6789,6 +6789,11 @@ ENUMDOC Unsigned 12 bit byte offset for 32 bit load/store from the page of the GOT entry for this symbol. Used in conjunction with BFD_RELOC_AARCH64_ADR_GOTPAGE. Valid in ILP32 ABI only. +ENUM + BFD_RELOC_AARCH64_MOVW_GOTOFF_G1 +ENUMDOC + Unsigned 16 bit byte higher offset for 64 bit load/store from the GOT entry + for this symbol. Valid in LP64 ABI only. ENUM BFD_RELOC_AARCH64_LD64_GOTOFF_LO15 ENUMDOC diff --git a/gas/ChangeLog b/gas/ChangeLog index 5420973386..04928017a0 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2015-10-02 Renlin Li + + * config/tc-aarch64.c (reloc_table): New relocation modifier + gotoff_g1. + (process_movw_reloc_info): Support newly added modifier. + (md_apply_fix): Likewise. + 2015-09-29 Dominik Vogt * doc/c-s390.texi: Add documentation. diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index b97a090830..1b0e69b2f3 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2455,6 +2455,15 @@ static struct reloc_table_entry reloc_table[] = { BFD_RELOC_AARCH64_LD_GOT_LO12_NC, 0}, + /* Most significant bits 16-31 of address/value: MOVZ. */ + {"gotoff_g1", 0, + 0, /* adr_type */ + 0, + BFD_RELOC_AARCH64_MOVW_GOTOFF_G1, + 0, + 0, + 0}, + /* 15 bit offset into the page containing GOT entry for that symbol. */ {"gotoff_lo15", 0, 0, /* adr_type */ @@ -4676,6 +4685,7 @@ process_movw_reloc_info (void) case BFD_RELOC_AARCH64_MOVW_G1: case BFD_RELOC_AARCH64_MOVW_G1_NC: case BFD_RELOC_AARCH64_MOVW_G1_S: + case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1: case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1: case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G1_NC: case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1: @@ -6794,6 +6804,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) case BFD_RELOC_AARCH64_MOVW_G1: case BFD_RELOC_AARCH64_MOVW_G1_NC: case BFD_RELOC_AARCH64_MOVW_G1_S: + case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1: scale = 16; goto movw_common; case BFD_RELOC_AARCH64_MOVW_G2: @@ -6824,6 +6835,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg) case BFD_RELOC_AARCH64_MOVW_G1: case BFD_RELOC_AARCH64_MOVW_G2: case BFD_RELOC_AARCH64_MOVW_G3: + case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1: if (unsigned_overflow (value, scale + 16)) as_bad_where (fixP->fx_file, fixP->fx_line, _("unsigned value out of range")); diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index f4c2dad6ff..5f5e35c55d 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-02 Renlin Li + + * gas/aarch64/reloc-gotoff_g1.s: New. + * gas/aarch64/reloc-gotoff_g1.d: New. + 2015-09-30 Alan Modra * gas/ppc/ppc.exp (e500-ill): Pass -me500. diff --git a/gas/testsuite/gas/aarch64/reloc-gotoff_g1.d b/gas/testsuite/gas/aarch64/reloc-gotoff_g1.d new file mode 100644 index 0000000000..43e1ee4040 --- /dev/null +++ b/gas/testsuite/gas/aarch64/reloc-gotoff_g1.d @@ -0,0 +1,9 @@ +#objdump: -dr + +.*: file format .* + +Disassembly of section \.text: + +0000000000000000 <.*>: + 0: d2a0001c movz x28, #0x0, lsl #16 + 0: R_AARCH64_MOVW_GOTOFF_G1 x diff --git a/gas/testsuite/gas/aarch64/reloc-gotoff_g1.s b/gas/testsuite/gas/aarch64/reloc-gotoff_g1.s new file mode 100644 index 0000000000..f1036a14af --- /dev/null +++ b/gas/testsuite/gas/aarch64/reloc-gotoff_g1.s @@ -0,0 +1,5 @@ +// Test file for AArch64 GAS -- gotoff_g1 + +func: + // BFD_RELOC_AARCH64_MOVW_GOTOFF_G1 + movz x28, #:gotoff_g1:x -- 2.34.1