This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[5/16][binutils][AARCH64]Add relocation support for large memory model. [GAS]Add BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC Support


Hi all,

This patch add BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC support in Gas.


It's used in large memory model, GOT PIC addressing.
For the large model and -fPIC, the GOT is limited to 4GB, allowing it to be accessed using a 32-bit unsigned register index.


// gp = &_GOT_
movz    t0, #:gotoff_g1:src             // R_AARCH64_MOVW_GOTOFF_G1 src
movk    t0, #:gotoff_g0_nc:src       // R_AARCH64_MOVW_GOTOFF_G0_NC src
ldr     t0, [gp, t0]


GAS tests Okay without any issues. Okay to commit?

bfd/ChangeLog:

2015-09-08  Renlin Li <renlin.li@arm.com>

    * reloc.c (BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC): New.
    * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry
        MOVW_GOTOFF_G0_NC.
    * libbfd.h: Regnerate.
    * bfd-in2.h: Regenerate.

gas/ChangeLog:

2015-09-08  Renlin Li <renlin.li@arm.com>

    * config/tc-aarch64.c (reloc_table): New relocation modifier
        gotoff_g0_nc.
    (process_movw_reloc_info): Support gotoff_g0_nc.
    (md_apply_fix): Likewise.

gas/testsuite/ChangeLog:

2015-09-08  Renlin Li <renlin.li@arm.com>

    * gas/aarch64/reloc-gotoff_g0_nc.s: New.
    * gas/aarch64/reloc-gotoff_g0_nc.d: New.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 5c444c7..0c7cb7c 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -5752,6 +5752,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 offset for 64 bit load/store from the GOT entry
+for this symbol.  Valid in LP64 ABI only.  */
+  BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_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,
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 0ef417c..eef43d1 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -866,6 +866,21 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 0xffc,			/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
+  /* Lower 16 bits of GOT offset for the symbol.  */
+  HOWTO64 (AARCH64_R (MOVW_GOTOFF_G0_NC),	/* type */
+	 0,			/* rightshift */
+	 2,			/* size (0 = byte, 1 = short, 2 = long) */
+	 16,			/* bitsize */
+	 FALSE,			/* pc_relative */
+	 0,			/* bitpos */
+	 complain_overflow_dont,	/* complain_on_overflow */
+	 bfd_elf_generic_reloc,	/* special_function */
+	 AARCH64_R_STR (MOVW_GOTOFF_G0_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
   /* Higher 16 bits of GOT offset for the symbol.  */
   HOWTO64 (AARCH64_R (MOVW_GOTOFF_G1),	/* type */
 	 16,			/* rightshift */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 42476dd..0c6fab8 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_G0_NC",
   "BFD_RELOC_AARCH64_MOVW_GOTOFF_G1",
   "BFD_RELOC_AARCH64_LD64_GOTOFF_LO15",
   "BFD_RELOC_AARCH64_LD32_GOTPAGE_LO14",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index f85d95e..4a5d1b6 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_G0_NC
+ENUMDOC
+  Unsigned 16 bit byte offset for 64 bit load/store from the GOT entry
+  for this symbol.  Valid in LP64 ABI only.
 ENUM
   BFD_RELOC_AARCH64_MOVW_GOTOFF_G1
 ENUMDOC
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 9888f81..6c1ed63 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},
 
+  /* 0-15 bits of address/value: MOVk, no check.  */
+  {"gotoff_g0_nc", 0,
+   0,				/* adr_type */
+   0,
+   BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC,
+   0,
+   0,
+   0},
+
   /* Most significant bits 16-31 of address/value: MOVZ.  */
   {"gotoff_g1", 0,
    0,				/* adr_type */
@@ -4613,6 +4622,7 @@ process_movw_reloc_info (void)
     case BFD_RELOC_AARCH64_MOVW_G0:
     case BFD_RELOC_AARCH64_MOVW_G0_NC:
     case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
     case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
     case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
       shift = 0;
@@ -6699,6 +6709,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
     case BFD_RELOC_AARCH64_MOVW_G0:
     case BFD_RELOC_AARCH64_MOVW_G0_NC:
     case BFD_RELOC_AARCH64_MOVW_G0_S:
+    case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC:
       scale = 0;
       goto movw_common;
     case BFD_RELOC_AARCH64_MOVW_G1:
diff --git a/gas/testsuite/gas/aarch64/reloc-gotoff_g0_nc.d b/gas/testsuite/gas/aarch64/reloc-gotoff_g0_nc.d
new file mode 100644
index 0000000..4c0bc60
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/reloc-gotoff_g0_nc.d
@@ -0,0 +1,9 @@
+#objdump: -dr
+
+.*:     file format .*
+
+Disassembly of section \.text:
+
+0000000000000000 <.*>:
+   0:	f280001c 	movk	x28, #0x0
+			0: R_AARCH64_MOVW_GOTOFF_G0_NC	x
diff --git a/gas/testsuite/gas/aarch64/reloc-gotoff_g0_nc.s b/gas/testsuite/gas/aarch64/reloc-gotoff_g0_nc.s
new file mode 100644
index 0000000..2affa03
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/reloc-gotoff_g0_nc.s
@@ -0,0 +1,5 @@
+// Test file for AArch64 GAS -- gotoff_g0_nc
+
+func:
+	// BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC
+	movk    x28, #:gotoff_g0_nc:x


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]