aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-08-07 10:28:42 -0700
committerH.J. Lu <hjl.tools@gmail.com>2015-08-07 10:35:58 -0700
commitd4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4 (patch)
tree95f22b0c72cd452bb7b2114d8e6d0a46f34ad42e /bfd
parentf12899e9f081bb857c96999386e64a4252c4a325 (diff)
downloadgdb-d4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4.zip
gdb-d4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4.tar.gz
gdb-d4ac1f878ecef58f1e4b4ff0cbfb4b475656eaf4.tar.bz2
Check sh_type/sh_flags/sh_addralign/sh_entsize when copying sh_link/sh_info
When copying the sh_link and sh_info fields in stripped section headers, we also check if the sh_type, sh_flags, /sh_addralign and sh_entsize fields of the output section match the output. Since --only-keep-debug turns all non-debug sections into SHT_NOBITS sections, the output SHT_NOBITS type matches any input type. bfd/ PR binutils/18785 * elf.c (_bfd_elf_copy_private_bfd_data): When copying the sh_link and sh_info fields in stripped section headers, we also check if the sh_type, sh_flags, /sh_addralign and sh_entsize fields of the output section match the output. Since --only-keep-debug turns all non-debug sections into SHT_NOBITS sections, the output SHT_NOBITS type matches any input type. binutils/testsuite/ PR binutils/18785 * binutils-all/objcopy.exp: Run strip-12. * binutils-all/strip-12.d: New file. * binutils-all/strip-12.s: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog10
-rw-r--r--bfd/elf.c9
2 files changed, 18 insertions, 1 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 36fae0e..c319f80 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,15 @@
2015-08-07 H.J. Lu <hongjiu.lu@intel.com>
+ PR binutils/18785
+ * elf.c (_bfd_elf_copy_private_bfd_data): When copying the
+ sh_link and sh_info fields in stripped section headers, we also
+ check if the sh_type, sh_flags, /sh_addralign and sh_entsize
+ fields of the output section match the output. Since
+ --only-keep-debug turns all non-debug sections into SHT_NOBITS
+ sections, the output SHT_NOBITS type matches any input type.
+
+2015-08-07 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/18720
* elflink.c (_bfd_elf_merge_symbol): Add a parameter to indicate
if the new symbol matches the existing one. The new hidden
diff --git a/bfd/elf.c b/bfd/elf.c
index 67e4240..9e401c8 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1233,7 +1233,14 @@ _bfd_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
{
Elf_Internal_Shdr * iheader = iheaders[j];
- if (iheader->sh_type != SHT_NOBITS
+ /* Since --only-keep-debug turns all non-debug sections
+ into SHT_NOBITS sections, the output SHT_NOBITS type
+ matches any input type. */
+ if ((oheader->sh_type == SHT_NOBITS
+ || oheader->sh_type == oheader->sh_type)
+ && iheader->sh_flags == oheader->sh_flags
+ && iheader->sh_addralign == oheader->sh_addralign
+ && iheader->sh_entsize == oheader->sh_entsize
&& iheader->sh_size == oheader->sh_size
&& iheader->sh_addr == oheader->sh_addr
&& (iheader->sh_info != oheader->sh_info