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]

PATCH: Don't check relocations against reloc sections


Hi,

bfd_elf_final_link checks relocations against reloc sections and generates

 [ 4] .rela.plt         RELA            00000000000001e8 0001e8 000018 18   A  2   6  8
 [ 5] .rela.rela.plt    RELA            0000000000000000 000830 000000 18     15   4  8

The reloc_count field in reloc sections are used for book keeping and
there is no such a thing of relocations against reloc sections.  This
patch avoids checking relocations against reloc sections.  Tested it
on Linux/ia32 and Linux/x86-64.  OK for trunk?

Thanks.


H.J.
---
bfd/

2012-04-12  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13947
	* elflink.c (bfd_elf_final_link): Don't check relocations against
	reloc sections.

ld/testsuite/

2012-04-12  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/13947
	* ld-x86-64/x86-64.exp: Run pr13947.
	* ld-x86-64/pr13947.d: New file.
	* ld-x86-64/pr13947.s: Likewise.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 0ed5208..ceb033e 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -10370,6 +10370,15 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
   for (o = abfd->sections; o != NULL; o = o->next)
     {
       struct bfd_elf_section_data *esdo = elf_section_data (o);
+
+      if (esdo->this_hdr.sh_type == SHT_REL
+	  || esdo->this_hdr.sh_type == SHT_RELA)
+	{
+	  /* There should be no relocations against reloc sections.  */
+	  BFD_ASSERT (!(o->flags & SEC_RELOC) && o->reloc_count == 0);
+	  continue;
+	}
+
       o->reloc_count = 0;
 
       for (p = o->map_head.link_order; p != NULL; p = p->next)
diff --git a/ld/testsuite/ld-x86-64/pr13947.d b/ld/testsuite/ld-x86-64/pr13947.d
new file mode 100644
index 0000000..c8af34d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr13947.d
@@ -0,0 +1,7 @@
+#ld: -shared --emit-relocs
+#readelf: -S --wide
+
+#failif
+#...
+ +\[ [0-9]\] .rela.rela.plt +RELA +[0-9a-f]+ +[0-9a-f]+ 0+ +.*
+#...
diff --git a/ld/testsuite/ld-x86-64/pr13947.s b/ld/testsuite/ld-x86-64/pr13947.s
new file mode 100644
index 0000000..71928cb
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/pr13947.s
@@ -0,0 +1,5 @@
+	.text
+	.globl foo
+	.type foo, @function
+foo:
+	call bar@PLT
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index 963e8e7..27174d5 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -205,6 +205,7 @@ run_dump_test "nogot2"
 run_dump_test "discarded1"
 run_dump_test "pr12718"
 run_dump_test "pr12921"
+run_dump_test "pr13947"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return


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