aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2013-12-19 11:34:47 -0800
committerH.J. Lu <hjl.tools@gmail.com>2013-12-19 11:34:47 -0800
commit9ef5d938819dff73d7640a2654b07df64670d7f9 (patch)
tree035e8760ec659165e1dc2d2665604c02d3a85f33
parentfa8761a3e0d999ada63194291ddf9b308a8d8276 (diff)
downloadfsf-binutils-gdb-9ef5d938819dff73d7640a2654b07df64670d7f9.zip
fsf-binutils-gdb-9ef5d938819dff73d7640a2654b07df64670d7f9.tar.gz
fsf-binutils-gdb-9ef5d938819dff73d7640a2654b07df64670d7f9.tar.bz2
Set SHF_INFO_LINK bit for SHT_REL/SHT_RELA sections
It is a good pratice to set the SHF_INFO_LINK bit when the sh_info field represents a section header index. bfd/ 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. binutils/testsuite/ PR binutils/16317 * binutils-all/readelf.s: Updated. * binutils-all/readelf.s-64: Likewise. ld/testsuite/ PR binutils/16317 * ld-elf/linkinfo1.s: New file. * ld-elf/linkinfo1a.d: Likewise. * ld-elf/linkinfo1b.d: Likewise.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf.c7
-rw-r--r--binutils/testsuite/ChangeLog6
-rw-r--r--binutils/testsuite/binutils-all/readelf.s2
-rw-r--r--binutils/testsuite/binutils-all/readelf.s-642
-rw-r--r--ld/testsuite/ChangeLog7
-rw-r--r--ld/testsuite/ld-elf/linkinfo1.s2
-rw-r--r--ld/testsuite/ld-elf/linkinfo1a.d8
-rw-r--r--ld/testsuite/ld-elf/linkinfo1b.d9
9 files changed, 46 insertions, 3 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 95355fc..70c7e72 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-19 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.
+
2013-12-19 Pierre Muller <muller@sourceware.org>
* peXXigen.c (rsrc_cmp): Fix unused variable warning.
diff --git a/bfd/elf.c b/bfd/elf.c
index b589e60..59b1d4b 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -3075,11 +3075,13 @@ assign_section_numbers (bfd *abfd, struct bfd_link_info *link_info)
{
d->rel.hdr->sh_link = elf_onesymtab (abfd);
d->rel.hdr->sh_info = d->this_idx;
+ d->rel.hdr->sh_flags |= SHF_INFO_LINK;
}
if (d->rela.idx != 0)
{
d->rela.hdr->sh_link = elf_onesymtab (abfd);
d->rela.hdr->sh_info = d->this_idx;
+ d->rela.hdr->sh_flags |= SHF_INFO_LINK;
}
/* We need to set up sh_link for SHF_LINK_ORDER. */
@@ -3166,7 +3168,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/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog
index 1023526..a1e6724 100644
--- a/binutils/testsuite/ChangeLog
+++ b/binutils/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/16317
+ * binutils-all/readelf.s: Updated.
+ * binutils-all/readelf.s-64: Likewise.
+
2013-12-13 Kuan-Lin Chen <kuanlinchentw@gmail.com>
Wei-Cheng Wang <cole945@gmail.com>
diff --git a/binutils/testsuite/binutils-all/readelf.s b/binutils/testsuite/binutils-all/readelf.s
index 22fb5d1..303e0c7 100644
--- a/binutils/testsuite/binutils-all/readelf.s
+++ b/binutils/testsuite/binutils-all/readelf.s
@@ -6,7 +6,7 @@ Section Headers:
# On the normal MIPS systems, sections must be aligned to 16 byte
# boundaries. On IA64, text sections are aligned to 16 byte boundaries.
+\[ 1\] .text +PROGBITS +00000000 0000(34|40) 0000(08|10) 00 +AX +0 +0 +(.|..)
- +\[ 2\] .rel.+text +REL. +0+ 0+.* 0000.. 0. +. +1 +4
+ +\[ 2\] .rel.+text +REL. +0+ 0+.* 0000.. 0. +I +. +1 +4
# MIPS targets put .rela.text here.
#...
+\[ .\] .data +PROGBITS +00000000 0000(3c|48|50) 0000(04|10) 00 +WA +0 +0 +(.|..)
diff --git a/binutils/testsuite/binutils-all/readelf.s-64 b/binutils/testsuite/binutils-all/readelf.s-64
index ec31f3f..2e05d68 100644
--- a/binutils/testsuite/binutils-all/readelf.s-64
+++ b/binutils/testsuite/binutils-all/readelf.s-64
@@ -8,7 +8,7 @@ Section Headers:
+\[ 1\] .text +PROGBITS +0000000000000000 +00000040
+00000000000000.. +0000000000000000 +AX +0 +0 +.*
+\[ 2\] .rel.+text +REL. +0+ +0+.*
- +000000000000001. +000000000000001. +. +1 +8
+ +000000000000001. +000000000000001. +I +. +1 +8
+\[ 3\] .data +PROGBITS +0000000000000000 +000000(48|50)
+000000000000000[48] +0000000000000000 +WA +0 +0 +.*
+\[ 4\] .bss +NOBITS +0000000000000000 +000000(4c|50|54|58)
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index f7e6e58..519c2cd 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/16317
+ * ld-elf/linkinfo1.s: New file.
+ * ld-elf/linkinfo1a.d: Likewise.
+ * ld-elf/linkinfo1b.d: Likewise.
+
2013-12-18 Vidya Praveen <vidyapraveen@arm.com>
* lib/ld-lib.exp (check_lto_available): Support cflags, ldflags and
diff --git a/ld/testsuite/ld-elf/linkinfo1.s b/ld/testsuite/ld-elf/linkinfo1.s
new file mode 100644
index 0000000..dadda31
--- /dev/null
+++ b/ld/testsuite/ld-elf/linkinfo1.s
@@ -0,0 +1,2 @@
+ .text
+ call foo@PLT
diff --git a/ld/testsuite/ld-elf/linkinfo1a.d b/ld/testsuite/ld-elf/linkinfo1a.d
new file mode 100644
index 0000000..8c6fb71
--- /dev/null
+++ b/ld/testsuite/ld-elf/linkinfo1a.d
@@ -0,0 +1,8 @@
+#source: linkinfo1.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/linkinfo1b.d b/ld/testsuite/ld-elf/linkinfo1b.d
new file mode 100644
index 0000000..cc3aaed
--- /dev/null
+++ b/ld/testsuite/ld-elf/linkinfo1b.d
@@ -0,0 +1,9 @@
+#source: linkinfo1.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