public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
@ 2014-02-07 10:16 Yury Gribov
  2014-02-10  8:32 ` Will Newton
  0 siblings, 1 reply; 18+ messages in thread
From: Yury Gribov @ 2014-02-07 10:16 UTC (permalink / raw)
  To: binutils; +Cc: Viacheslav Garbuzov, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 1304 bytes --]

Hi all,

Currently BFD linker generates 3-word wide .plt entries for ARM targets:

0000825c <.plt>:
...
8270: e28fc600 add ip, pc, #0, 12
8274: e28cca08 add ip, ip, #8, 20 ; 0x8000
8278: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8
827c: e28fc600 add ip, pc, #0, 12
8280: e28cca08 add ip, ip, #8, 20 ; 0x8000
8284: e5bcf3e0 ldr pc, [ip, #992]! ; 0x3e0

These entries are only able to initialize first 28 bits of .plt/.got
displacement. If .text and .rodata are bigger than 2 ^ 28 bytes (i.e. 
256M) this may cause linker errors due to assert in 
elf32_arm_populate_plt_entry (in bfd/elf32-arm.c):
BFD_ASSERT ((got_displacement & 0xf0000000) == 0);

I suggest to add an option --long-plt to allow generation of 4-word wide
.plt entries capable of handling arbitrary .plt/.got displacements:

0000825c <.plt>:
...
8270: e28fc200 add ip, pc, #0, 4
8274: e28cc600 add ip, ip, #0, 12
8278: e28cca08 add ip, ip, #8, 20 ; 0x8000
827c: e5bcf3f4 ldr pc, [ip, #1012]! ; 0x3f4
8280: e28fc200 add ip, pc, #0, 4
8284: e28cc600 add ip, ip, #0, 12
8288: e28cca08 add ip, ip, #8, 20 ; 0x8000
828c: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8

Users will than be able to avoid afore-mentioned link error by compiling
with -Wl,--long-plt.

I'm attaching a draft patch to illustrate my proposal. Does it make sense?

Best regards,
Yury

[-- Attachment #2: long_plt_1.diff --]
[-- Type: text/x-diff, Size: 7211 bytes --]

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index c7c5a7d..52fa19e 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -887,6 +887,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 33792f4..92cd688 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -894,6 +894,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 7216244..bbf394e 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2142,13 +2142,24 @@ static const bfd_vma elf32_arm_plt0_entry [] =
 
 /* Subsequent entries in a procedure linkage table look like
    this.  */
-static const bfd_vma elf32_arm_plt_entry [] =
+static const bfd_vma elf32_arm_plt_entry_short [] =
 {
   0xe28fc600,		/* add   ip, pc, #0xNN00000 */
   0xe28cca00,		/* add	 ip, ip, #0xNN000   */
   0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
 };
 
+/* Or this */
+static const bfd_vma elf32_arm_plt_entry_long [] =
+  {
+    0xe28fc200,     /* add   ip, pc, #0xN0000000 */
+    0xe28cc600,		/* add   ip, ip, #0xNN00000 */
+    0xe28cca00,		/* add	 ip, ip, #0xNN000   */
+    0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
+  };
+
+static size_t elf32_arm_use_long_plt_entry = 0;
+
 #endif
 
 /* The format of the first entry in the procedure linkage table
@@ -3464,7 +3475,7 @@ elf32_arm_link_hash_table_create (bfd *abfd)
   ret->plt_entry_size = 16;
 #else
   ret->plt_header_size = 20;
-  ret->plt_entry_size = 12;
+  ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12;
 #endif
   ret->use_rel = 1;
   ret->obfd = abfd;
@@ -6027,6 +6038,15 @@ arm_make_glue_section (bfd * abfd, const char * name)
   return TRUE;
 }
 
+/* Set size of .plt entries.  This function is called from the
+   linker scripts in ld/emultempl/{armelf}.em.  */
+
+void
+bfd_elf32_arm_use_long_plt (void)
+{
+  elf32_arm_use_long_plt_entry = 1;
+}
+
 /* Add the glue sections to ABFD.  This function is called from the
    linker scripts in ld/emultempl/{armelf}.em.  */
 
@@ -7705,8 +7725,6 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 	     of the PLT stub.  */
 	  got_displacement = got_address - (plt_address + 8);
 
-	  BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
-
 	  if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt))
 	    {
 	      put_thumb_insn (htab, output_bfd,
@@ -7715,21 +7733,44 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 			      elf32_arm_plt_thumb_stub[1], ptr - 2);
 	    }
 
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[0]
-			| ((got_displacement & 0x0ff00000) >> 20),
-			ptr + 0);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[1]
-			| ((got_displacement & 0x000ff000) >> 12),
-			ptr+ 4);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[2]
-			| (got_displacement & 0x00000fff),
-			ptr + 8);
+	  if (!elf32_arm_use_long_plt_entry)
+	    {
+	      BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[0]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[1]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[2]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 8);
 #ifdef FOUR_WORD_PLT
-	  bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12);
+	      bfd_put_32 (output_bfd, elf32_arm_plt_entry_short[3], ptr + 12);
 #endif
+	    }
+	  else
+	    {
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[0]
+			      | ((got_displacement & 0xf0000000) >> 28),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[1]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[2]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 8);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[3]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 12);
+	    }
 	}
 
       /* Fill in the entry in the .rel(a).(i)plt section.  */
diff --git a/elfcpp/arm.h b/elfcpp/arm.h
index ab0618a..5c383c4 100644
--- a/elfcpp/arm.h
+++ b/elfcpp/arm.h
@@ -214,6 +214,8 @@ enum
   EF_ARM_EABI_VER3 = 0x03000000,
   EF_ARM_EABI_VER4 = 0x04000000,
   EF_ARM_EABI_VER5 = 0x05000000,
+
+  EF_ARM_HASENTRY = 0x00000002,
 };
 
 // Extract EABI version from flags.
diff --git a/gold/arm.cc b/gold/arm.cc
index 560f380..b3dd039 100644
--- a/gold/arm.cc
+++ b/gold/arm.cc
@@ -8693,6 +8693,9 @@ Target_arm<big_endian>::do_finalize_sections(
       merged_any_attributes = true;
     }
 
+  if (parameters->entry())
+    this->set_processor_specific_flags(this->processor_specific_flags() | elfcpp::EF_ARM_HASENTRY);
+
   // Create an empty uninitialized attribute section if we still don't have it
   // at this moment.  This happens if there is no attributes sections in all
   // inputs.
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 85e924f..ce3d688 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -531,6 +531,7 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_NO_MERGE_EXIDX_ENTRIES   316
 #define OPTION_FIX_ARM1176		317
 #define OPTION_NO_FIX_ARM1176		318
+#define OPTION_LONG_PLT		319
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -555,6 +556,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "no-merge-exidx-entries", no_argument, NULL, OPTION_NO_MERGE_EXIDX_ENTRIES },
   { "fix-arm1176", no_argument, NULL, OPTION_FIX_ARM1176 },
   { "no-fix-arm1176", no_argument, NULL, OPTION_NO_FIX_ARM1176 },
+  { "long-plt", no_argument, NULL, OPTION_LONG_PLT },
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -572,6 +574,8 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("  --no-wchar-size-warning     Don'\''t warn about objects with incompatible\n"
 		   "                                wchar_t sizes\n"));
   fprintf (file, _("  --pic-veneer                Always generate PIC interworking veneers\n"));
+  fprintf (file, _("  --long-plt                  Generate long .plt entries\n"
+           "                              to handle large .plt/.got displacements\n"));
   fprintf (file, _("\
   --stub-group-size=N         Maximum size of a group of input sections that\n\
                                can be handled by one stub section.  A negative\n\
@@ -675,6 +679,10 @@ PARSE_AND_LIST_ARGS_CASES='
    case OPTION_NO_FIX_ARM1176:
       fix_arm1176 = 0;
       break;
+
+   case OPTION_LONG_PLT:
+      bfd_elf32_arm_use_long_plt ();
+      break;
 '
 
 # We have our own before_allocation etc. functions, but they call

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-07 10:16 [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM Yury Gribov
@ 2014-02-10  8:32 ` Will Newton
  2014-02-10 11:52   ` Yury Gribov
  0 siblings, 1 reply; 18+ messages in thread
From: Will Newton @ 2014-02-10  8:32 UTC (permalink / raw)
  To: Yury Gribov; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

On 7 February 2014 10:17, Yury Gribov <y.gribov@samsung.com> wrote:
> Hi all,
>
> Currently BFD linker generates 3-word wide .plt entries for ARM targets:
>
> 0000825c <.plt>:
> ...
> 8270: e28fc600 add ip, pc, #0, 12
> 8274: e28cca08 add ip, ip, #8, 20 ; 0x8000
> 8278: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8
> 827c: e28fc600 add ip, pc, #0, 12
> 8280: e28cca08 add ip, ip, #8, 20 ; 0x8000
> 8284: e5bcf3e0 ldr pc, [ip, #992]! ; 0x3e0
>
> These entries are only able to initialize first 28 bits of .plt/.got
> displacement. If .text and .rodata are bigger than 2 ^ 28 bytes (i.e. 256M)
> this may cause linker errors due to assert in elf32_arm_populate_plt_entry
> (in bfd/elf32-arm.c):
> BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
>
> I suggest to add an option --long-plt to allow generation of 4-word wide
> .plt entries capable of handling arbitrary .plt/.got displacements:
>
> 0000825c <.plt>:
> ...
> 8270: e28fc200 add ip, pc, #0, 4
> 8274: e28cc600 add ip, ip, #0, 12
> 8278: e28cca08 add ip, ip, #8, 20 ; 0x8000
> 827c: e5bcf3f4 ldr pc, [ip, #1012]! ; 0x3f4
> 8280: e28fc200 add ip, pc, #0, 4
> 8284: e28cc600 add ip, ip, #0, 12
> 8288: e28cca08 add ip, ip, #8, 20 ; 0x8000
> 828c: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8
>
> Users will than be able to avoid afore-mentioned link error by compiling
> with -Wl,--long-plt.
>
> I'm attaching a draft patch to illustrate my proposal. Does it make sense?
>
> Best regards,
> Yury

This sounds ok in principle to me (note I am not the ARM or a global
maintainer).

I think elf32_arm_use_long_plt_entry should probably be a boolean
rather than size_t.

The comments on the PLT entries could be more verbose (i.e. point out
that one PLT can address 28 bits and the other 32).

I wonder whether the FOUR_WORD_PLT #define is now rather ambiguous,
maybe it should be removed?

The gold parts of this patch look like they are not related?

And obviously there would need to be ld testcases.

-- 
Will Newton
Toolchain Working Group, Linaro

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-10  8:32 ` Will Newton
@ 2014-02-10 11:52   ` Yury Gribov
  2014-02-17  6:39     ` [PATCH/ARM][PING] " Yury Gribov
  2014-02-21 14:24     ` [RFC][PATCH] " nick clifton
  0 siblings, 2 replies; 18+ messages in thread
From: Yury Gribov @ 2014-02-10 11:52 UTC (permalink / raw)
  To: Will Newton; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

Will wrote:
> I think elf32_arm_use_long_plt_entry should probably be
> a boolean rather than size_t.

Done, thanks

> The comments on the PLT entries could be more verbose (i.e. point out
> that one PLT can address 28 bits and the other 32).

Ok, I tried my best.

> I wonder whether the FOUR_WORD_PLT #define is now rather ambiguous,
> maybe it should be removed?

That was my impression as well. At least there are no options in 
configure scripts to define.

> The gold parts of this patch look like they are not related?

Sorry, unrelated indeed.

> And obviously there would need to be ld testcases.

Added ld/testsuite/ld-arm/long-plt-format.{s,d}. BTW are there any 
guidelines for writing tests? I was unable to find any...

-Y

[-- Attachment #2: long_plt_2.diff --]
[-- Type: text/x-diff, Size: 8171 bytes --]

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index c7c5a7d..52fa19e 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -887,6 +887,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 33792f4..92cd688 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -894,6 +894,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 7216244..ecc5ee4 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2140,15 +2140,27 @@ static const bfd_vma elf32_arm_plt0_entry [] =
   0x00000000,		/* &GOT[0] - .          */
 };
 
-/* Subsequent entries in a procedure linkage table look like
-   this.  */
-static const bfd_vma elf32_arm_plt_entry [] =
+/* By default subsequent entries in a procedure linkage table look like
+   this. Offsets that don't fit into 28 bits will cause link error. */
+static const bfd_vma elf32_arm_plt_entry_short [] =
 {
   0xe28fc600,		/* add   ip, pc, #0xNN00000 */
   0xe28cca00,		/* add	 ip, ip, #0xNN000   */
   0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
 };
 
+/* When explicitly asked, we'll use this "long" entry format
+   which can cope with arbitrary displacements. */
+static const bfd_vma elf32_arm_plt_entry_long [] =
+  {
+    0xe28fc200,     /* add   ip, pc, #0xN0000000 */
+    0xe28cc600,		/* add   ip, ip, #0xNN00000 */
+    0xe28cca00,		/* add	 ip, ip, #0xNN000   */
+    0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
+  };
+
+static bfd_boolean elf32_arm_use_long_plt_entry = FALSE;
+
 #endif
 
 /* The format of the first entry in the procedure linkage table
@@ -3464,7 +3476,7 @@ elf32_arm_link_hash_table_create (bfd *abfd)
   ret->plt_entry_size = 16;
 #else
   ret->plt_header_size = 20;
-  ret->plt_entry_size = 12;
+  ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12;
 #endif
   ret->use_rel = 1;
   ret->obfd = abfd;
@@ -6027,6 +6039,15 @@ arm_make_glue_section (bfd * abfd, const char * name)
   return TRUE;
 }
 
+/* Set size of .plt entries.  This function is called from the
+   linker scripts in ld/emultempl/{armelf}.em.  */
+
+void
+bfd_elf32_arm_use_long_plt (void)
+{
+  elf32_arm_use_long_plt_entry = TRUE;
+}
+
 /* Add the glue sections to ABFD.  This function is called from the
    linker scripts in ld/emultempl/{armelf}.em.  */
 
@@ -7705,8 +7726,6 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 	     of the PLT stub.  */
 	  got_displacement = got_address - (plt_address + 8);
 
-	  BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
-
 	  if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt))
 	    {
 	      put_thumb_insn (htab, output_bfd,
@@ -7715,21 +7734,44 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 			      elf32_arm_plt_thumb_stub[1], ptr - 2);
 	    }
 
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[0]
-			| ((got_displacement & 0x0ff00000) >> 20),
-			ptr + 0);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[1]
-			| ((got_displacement & 0x000ff000) >> 12),
-			ptr+ 4);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[2]
-			| (got_displacement & 0x00000fff),
-			ptr + 8);
+	  if (!elf32_arm_use_long_plt_entry)
+	    {
+	      BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[0]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[1]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[2]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 8);
 #ifdef FOUR_WORD_PLT
-	  bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12);
+	      bfd_put_32 (output_bfd, elf32_arm_plt_entry_short[3], ptr + 12);
 #endif
+	    }
+	  else
+	    {
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[0]
+			      | ((got_displacement & 0xf0000000) >> 28),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[1]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[2]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 8);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[3]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 12);
+	    }
 	}
 
       /* Fill in the entry in the .rel(a).(i)plt section.  */
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 85e924f..ce3d688 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -531,6 +531,7 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_NO_MERGE_EXIDX_ENTRIES   316
 #define OPTION_FIX_ARM1176		317
 #define OPTION_NO_FIX_ARM1176		318
+#define OPTION_LONG_PLT		319
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -555,6 +556,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "no-merge-exidx-entries", no_argument, NULL, OPTION_NO_MERGE_EXIDX_ENTRIES },
   { "fix-arm1176", no_argument, NULL, OPTION_FIX_ARM1176 },
   { "no-fix-arm1176", no_argument, NULL, OPTION_NO_FIX_ARM1176 },
+  { "long-plt", no_argument, NULL, OPTION_LONG_PLT },
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -572,6 +574,8 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("  --no-wchar-size-warning     Don'\''t warn about objects with incompatible\n"
 		   "                                wchar_t sizes\n"));
   fprintf (file, _("  --pic-veneer                Always generate PIC interworking veneers\n"));
+  fprintf (file, _("  --long-plt                  Generate long .plt entries\n"
+           "                              to handle large .plt/.got displacements\n"));
   fprintf (file, _("\
   --stub-group-size=N         Maximum size of a group of input sections that\n\
                                can be handled by one stub section.  A negative\n\
@@ -675,6 +679,10 @@ PARSE_AND_LIST_ARGS_CASES='
    case OPTION_NO_FIX_ARM1176:
       fix_arm1176 = 0;
       break;
+
+   case OPTION_LONG_PLT:
+      bfd_elf32_arm_use_long_plt ();
+      break;
 '
 
 # We have our own before_allocation etc. functions, but they call
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 4c0f802..cea18fa 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -188,6 +188,10 @@ set armelftests_common {
      "" {exec-got-1b.s}
      {{readelf --relocs exec-got-1.d}}
      "exec-got-1"}
+    {"Long PLT entries in executables" "--long-plt -shared --section-start=.plt=0x200 --section-start=.got=0xf0000300" ""
+     "" {long-plt-format.s}
+     {{objdump "-d -j .plt" long-plt-format.d}}
+     "long-plt-format"}
     {"abs call" "-T arm.ld" "" "" {abs-call-1.s}
      {{objdump -d abs-call-1.d}}
      "abs-call-1"}
diff --git a/ld/testsuite/ld-arm/long-plt-format.d b/ld/testsuite/ld-arm/long-plt-format.d
index e69de29..c08cb71 100644
--- a/ld/testsuite/ld-arm/long-plt-format.d
+++ b/ld/testsuite/ld-arm/long-plt-format.d
@@ -0,0 +1,15 @@
+.*:     file format elf32-.*
+
+
+Disassembly of section .plt:
+
+00000200 <.plt>:
+ 200:	.*
+ 204:	.*
+ 208:	.*
+ 20c:	.*
+ 210:	.* 	.word	.*
+ 214:	.* 	add	ip, pc, #-268435456	; 0xf0000000
+ 218:	.* 	add	ip, ip, #0, 12
+ 21c:	.* 	add	ip, ip, #0, 20
+ 220:	.* 	ldr	pc, [ip, #[0-9]*]!	; 0x.*
diff --git a/ld/testsuite/ld-arm/long-plt-format.s b/ld/testsuite/ld-arm/long-plt-format.s
index e69de29..bb0c3a2 100644
--- a/ld/testsuite/ld-arm/long-plt-format.s
+++ b/ld/testsuite/ld-arm/long-plt-format.s
@@ -0,0 +1,7 @@
+	.globl	_start
+	.type	_start,%function
+	.globl foo
+_start:
+	bl foo(PLT)
+	.size	_start,.-_start
+

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH/ARM][PING] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-10 11:52   ` Yury Gribov
@ 2014-02-17  6:39     ` Yury Gribov
  2014-02-24 15:09       ` [PATCH/ARM][PING^2] " Yury Gribov
  2014-02-21 14:24     ` [RFC][PATCH] " nick clifton
  1 sibling, 1 reply; 18+ messages in thread
From: Yury Gribov @ 2014-02-17  6:39 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]

Link to original discussion: 
https://sourceware.org/ml/binutils/2014-02/msg00053.html

Will Newton wrote:
>> I suggest to add an option --long-plt to allow generation of 4-word wide
>> .plt entries capable of handling arbitrary .plt/.got displacements:
 >
 > This sounds ok in principle to me (note I am not the ARM or a global
 > maintainer).

> I think elf32_arm_use_long_plt_entry should probably be
> a boolean rather than size_t.

Done, thanks

> The comments on the PLT entries could be more verbose (i.e. point out
> that one PLT can address 28 bits and the other 32).

Ok, I tried my best.

> I wonder whether the FOUR_WORD_PLT #define is now rather ambiguous,
> maybe it should be removed?

That was my impression as well. At least there are no options in
configure scripts to define.

> The gold parts of this patch look like they are not related?

Sorry, unrelated indeed.

> And obviously there would need to be ld testcases.

Added ld/testsuite/ld-arm/long-plt-format.{s,d}. BTW are there any
guidelines for writing tests? I was unable to find any...

-Y




[-- Attachment #2: long_plt_2.diff --]
[-- Type: text/x-diff, Size: 8172 bytes --]

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index c7c5a7d..52fa19e 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -887,6 +887,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 33792f4..92cd688 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -894,6 +894,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 7216244..ecc5ee4 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2140,15 +2140,27 @@ static const bfd_vma elf32_arm_plt0_entry [] =
   0x00000000,		/* &GOT[0] - .          */
 };
 
-/* Subsequent entries in a procedure linkage table look like
-   this.  */
-static const bfd_vma elf32_arm_plt_entry [] =
+/* By default subsequent entries in a procedure linkage table look like
+   this. Offsets that don't fit into 28 bits will cause link error. */
+static const bfd_vma elf32_arm_plt_entry_short [] =
 {
   0xe28fc600,		/* add   ip, pc, #0xNN00000 */
   0xe28cca00,		/* add	 ip, ip, #0xNN000   */
   0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
 };
 
+/* When explicitly asked, we'll use this "long" entry format
+   which can cope with arbitrary displacements. */
+static const bfd_vma elf32_arm_plt_entry_long [] =
+  {
+    0xe28fc200,     /* add   ip, pc, #0xN0000000 */
+    0xe28cc600,		/* add   ip, ip, #0xNN00000 */
+    0xe28cca00,		/* add	 ip, ip, #0xNN000   */
+    0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
+  };
+
+static bfd_boolean elf32_arm_use_long_plt_entry = FALSE;
+
 #endif
 
 /* The format of the first entry in the procedure linkage table
@@ -3464,7 +3476,7 @@ elf32_arm_link_hash_table_create (bfd *abfd)
   ret->plt_entry_size = 16;
 #else
   ret->plt_header_size = 20;
-  ret->plt_entry_size = 12;
+  ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12;
 #endif
   ret->use_rel = 1;
   ret->obfd = abfd;
@@ -6027,6 +6039,15 @@ arm_make_glue_section (bfd * abfd, const char * name)
   return TRUE;
 }
 
+/* Set size of .plt entries.  This function is called from the
+   linker scripts in ld/emultempl/{armelf}.em.  */
+
+void
+bfd_elf32_arm_use_long_plt (void)
+{
+  elf32_arm_use_long_plt_entry = TRUE;
+}
+
 /* Add the glue sections to ABFD.  This function is called from the
    linker scripts in ld/emultempl/{armelf}.em.  */
 
@@ -7705,8 +7726,6 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 	     of the PLT stub.  */
 	  got_displacement = got_address - (plt_address + 8);
 
-	  BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
-
 	  if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt))
 	    {
 	      put_thumb_insn (htab, output_bfd,
@@ -7715,21 +7734,44 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 			      elf32_arm_plt_thumb_stub[1], ptr - 2);
 	    }
 
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[0]
-			| ((got_displacement & 0x0ff00000) >> 20),
-			ptr + 0);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[1]
-			| ((got_displacement & 0x000ff000) >> 12),
-			ptr+ 4);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[2]
-			| (got_displacement & 0x00000fff),
-			ptr + 8);
+	  if (!elf32_arm_use_long_plt_entry)
+	    {
+	      BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[0]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[1]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[2]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 8);
 #ifdef FOUR_WORD_PLT
-	  bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12);
+	      bfd_put_32 (output_bfd, elf32_arm_plt_entry_short[3], ptr + 12);
 #endif
+	    }
+	  else
+	    {
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[0]
+			      | ((got_displacement & 0xf0000000) >> 28),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[1]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[2]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 8);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[3]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 12);
+	    }
 	}
 
       /* Fill in the entry in the .rel(a).(i)plt section.  */
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 85e924f..ce3d688 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -531,6 +531,7 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_NO_MERGE_EXIDX_ENTRIES   316
 #define OPTION_FIX_ARM1176		317
 #define OPTION_NO_FIX_ARM1176		318
+#define OPTION_LONG_PLT		319
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -555,6 +556,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "no-merge-exidx-entries", no_argument, NULL, OPTION_NO_MERGE_EXIDX_ENTRIES },
   { "fix-arm1176", no_argument, NULL, OPTION_FIX_ARM1176 },
   { "no-fix-arm1176", no_argument, NULL, OPTION_NO_FIX_ARM1176 },
+  { "long-plt", no_argument, NULL, OPTION_LONG_PLT },
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -572,6 +574,8 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("  --no-wchar-size-warning     Don'\''t warn about objects with incompatible\n"
 		   "                                wchar_t sizes\n"));
   fprintf (file, _("  --pic-veneer                Always generate PIC interworking veneers\n"));
+  fprintf (file, _("  --long-plt                  Generate long .plt entries\n"
+           "                              to handle large .plt/.got displacements\n"));
   fprintf (file, _("\
   --stub-group-size=N         Maximum size of a group of input sections that\n\
                                can be handled by one stub section.  A negative\n\
@@ -675,6 +679,10 @@ PARSE_AND_LIST_ARGS_CASES='
    case OPTION_NO_FIX_ARM1176:
       fix_arm1176 = 0;
       break;
+
+   case OPTION_LONG_PLT:
+      bfd_elf32_arm_use_long_plt ();
+      break;
 '
 
 # We have our own before_allocation etc. functions, but they call
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 4c0f802..cea18fa 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -188,6 +188,10 @@ set armelftests_common {
      "" {exec-got-1b.s}
      {{readelf --relocs exec-got-1.d}}
      "exec-got-1"}
+    {"Long PLT entries in executables" "--long-plt -shared --section-start=.plt=0x200 --section-start=.got=0xf0000300" ""
+     "" {long-plt-format.s}
+     {{objdump "-d -j .plt" long-plt-format.d}}
+     "long-plt-format"}
     {"abs call" "-T arm.ld" "" "" {abs-call-1.s}
      {{objdump -d abs-call-1.d}}
      "abs-call-1"}
diff --git a/ld/testsuite/ld-arm/long-plt-format.d b/ld/testsuite/ld-arm/long-plt-format.d
index e69de29..c08cb71 100644
--- a/ld/testsuite/ld-arm/long-plt-format.d
+++ b/ld/testsuite/ld-arm/long-plt-format.d
@@ -0,0 +1,15 @@
+.*:     file format elf32-.*
+
+
+Disassembly of section .plt:
+
+00000200 <.plt>:
+ 200:	.*
+ 204:	.*
+ 208:	.*
+ 20c:	.*
+ 210:	.* 	.word	.*
+ 214:	.* 	add	ip, pc, #-268435456	; 0xf0000000
+ 218:	.* 	add	ip, ip, #0, 12
+ 21c:	.* 	add	ip, ip, #0, 20
+ 220:	.* 	ldr	pc, [ip, #[0-9]*]!	; 0x.*
diff --git a/ld/testsuite/ld-arm/long-plt-format.s b/ld/testsuite/ld-arm/long-plt-format.s
index e69de29..bb0c3a2 100644
--- a/ld/testsuite/ld-arm/long-plt-format.s
+++ b/ld/testsuite/ld-arm/long-plt-format.s
@@ -0,0 +1,7 @@
+	.globl	_start
+	.type	_start,%function
+	.globl foo
+_start:
+	bl foo(PLT)
+	.size	_start,.-_start
+


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-10 11:52   ` Yury Gribov
  2014-02-17  6:39     ` [PATCH/ARM][PING] " Yury Gribov
@ 2014-02-21 14:24     ` nick clifton
  2014-02-24 15:07       ` Yury Gribov
  1 sibling, 1 reply; 18+ messages in thread
From: nick clifton @ 2014-02-21 14:24 UTC (permalink / raw)
  To: Yury Gribov, Will Newton; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

Hi Yury,

> Added ld/testsuite/ld-arm/long-plt-format.{s,d}. BTW are there any
> guidelines for writing tests? I was unable to find any...

The only guideline is "follow what has been done before".  Since you 
have done this, the new test looks fine.

I wonder however whether it would be possible to remove the new command 
line option and have the linker automatically decide between using 
28-bit or 32-bit PLT entries ?  Presumably this would require a scan of 
the entries first, or maybe just the sizes of the object files, but I 
think that users would prefer to have something that just works rather 
than having to learn a new linker command line option.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-21 14:24     ` [RFC][PATCH] " nick clifton
@ 2014-02-24 15:07       ` Yury Gribov
  2014-02-25  9:02         ` nick clifton
  2014-02-25 16:46         ` Richard Earnshaw
  0 siblings, 2 replies; 18+ messages in thread
From: Yury Gribov @ 2014-02-24 15:07 UTC (permalink / raw)
  To: nick clifton, Will Newton; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

Nick Clifton wrote:
> I wonder however whether it would be possible to remove the new command
> line option and have the linker automatically decide between using
> 28-bit or 32-bit PLT entries ?

The problem is that decision on PLT entry size is done long before we 
actually output PLT entries.
Fixing this would require a non-trivial code churn which I'm a bit 
scared to do...

Note that most of the people are probably ok with existing 28-bit 
entries (otherwise we'd know about this issue long ago).

-Y

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH/ARM][PING^2] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-17  6:39     ` [PATCH/ARM][PING] " Yury Gribov
@ 2014-02-24 15:09       ` Yury Gribov
  0 siblings, 0 replies; 18+ messages in thread
From: Yury Gribov @ 2014-02-24 15:09 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

Link to original discussion:
https://sourceware.org/ml/binutils/2014-02/msg00053.html

Will Newton wrote:
>> I suggest to add an option --long-plt to allow generation of 4-word wide
>> .plt entries capable of handling arbitrary .plt/.got displacements:
  >
  > This sounds ok in principle to me (note I am not the ARM or a global
  > maintainer).

> I think elf32_arm_use_long_plt_entry should probably be
> a boolean rather than size_t.

Done, thanks

> The comments on the PLT entries could be more verbose (i.e. point out
> that one PLT can address 28 bits and the other 32).

Ok, I tried my best.

> I wonder whether the FOUR_WORD_PLT #define is now rather ambiguous,
> maybe it should be removed?

That was my impression as well. At least there are no options in
configure scripts to define.

> The gold parts of this patch look like they are not related?

Sorry, unrelated indeed.

> And obviously there would need to be ld testcases.

Added ld/testsuite/ld-arm/long-plt-format.{s,d}. BTW are there any
guidelines for writing tests? I was unable to find any...

-Y







[-- Attachment #2: long_plt_2.diff --]
[-- Type: text/x-diff, Size: 8173 bytes --]

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index c7c5a7d..52fa19e 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -887,6 +887,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 33792f4..92cd688 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -894,6 +894,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 7216244..ecc5ee4 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2140,15 +2140,27 @@ static const bfd_vma elf32_arm_plt0_entry [] =
   0x00000000,		/* &GOT[0] - .          */
 };
 
-/* Subsequent entries in a procedure linkage table look like
-   this.  */
-static const bfd_vma elf32_arm_plt_entry [] =
+/* By default subsequent entries in a procedure linkage table look like
+   this. Offsets that don't fit into 28 bits will cause link error. */
+static const bfd_vma elf32_arm_plt_entry_short [] =
 {
   0xe28fc600,		/* add   ip, pc, #0xNN00000 */
   0xe28cca00,		/* add	 ip, ip, #0xNN000   */
   0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
 };
 
+/* When explicitly asked, we'll use this "long" entry format
+   which can cope with arbitrary displacements. */
+static const bfd_vma elf32_arm_plt_entry_long [] =
+  {
+    0xe28fc200,     /* add   ip, pc, #0xN0000000 */
+    0xe28cc600,		/* add   ip, ip, #0xNN00000 */
+    0xe28cca00,		/* add	 ip, ip, #0xNN000   */
+    0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
+  };
+
+static bfd_boolean elf32_arm_use_long_plt_entry = FALSE;
+
 #endif
 
 /* The format of the first entry in the procedure linkage table
@@ -3464,7 +3476,7 @@ elf32_arm_link_hash_table_create (bfd *abfd)
   ret->plt_entry_size = 16;
 #else
   ret->plt_header_size = 20;
-  ret->plt_entry_size = 12;
+  ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12;
 #endif
   ret->use_rel = 1;
   ret->obfd = abfd;
@@ -6027,6 +6039,15 @@ arm_make_glue_section (bfd * abfd, const char * name)
   return TRUE;
 }
 
+/* Set size of .plt entries.  This function is called from the
+   linker scripts in ld/emultempl/{armelf}.em.  */
+
+void
+bfd_elf32_arm_use_long_plt (void)
+{
+  elf32_arm_use_long_plt_entry = TRUE;
+}
+
 /* Add the glue sections to ABFD.  This function is called from the
    linker scripts in ld/emultempl/{armelf}.em.  */
 
@@ -7705,8 +7726,6 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 	     of the PLT stub.  */
 	  got_displacement = got_address - (plt_address + 8);
 
-	  BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
-
 	  if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt))
 	    {
 	      put_thumb_insn (htab, output_bfd,
@@ -7715,21 +7734,44 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 			      elf32_arm_plt_thumb_stub[1], ptr - 2);
 	    }
 
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[0]
-			| ((got_displacement & 0x0ff00000) >> 20),
-			ptr + 0);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[1]
-			| ((got_displacement & 0x000ff000) >> 12),
-			ptr+ 4);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[2]
-			| (got_displacement & 0x00000fff),
-			ptr + 8);
+	  if (!elf32_arm_use_long_plt_entry)
+	    {
+	      BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[0]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[1]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[2]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 8);
 #ifdef FOUR_WORD_PLT
-	  bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12);
+	      bfd_put_32 (output_bfd, elf32_arm_plt_entry_short[3], ptr + 12);
 #endif
+	    }
+	  else
+	    {
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[0]
+			      | ((got_displacement & 0xf0000000) >> 28),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[1]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[2]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 8);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[3]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 12);
+	    }
 	}
 
       /* Fill in the entry in the .rel(a).(i)plt section.  */
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 85e924f..ce3d688 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -531,6 +531,7 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_NO_MERGE_EXIDX_ENTRIES   316
 #define OPTION_FIX_ARM1176		317
 #define OPTION_NO_FIX_ARM1176		318
+#define OPTION_LONG_PLT		319
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -555,6 +556,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "no-merge-exidx-entries", no_argument, NULL, OPTION_NO_MERGE_EXIDX_ENTRIES },
   { "fix-arm1176", no_argument, NULL, OPTION_FIX_ARM1176 },
   { "no-fix-arm1176", no_argument, NULL, OPTION_NO_FIX_ARM1176 },
+  { "long-plt", no_argument, NULL, OPTION_LONG_PLT },
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -572,6 +574,8 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("  --no-wchar-size-warning     Don'\''t warn about objects with incompatible\n"
 		   "                                wchar_t sizes\n"));
   fprintf (file, _("  --pic-veneer                Always generate PIC interworking veneers\n"));
+  fprintf (file, _("  --long-plt                  Generate long .plt entries\n"
+           "                              to handle large .plt/.got displacements\n"));
   fprintf (file, _("\
   --stub-group-size=N         Maximum size of a group of input sections that\n\
                                can be handled by one stub section.  A negative\n\
@@ -675,6 +679,10 @@ PARSE_AND_LIST_ARGS_CASES='
    case OPTION_NO_FIX_ARM1176:
       fix_arm1176 = 0;
       break;
+
+   case OPTION_LONG_PLT:
+      bfd_elf32_arm_use_long_plt ();
+      break;
 '
 
 # We have our own before_allocation etc. functions, but they call
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 4c0f802..cea18fa 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -188,6 +188,10 @@ set armelftests_common {
      "" {exec-got-1b.s}
      {{readelf --relocs exec-got-1.d}}
      "exec-got-1"}
+    {"Long PLT entries in executables" "--long-plt -shared --section-start=.plt=0x200 --section-start=.got=0xf0000300" ""
+     "" {long-plt-format.s}
+     {{objdump "-d -j .plt" long-plt-format.d}}
+     "long-plt-format"}
     {"abs call" "-T arm.ld" "" "" {abs-call-1.s}
      {{objdump -d abs-call-1.d}}
      "abs-call-1"}
diff --git a/ld/testsuite/ld-arm/long-plt-format.d b/ld/testsuite/ld-arm/long-plt-format.d
index e69de29..c08cb71 100644
--- a/ld/testsuite/ld-arm/long-plt-format.d
+++ b/ld/testsuite/ld-arm/long-plt-format.d
@@ -0,0 +1,15 @@
+.*:     file format elf32-.*
+
+
+Disassembly of section .plt:
+
+00000200 <.plt>:
+ 200:	.*
+ 204:	.*
+ 208:	.*
+ 20c:	.*
+ 210:	.* 	.word	.*
+ 214:	.* 	add	ip, pc, #-268435456	; 0xf0000000
+ 218:	.* 	add	ip, ip, #0, 12
+ 21c:	.* 	add	ip, ip, #0, 20
+ 220:	.* 	ldr	pc, [ip, #[0-9]*]!	; 0x.*
diff --git a/ld/testsuite/ld-arm/long-plt-format.s b/ld/testsuite/ld-arm/long-plt-format.s
index e69de29..bb0c3a2 100644
--- a/ld/testsuite/ld-arm/long-plt-format.s
+++ b/ld/testsuite/ld-arm/long-plt-format.s
@@ -0,0 +1,7 @@
+	.globl	_start
+	.type	_start,%function
+	.globl foo
+_start:
+	bl foo(PLT)
+	.size	_start,.-_start
+



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-24 15:07       ` Yury Gribov
@ 2014-02-25  9:02         ` nick clifton
  2014-02-27 12:53           ` Yury Gribov
  2014-02-25 16:46         ` Richard Earnshaw
  1 sibling, 1 reply; 18+ messages in thread
From: nick clifton @ 2014-02-25  9:02 UTC (permalink / raw)
  To: Yury Gribov, Will Newton; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

Hi Yury,

> The problem is that decision on PLT entry size is done long before we
> actually output PLT entries.

I thought that that might be the case.

> Fixing this would require a non-trivial code churn which I'm a bit
> scared to do...
>
> Note that most of the people are probably ok with existing 28-bit
> entries (otherwise we'd know about this issue long ago).

Fair enough - in which case the patch is approved - please apply.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-24 15:07       ` Yury Gribov
  2014-02-25  9:02         ` nick clifton
@ 2014-02-25 16:46         ` Richard Earnshaw
  2014-02-25 18:01           ` Yuri Gribov
  1 sibling, 1 reply; 18+ messages in thread
From: Richard Earnshaw @ 2014-02-25 16:46 UTC (permalink / raw)
  To: Yury Gribov
  Cc: nickc, Will Newton, binutils, Viacheslav Garbuzov, Yuri Gribov

On 24/02/14 15:07, Yury Gribov wrote:
> Nick Clifton wrote:
>> I wonder however whether it would be possible to remove the new command
>> line option and have the linker automatically decide between using
>> 28-bit or 32-bit PLT entries ?
> 
> The problem is that decision on PLT entry size is done long before we 
> actually output PLT entries.
> Fixing this would require a non-trivial code churn which I'm a bit 
> scared to do...
> 
> Note that most of the people are probably ok with existing 28-bit 
> entries (otherwise we'd know about this issue long ago).
> 
> -Y
> 

Indeed, why would you need to place the PLT and GOT more than 256MB
apart?  That would be a pretty massive library on a 32-bit machine.

R.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-25 16:46         ` Richard Earnshaw
@ 2014-02-25 18:01           ` Yuri Gribov
  0 siblings, 0 replies; 18+ messages in thread
From: Yuri Gribov @ 2014-02-25 18:01 UTC (permalink / raw)
  To: Richard Earnshaw
  Cc: Yury Gribov, nickc, Will Newton, binutils, Viacheslav Garbuzov

> Indeed, why would you need to place the PLT and GOT more than 256MB
> apart?  That would be a pretty massive library on a 32-bit machine.

I was waiting for this question. So my client links most of the code
into one monstrous executable where .text + .rodata take ~120M in
size. I then compile it under AddressSanitizer which doubles size of
executable.

-Y

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-25  9:02         ` nick clifton
@ 2014-02-27 12:53           ` Yury Gribov
  2014-02-27 14:42             ` nick clifton
  0 siblings, 1 reply; 18+ messages in thread
