summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-08-31 12:48:37 +0930
committerAlan Modra <amodra@gmail.com>2017-09-19 14:39:48 +0930
commit3bf3f89d9d6f3a09def722d010695c35bffb4a48 (patch)
tree4775a211df945d724f178b67e30eefd950489910
parent8fd7cca5b0ed5a2f2099428586359f5cdff2063d (diff)
downloadbinutils-gdb-3bf3f89d9d6f3a09def722d010695c35bffb4a48.tar.gz
PR22048, Incorrect .eh_frame section in libc.so
PR 21441 PR 22048 * elflink.c (bfd_elf_discard_info): Don't pad embedded zero terminators. (cherry picked from commit af471f828cc74d65b50a7531ba2c69522266cfe9)
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elflink.c25
2 files changed, 22 insertions, 10 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 73377b91733..268f187f56b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2017-08-31 Alan Modra <amodra@gmail.com>
+
+ PR 21441
+ PR 22048
+ * elflink.c (bfd_elf_discard_info): Don't pad embedded zero
+ terminators.
+
2017-08-14 Alan Modra <amodra@gmail.com>
PR 21441
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 6bab097b057..d02aff97413 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -13873,17 +13873,22 @@ bfd_elf_discard_info (bfd *output_bfd, struct bfd_link_info *info)
/* Any prior sections must pad the last FDE out to the
output section alignment. Otherwise we might have zero
padding between sections, which would be seen as a
- terminator. */
+ terminator. If there is a terminator in the middle of
+ FDEs, don't increase its size as that will write bogus
+ data of whatever was after the terminator in the input
+ file, to the output file. */
for (; i != NULL; i = i->map_tail.s)
- {
- bfd_size_type size = (i->size + eh_alignment - 1) & -eh_alignment;
- if (i->size != size)
- {
- i->size = size;
- changed = 1;
- eh_changed = 1;
- }
- }
+ if (i->size != 4)
+ {
+ bfd_size_type size
+ = (i->size + eh_alignment - 1) & -eh_alignment;
+ if (i->size != size)
+ {
+ i->size = size;
+ changed = 1;
+ eh_changed = 1;
+ }
+ }
}
if (eh_changed)
elf_link_hash_traverse (elf_hash_table (info),