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] PR binutils/16317: Set SHF_INFO_LINK bit for SHT_REL/SHT_RELA sections sections


On Wed, Dec 11, 2013 at 10:18:42AM -0800, H.J. Lu wrote:
> Hi,
> 
> This patch adds SHF_INFO_LINK to SHT_RELA/SHT_REL sections generated
> by ld.  It makes ld behaves the same as gold.  OK to install?
> 

Turns out we should set the HF_INFO_LINK bit for SHT_RELA/SHT_REL
sections only when setting the sh_info field.  Here is the new
patch.  Tested on Linux/x86 and Linux/x86-64. OK for trunk?

Thanks.


H.J.
---
bfd/

2013-12-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/16317
	* elf.c (assign_section_numbers): Set the SHF_INFO_LINK bit for
	SHT_REL/SHT_RELA sections when setting the sh_info field.

ld/testsuite/

2013-12-11  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/16317
	* ld-elf/linkinfo.s: New file.
	* ld-elf/linkinfo1.d: Likewise.
	* ld-elf/linkinfo2.d: Likewise.
index 8df38ee..82c5e78 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3162,7 +3162,10 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
 	    name += 5;
 	  s = bfd_get_section_by_name (abfd, name);
 	  if (s != NULL)
-	    d->this_hdr.sh_info = elf_section_data (s)->this_idx;
+	    {
+	      d->this_hdr.sh_info = elf_section_data (s)->this_idx;
+	      d->this_hdr.sh_flags |= SHF_INFO_LINK;
+	    }
 	  break;
 
 	case SHT_STRTAB:
diff --git a/ld/testsuite/ld-elf/linkinfo.s b/ld/testsuite/ld-elf/linkinfo.s
new file mode 100644
index 0000000..dadda31
--- /dev/null
+++ b/ld/testsuite/ld-elf/linkinfo.s
@@ -0,0 +1,2 @@
+	.text
+	call	foo@PLT
diff --git a/ld/testsuite/ld-elf/linkinfo1.d b/ld/testsuite/ld-elf/linkinfo1.d
new file mode 100644
index 0000000..2b3463f
--- /dev/null
+++ b/ld/testsuite/ld-elf/linkinfo1.d
@@ -0,0 +1,8 @@
+#source: linkinfo.s
+#ld: -shared
+#readelf: -SW
+#target: x86_64-* i?86-*
+
+#...
+  \[[ 0-9]+\] \.rel[a]?\.plt[ \t]+REL[A]+[ \t][ \t0-9a-f]+AI[ \t0-9a-f]+
+#pass
diff --git a/ld/testsuite/ld-elf/linkinfo2.d b/ld/testsuite/ld-elf/linkinfo2.d
new file mode 100644
index 0000000..aeae6f8
--- /dev/null
+++ b/ld/testsuite/ld-elf/linkinfo2.d
@@ -0,0 +1,9 @@
+#source: linkinfo.s
+#ld: -shared
+#objcopy_linked_file: --strip-debug
+#readelf: -SW
+#target: x86_64-* i?86-*
+
+#...
+  \[[ 0-9]+\] \.rel[a]?\.plt[ \t]+REL[A]+[ \t][ \t0-9a-f]+AI[ \t0-9a-f]+
+#pass
-- 
1.8.3.1


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