From: Yury Gribov @ 2014-02-27 12:53 UTC (permalink / raw)
  To: nick clifton, Will Newton; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 186 bytes --]

Nick wrote:
> Fair enough - in which case the patch is approved - please apply.

Unfortunately I don't have write access. Could someone commit it for me?

Re-attaching just in case.

-Y

[-- Attachment #2: long_plt_2.diff --]
[-- Type: text/x-diff, Size: 8171 bytes --]

diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index c7c5a7d..52fa19e 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -887,6 +887,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 33792f4..92cd688 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -894,6 +894,8 @@ extern bfd_boolean bfd_is_arm_special_symbol_name
 
 extern void bfd_elf32_arm_set_byteswap_code (struct bfd_link_info *, int);
 
+extern void bfd_elf32_arm_use_long_plt (void);
+
 /* ARM Note section processing.  */
 extern bfd_boolean bfd_arm_merge_machines
   (bfd *, bfd *);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 7216244..ecc5ee4 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -2140,15 +2140,27 @@ static const bfd_vma elf32_arm_plt0_entry [] =
   0x00000000,		/* &GOT[0] - .          */
 };
 
-/* Subsequent entries in a procedure linkage table look like
-   this.  */
-static const bfd_vma elf32_arm_plt_entry [] =
+/* By default subsequent entries in a procedure linkage table look like
+   this. Offsets that don't fit into 28 bits will cause link error. */
+static const bfd_vma elf32_arm_plt_entry_short [] =
 {
   0xe28fc600,		/* add   ip, pc, #0xNN00000 */
   0xe28cca00,		/* add	 ip, ip, #0xNN000   */
   0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
 };
 
