aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2003-10-06 18:10:48 +0000
committerH.J. Lu <hjl.tools@gmail.com>2003-10-06 18:10:48 +0000
commit10cf14ea3d6263659b4e654ecea1a2af18e5626b (patch)
tree70e1b4411c6b2d0f9112488b4ef029966d68aa62 /bfd
parent4efdaa0dd761c87e9dd938353ca98e88c68a4dbb (diff)
downloadfsf-binutils-gdb-10cf14ea3d6263659b4e654ecea1a2af18e5626b.zip
fsf-binutils-gdb-10cf14ea3d6263659b4e654ecea1a2af18e5626b.tar.gz
fsf-binutils-gdb-10cf14ea3d6263659b4e654ecea1a2af18e5626b.tar.bz2
2003-10-06 H.J. Lu <hongjiu.lu@intel.com>
* elf-eh-frame.c (_bfd_elf_write_section_eh_frame): Pad the last CIE/FDE if needed.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf-eh-frame.c32
2 files changed, 37 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 77e9f87..45bb8e0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2003-10-06 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf-eh-frame.c (_bfd_elf_write_section_eh_frame): Pad the
+ last CIE/FDE if needed.
+
2003-10-06 Matt Thomas <matt@3am-software.com>
config.bfd: Move the hppa*-*-netbsd* case to the hppa*-*-linux* case.
diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c
index c71129e..c2f6b96 100644
--- a/bfd/elf-eh-frame.c
+++ b/bfd/elf-eh-frame.c
@@ -1026,6 +1026,38 @@ _bfd_elf_write_section_eh_frame (bfd *abfd,
and 3xDW_CFA_nop as pad */
p += 16;
}
+ else
+ {
+ unsigned int alignment = 1 << sec->alignment_power;
+ unsigned int pad = sec->_cooked_size % alignment;
+
+ if (pad)
+ {
+ /* Find the last CIE/FDE. */
+ for (i = sec_info->count - 1; i > 0; i--)
+ if (! sec_info->entry[i].removed)
+ break;
+
+ /* The size of the last CIE/FDE must be at least 4. */
+ if (sec_info->entry[i].removed
+ || sec_info->entry[i].size < 4)
+ abort ();
+
+ pad = alignment - pad;
+
+ buf = contents + sec_info->entry[i].new_offset;
+
+ /* Update length. */
+ sec_info->entry[i].size += pad;
+ bfd_put_32 (abfd, sec_info->entry[i].size - 4, buf);
+
+ /* Pad it with DW_CFA_nop */
+ memset (p, 0, pad);
+ p += pad;
+
+ sec->_cooked_size += pad;
+ }
+ }
BFD_ASSERT ((bfd_size_type) (p - contents) == sec->_cooked_size);