diff options
author | Christian Eggers <ceggers@gmx.de> | 2019-03-10 19:21:57 +0100 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-03-13 13:29:35 +1030 |
commit | 145c4477d239fef4e31a457ff8a1ba7153e9a448 (patch) | |
tree | cbd268da0c41af0f7b82a96f257322e17e6c4071 /gas | |
parent | 5c4e5fe61bb00395f697a928524da1e94087c677 (diff) | |
download | gdb-145c4477d239fef4e31a457ff8a1ba7153e9a448.zip gdb-145c4477d239fef4e31a457ff8a1ba7153e9a448.tar.gz gdb-145c4477d239fef4e31a457ff8a1ba7153e9a448.tar.bz2 |
dwarf2: Pad size of .debug_line section.
As all dwarf debug information is organized in octets, the size of all
dwarf sections must be aligned to OCTETS_PER_BYTE. Most DWARF sections
meet this requirement, only the .debug_line section can reach an
arbitrary octet size.
In order to align the size to a multiple of OCTETS_PER_BYTE, the section
is padded with "nop" statements at the end.
* dwarf2dbg.c (out_debug_line): Pad size of .debug_line section.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/ChangeLog | 4 | ||||
-rw-r--r-- | gas/dwarf2dbg.c | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 368a73c..5b20974 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,9 @@ 2019-03-13 Christian Eggers <ceggers@gmx.de> + * dwarf2dbg.c (out_debug_line): Pad size of .debug_line section. + +2019-03-13 Christian Eggers <ceggers@gmx.de> + * dwarf2dbg.c (out_debug_str): Use octets for .debug_string pointers. 2019-03-13 Christian Eggers <ceggers@gmx.de> diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index d469138..0b7b78c 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -1787,6 +1787,7 @@ out_debug_line (segT line_seg) symbolS *line_end; struct line_seg *s; int sizeof_offset; + addressT section_end, section_end_aligned; memset (&exp, 0, sizeof exp); sizeof_offset = out_header (line_seg, &exp); @@ -1848,6 +1849,16 @@ out_debug_line (segT line_seg) in the DWARF Line Number header. */ subseg_set (subseg_get (".debug_line_end", FALSE), 0); + /* Pad size of .debug_line section to a multiple of OCTETS_PER_BYTE. + Simply sizing the section in md_section_align() is not sufficient, + also the size field in the .debug_line header must be a multiple + of OCTETS_PER_BYTE. Not doing so will introduce gaps within the + .debug_line sections after linking. */ + section_end = frag_now_fix_octets (); + section_end_aligned = (section_end + OCTETS_PER_BYTE - 1) & -OCTETS_PER_BYTE; + for ( ; section_end != section_end_aligned; section_end++) + out_inc_line_addr (0, 0); /* NOP */ + symbol_set_value_now_octets (line_end); } |