+/* When explicitly asked, we'll use this "long" entry format
+   which can cope with arbitrary displacements. */
+static const bfd_vma elf32_arm_plt_entry_long [] =
+  {
+    0xe28fc200,     /* add   ip, pc, #0xN0000000 */
+    0xe28cc600,		/* add   ip, ip, #0xNN00000 */
+    0xe28cca00,		/* add	 ip, ip, #0xNN000   */
+    0xe5bcf000,		/* ldr	 pc, [ip, #0xNNN]!  */
+  };
+
+static bfd_boolean elf32_arm_use_long_plt_entry = FALSE;
+
 #endif
 
 /* The format of the first entry in the procedure linkage table
@@ -3464,7 +3476,7 @@ elf32_arm_link_hash_table_create (bfd *abfd)
   ret->plt_entry_size = 16;
 #else
   ret->plt_header_size = 20;
-  ret->plt_entry_size = 12;
+  ret->plt_entry_size = elf32_arm_use_long_plt_entry ? 16 : 12;
 #endif
   ret->use_rel = 1;
   ret->obfd = abfd;
@@ -6027,6 +6039,15 @@ arm_make_glue_section (bfd * abfd, const char * name)
   return TRUE;
 }
 
+/* Set size of .plt entries.  This function is called from the
+   linker scripts in ld/emultempl/{armelf}.em.  */
+
+void
+bfd_elf32_arm_use_long_plt (void)
+{
+  elf32_arm_use_long_plt_entry = TRUE;
+}
+
 /* Add the glue sections to ABFD.  This function is called from the
    linker scripts in ld/emultempl/{armelf}.em.  */
 
