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]

[9/16][binutils][AARCH64]Add relocation support for large memory model. [GAS]Add BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC support.


Hi all,

This is a patch to add BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC to GAS.
The following code sequence should be generated to access TLS variable in General Dynamic TLS Model.


    movz a0, #:tlsgd_g1:x             R_AARCH64_TLSGD_MOVW_G1
    movk a0, #:tlsgd_g0_nc:x       R_AARCH64_TLSGD_MOVW_G0_NC
    add  a0, gp, a0
    bl   __tls_get_addr                    R_AARCH64_CALL26
    nop

Binutils and gas regression test done without new failures. Okay to commit?

Regards,
Renlin

bfd/ChangeLog:

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

    * reloc.c (BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC): New entry.
    * elfnn-aarch64.c (elfNN_aarch64_howto_table): New entry for
    BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC.
    * libbfd.h: Regenerate.
    * bfd-in2.h: Likewise


gas/ChangeLog:

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

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

gas/testsuite/ChangeLog:

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

    * gas/aarch64/reloc-tlsgd_g0_nc.d: New.
    * gas/aarch64/reloc-tlsgd_g0_nc.s: New.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 8ab8bd5..ac2fa7f 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -5785,6 +5785,9 @@ BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.  */
   BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC,
 
 /* AArch64 TLS General Dynamic relocation.  */
+  BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC,
+
+/* AArch64 TLS General Dynamic relocation.  */
   BFD_RELOC_AARCH64_TLSGD_MOVW_G1,
 
 /* AArch64 TLS INITIAL EXEC relocation.  */
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index d2c8a0b..e373986 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -168,6 +168,7 @@
   ((R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC		\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21		\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSGD_ADR_PREL21		\
+   || (R_TYPE) == BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC		\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSGD_MOVW_G1		\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21	\
    || (R_TYPE) == BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC	\
@@ -989,6 +990,21 @@ static reloc_howto_type elfNN_aarch64_howto_table[] =
 	 0xfff,			/* dst_mask */
 	 FALSE),		/* pcrel_offset */
 
+  /* Lower 16 bits of GOT offset to tls_index.  */
+  HOWTO64 (AARCH64_R (TLSGD_MOVW_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 (TLSGD_MOVW_G0_NC),	/* name */
+	 FALSE,			/* partial_inplace */
+	 0xffff,		/* src_mask */
+	 0xffff,		/* dst_mask */
+	 FALSE),		/* pcrel_offset */
+
   /* Higher 16 bits of GOT offset to tls_index.  */
   HOWTO64 (AARCH64_R (TLSGD_MOVW_G1),	/* type */
 	 16,			/* rightshift */
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 10bc048..40e4118 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -2755,6 +2755,7 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
   "BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21",
   "BFD_RELOC_AARCH64_TLSGD_ADR_PREL21",
   "BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC",
+  "BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC",
   "BFD_RELOC_AARCH64_TLSGD_MOVW_G1",
   "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1",
   "BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 008a809..f408a97 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -6830,6 +6830,10 @@ ENUMDOC
   tls_index structure.  Used in conjunction with
   BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21.
 ENUM
+  BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC
+ENUMDOC
+  AArch64 TLS General Dynamic relocation.
+ENUM
   BFD_RELOC_AARCH64_TLSGD_MOVW_G1
 ENUMDOC
   AArch64 TLS General Dynamic relocation.
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index b56d4c1..0b7d92e 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -2500,6 +2500,15 @@ static struct reloc_table_entry reloc_table[] = {
    0,
    0},
 
+  /* Lower 16 bits address/value: MOVk.  */
+  {"tlsgd_g0_nc", 0,
+   0,				/* adr_type */
+   0,
+   BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC,
+   0,
+   0,
+   0},
+
   /* Most significant bits 16-31 of address/value: MOVZ.  */
   {"tlsgd_g1", 0,
    0,				/* adr_type */
@@ -4633,6 +4642,7 @@ process_movw_reloc_info (void)
     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_TLSGD_MOVW_G0_NC:
     case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0:
     case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0_NC:
       shift = 0;
@@ -6826,6 +6836,7 @@ md_apply_fix (fixS * fixP, valueT * valP, segT seg)
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
+    case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC:
     case BFD_RELOC_AARCH64_TLSGD_MOVW_G1:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
@@ -7040,6 +7051,7 @@ aarch64_force_relocation (struct fix *fixp)
     case BFD_RELOC_AARCH64_TLSGD_ADD_LO12_NC:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PAGE21:
     case BFD_RELOC_AARCH64_TLSGD_ADR_PREL21:
+    case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC:
     case BFD_RELOC_AARCH64_TLSGD_MOVW_G1:
     case BFD_RELOC_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
     case BFD_RELOC_AARCH64_TLSIE_LD32_GOTTPREL_LO12_NC:
diff --git a/gas/testsuite/gas/aarch64/reloc-tlsgd_g0_nc.d b/gas/testsuite/gas/aarch64/reloc-tlsgd_g0_nc.d
new file mode 100644
index 0000000..157c5fd
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/reloc-tlsgd_g0_nc.d
@@ -0,0 +1,9 @@
+#objdump: -dr
+
+.*:     file format .*
+
+Disassembly of section \.text:
+
+0000000000000000 <.*>:
+   0:	f280001c 	movk	x28, #0x0
+			0: R_AARCH64_TLSGD_MOVW_G0_NC	var
diff --git a/gas/testsuite/gas/aarch64/reloc-tlsgd_g0_nc.s b/gas/testsuite/gas/aarch64/reloc-tlsgd_g0_nc.s
new file mode 100644
index 0000000..bb253fa
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/reloc-tlsgd_g0_nc.s
@@ -0,0 +1,4 @@
+func:
+
+	// R_AARCH64_TLSGD_MOVW_G0_NC var
+	movk x28, #:tlsgd_g0_nc:var


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