@@ -7705,8 +7726,6 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 	     of the PLT stub.  */
 	  got_displacement = got_address - (plt_address + 8);
 
-	  BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
-
 	  if (elf32_arm_plt_needs_thumb_stub_p (info, arm_plt))
 	    {
 	      put_thumb_insn (htab, output_bfd,
@@ -7715,21 +7734,44 @@ elf32_arm_populate_plt_entry (bfd *output_bfd, struct bfd_link_info *info,
 			      elf32_arm_plt_thumb_stub[1], ptr - 2);
 	    }
 
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[0]
-			| ((got_displacement & 0x0ff00000) >> 20),
-			ptr + 0);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[1]
-			| ((got_displacement & 0x000ff000) >> 12),
-			ptr+ 4);
-	  put_arm_insn (htab, output_bfd,
-			elf32_arm_plt_entry[2]
-			| (got_displacement & 0x00000fff),
-			ptr + 8);
+	  if (!elf32_arm_use_long_plt_entry)
+	    {
+	      BFD_ASSERT ((got_displacement & 0xf0000000) == 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[0]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[1]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_short[2]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 8);
 #ifdef FOUR_WORD_PLT
-	  bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], ptr + 12);
+	      bfd_put_32 (output_bfd, elf32_arm_plt_entry_short[3], ptr + 12);
 #endif
+	    }
+	  else
+	    {
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[0]
+			      | ((got_displacement & 0xf0000000) >> 28),
+			      ptr + 0);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[1]
+			      | ((got_displacement & 0x0ff00000) >> 20),
+			      ptr + 4);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[2]
+			      | ((got_displacement & 0x000ff000) >> 12),
+			      ptr+ 8);
+	      put_arm_insn (htab, output_bfd,
+			      elf32_arm_plt_entry_long[3]
+			      | (got_displacement & 0x00000fff),
+			      ptr + 12);
+	    }
 	}
 
       /* Fill in the entry in the .rel(a).(i)plt section.  */
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 85e924f..ce3d688 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -531,6 +531,7 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_NO_MERGE_EXIDX_ENTRIES   316
 #define OPTION_FIX_ARM1176		317
 #define OPTION_NO_FIX_ARM1176		318
+#define OPTION_LONG_PLT		319
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -555,6 +556,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "no-merge-exidx-entries", no_argument, NULL, OPTION_NO_MERGE_EXIDX_ENTRIES },
   { "fix-arm1176", no_argument, NULL, OPTION_FIX_ARM1176 },
   { "no-fix-arm1176", no_argument, NULL, OPTION_NO_FIX_ARM1176 },
+  { "long-plt", no_argument, NULL, OPTION_LONG_PLT },
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -572,6 +574,8 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("  --no-wchar-size-warning     Don'\''t warn about objects with incompatible\n"
 		   "                                wchar_t sizes\n"));
   fprintf (file, _("  --pic-veneer                Always generate PIC interworking veneers\n"));
+  fprintf (file, _("  --long-plt                  Generate long .plt entries\n"
+           "                              to handle large .plt/.got displacements\n"));
   fprintf (file, _("\
   --stub-group-size=N         Maximum size of a group of input sections that\n\
                                can be handled by one stub section.  A negative\n\
@@ -675,6 +679,10 @@ PARSE_AND_LIST_ARGS_CASES='
    case OPTION_NO_FIX_ARM1176:
       fix_arm1176 = 0;
       break;
+
+   case OPTION_LONG_PLT:
+      bfd_elf32_arm_use_long_plt ();
+      break;
 '
 
 # We have our own before_allocation etc. functions, but they call
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index 4c0f802..cea18fa 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -188,6 +188,10 @@ set armelftests_common {
      "" {exec-got-1b.s}
      {{readelf --relocs exec-got-1.d}}
      "exec-got-1"}
+    {"Long PLT entries in executables" "--long-plt -shared --section-start=.plt=0x200 --section-start=.got=0xf0000300" ""
+     "" {long-plt-format.s}
+     {{objdump "-d -j .plt" long-plt-format.d}}
+     "long-plt-format"}
     {"abs call" "-T arm.ld" "" "" {abs-call-1.s}
      {{objdump -d abs-call-1.d}}
      "abs-call-1"}
diff --git a/ld/testsuite/ld-arm/long-plt-format.d b/ld/testsuite/ld-arm/long-plt-format.d
index e69de29..c08cb71 100644
--- a/ld/testsuite/ld-arm/long-plt-format.d
+++ b/ld/testsuite/ld-arm/long-plt-format.d
@@ -0,0 +1,15 @@
+.*:     file format elf32-.*
+
+
+Disassembly of section .plt:
+
+00000200 <.plt>:
+ 200:	.*
+ 204:	.*
+ 208:	.*
+ 20c:	.*
+ 210:	.* 	.word	.*
+ 214:	.* 	add	ip, pc, #-268435456	; 0xf0000000
+ 218:	.* 	add	ip, ip, #0, 12
+ 21c:	.* 	add	ip, ip, #0, 20
+ 220:	.* 	ldr	pc, [ip, #[0-9]*]!	; 0x.*
diff --git a/ld/testsuite/ld-arm/long-plt-format.s b/ld/testsuite/ld-arm/long-plt-format.s
index e69de29..bb0c3a2 100644
--- a/ld/testsuite/ld-arm/long-plt-format.s
+++ b/ld/testsuite/ld-arm/long-plt-format.s
@@ -0,0 +1,7 @@
+	.globl	_start
+	.type	_start,%function
+	.globl foo
+_start:
+	bl foo(PLT)
+	.size	_start,.-_start
+

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-27 12:53           ` Yury Gribov
@ 2014-02-27 14:42             ` nick clifton
  2014-02-28  5:53               ` Hans-Peter Nilsson
  0 siblings, 1 reply; 18+ messages in thread
From: nick clifton @ 2014-02-27 14:42 UTC (permalink / raw)
  To: Yury Gribov, Will Newton; +Cc: binutils, Viacheslav Garbuzov, Yuri Gribov

Hi Yury,

>> Fair enough - in which case the patch is approved - please apply.
>
> Unfortunately I don't have write access. Could someone commit it for me?

Done. :-)

Cheers
   Nick


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-27 14:42             ` nick clifton
@ 2014-02-28  5:53               ` Hans-Peter Nilsson
  2014-02-28  6:15                 ` Yury Gribov
  0 siblings, 1 reply; 18+ messages in thread
From: Hans-Peter Nilsson @ 2014-02-28  5:53 UTC (permalink / raw)
  To: nick clifton
  Cc: Yury Gribov, Will Newton, binutils, Viacheslav Garbuzov, Yuri Gribov

On Thu, 27 Feb 2014, nick clifton wrote:

> Hi Yury,
>
> > > Fair enough - in which case the patch is approved - please apply.
> >
> > Unfortunately I don't have write access. Could someone commit it for me?
>
> Done. :-)

The new test fails for arm-eabi:
Running /tmp/hpautotest-binutils/bsrc/src/ld/testsuite/ld-arm/arm-elf.exp ...
FAIL: Long PLT entries in executables

brgds, H-P

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-28  5:53               ` Hans-Peter Nilsson
@ 2014-02-28  6:15                 ` Yury Gribov
  2014-02-28 19:40                   ` Hans-Peter Nilsson
  0 siblings, 1 reply; 18+ messages in thread
From: Yury Gribov @ 2014-02-28  6:15 UTC (permalink / raw)
  To: Hans-Peter Nilsson, nick clifton
  Cc: Will Newton, binutils, Viacheslav Garbuzov, Yuri Gribov

[-- Attachment #1: Type: text/plain, Size: 173 bytes --]

 > The new test fails for arm-eabi:

Right, I only tested linux-gnueabi. Could you check whether attached 
patch works for you? Gnueabi and eabi tests passed fine here.

-Y

[-- Attachment #2: long_plt_eabi_fix_1.diff --]
[-- Type: text/x-diff, Size: 1365 bytes --]

diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
index ec569ca..b6bde2b 100644
--- a/ld/testsuite/ld-arm/arm-elf.exp
+++ b/ld/testsuite/ld-arm/arm-elf.exp
@@ -188,7 +188,7 @@ set armelftests_common {
      "" {exec-got-1b.s}
      {{readelf --relocs exec-got-1.d}}
      "exec-got-1"}
-    {"Long PLT entries in executables" "--long-plt -shared --section-start=.plt=0x200 --section-start=.got=0xf0000300" ""
+    {"Long PLT entries in executables" "--long-plt -shared --section-start=.plt=0x1000 --section-start=.got=0xf0001100" ""
      "" {long-plt-format.s}
      {{objdump "-d -j .plt" long-plt-format.d}}
      "long-plt-format"}
diff --git a/ld/testsuite/ld-arm/long-plt-format.d b/ld/testsuite/ld-arm/long-plt-format.d
index c08cb71..c64b42f 100644
--- a/ld/testsuite/ld-arm/long-plt-format.d
+++ b/ld/testsuite/ld-arm/long-plt-format.d
@@ -3,13 +3,13 @@
 
 Disassembly of section .plt:
 
-00000200 <.plt>:
- 200:	.*
- 204:	.*
- 208:	.*
- 20c:	.*
- 210:	.* 	.word	.*
- 214:	.* 	add	ip, pc, #-268435456	; 0xf0000000
- 218:	.* 	add	ip, ip, #0, 12
- 21c:	.* 	add	ip, ip, #0, 20
- 220:	.* 	ldr	pc, [ip, #[0-9]*]!	; 0x.*
+.* <.plt>:
+ .*:	.*
+ .*:	.*
+ .*:	.*
+ .*:	.*
+ .*:	.* 	.word	.*
+ .*:	.* 	add	ip, pc, #-268435456	; 0xf0000000
+ .*:	.* 	add	ip, ip, #0, 12
+ .*:	.* 	add	ip, ip, #0, 20
+ .*:	.* 	ldr	pc, [ip, #[0-9]*]!	; 0x.*

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-28  6:15                 ` Yury Gribov
@ 2014-02-28 19:40                   ` Hans-Peter Nilsson
  2014-02-28 19:57                     ` Yuri Gribov
  0 siblings, 1 reply; 18+ messages in thread
From: Hans-Peter Nilsson @ 2014-02-28 19:40 UTC (permalink / raw)
  To: Yury Gribov
  Cc: nick clifton, Will Newton, binutils, Viacheslav Garbuzov, Yuri Gribov

On Fri, 28 Feb 2014, Yury Gribov wrote:

> > The new test fails for arm-eabi:
>
> Right, I only tested linux-gnueabi. Could you check whether attached patch
> works for you? Gnueabi and eabi tests passed fine here.

Thanks for the quick reply, but I don't think I need a separate
test at this end for the same target?  Still, yes it worked here
too, thanks.

brgds, H-P

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-28 19:40                   ` Hans-Peter Nilsson
@ 2014-02-28 19:57                     ` Yuri Gribov
  2014-03-01 11:27                       ` Hans-Peter Nilsson
  0 siblings, 1 reply; 18+ messages in thread
From: Yuri Gribov @ 2014-02-28 19:57 UTC (permalink / raw)
  To: Hans-Peter Nilsson
  Cc: Yury Gribov, nick clifton, Will Newton, binutils, Viacheslav Garbuzov

> but I don't think I need a separate
> test at this end for the same target?

True, just wanted to be sure.

> Still, yes it worked here
> too, thanks.

Could you commit this fix then? I don't have write access.

-Y

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-02-28 19:57                     ` Yuri Gribov
@ 2014-03-01 11:27                       ` Hans-Peter Nilsson
  2014-03-02 16:10                         ` Nicholas Clifton
  0 siblings, 1 reply; 18+ messages in thread
From: Hans-Peter Nilsson @ 2014-03-01 11:27 UTC (permalink / raw)
  To: Yuri Gribov
  Cc: Yury Gribov, nick clifton, Will Newton, binutils, Viacheslav Garbuzov

On Fri, 28 Feb 2014, Yuri Gribov wrote:
> > but I don't think I need a separate
> > test at this end for the same target?
>
> True, just wanted to be sure.
>
> > Still, yes it worked here
> > too, thanks.
>
> Could you commit this fix then? I don't have write access.

Seeing that this was due to your earlier approved patch, this
update was committed on your behalf as obvious with this
ChangeLog entry:
	* ld-arm/long-plt-format.d, ld-arm/arm-elf.exp: Adjust for arm-eabi.

Nick, is this a good time to consider Yuri for
write(-after-approval) access?

brgds, H-P

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM
  2014-03-01 11:27                       ` Hans-Peter Nilsson
@ 2014-03-02 16:10                         ` Nicholas Clifton
  0 siblings, 0 replies; 18+ messages in thread
From: Nicholas Clifton @ 2014-03-02 16:10 UTC (permalink / raw)
  To: Hans-Peter Nilsson, Yuri Gribov
  Cc: Yury Gribov, Will Newton, binutils, Viacheslav Garbuzov


> Seeing that this was due to your earlier approved patch, this
> update was committed on your behalf as obvious with this
> ChangeLog entry:
> 	* ld-arm/long-plt-format.d, ld-arm/arm-elf.exp: Adjust for arm-eabi.
>
> Nick, is this a good time to consider Yuri for
> write(-after-approval) access?

It certainly is.  Yuri - assuming that this is OK with you, please could 
you fill out the form at:

http://sourceware.org/cgi-bin/pdw/ps_form.cgi

Use my name as approver.

Cheers
   Nick


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-03-02 16:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-07 10:16 [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM Yury Gribov
2014-02-10  8:32 ` Will Newton
2014-02-10 11:52   ` Yury Gribov
2014-02-17  6:39     ` [PATCH/ARM][PING] " Yury Gribov
2014-02-24 15:09       ` [PATCH/ARM][PING^2] " Yury Gribov
2014-02-21 14:24     ` [RFC][PATCH] " nick clifton
2014-02-24 15:07       ` Yury Gribov
2014-02-25  9:02         ` nick clifton
2014-02-27 12:53           ` Yury Gribov
2014-02-27 14:42             ` nick clifton
2014-02-28  5:53               ` Hans-Peter Nilsson
2014-02-28  6:15                 ` Yury Gribov
2014-02-28 19:40                   ` Hans-Peter Nilsson
2014-02-28 19:57                     ` Yuri Gribov
2014-03-01 11:27                       ` Hans-Peter Nilsson
2014-03-02 16:10                         ` Nicholas Clifton
2014-02-25 16:46         ` Richard Earnshaw
2014-02-25 18:01           ` Yuri Gribov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).