BR 3392417: always end the DWARF .debug_abbrev section with a null

The DWARF spec specifies that the .debug_abbrev section always should
end with a null byte.  Existing tools don't seem to care, but some
issue a warning, and it is invalid according to spec.

Reported-by: Darren Sylvain <sylvaindarren@gmail.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2017-09-27 15:05:03 -07:00
parent f91dc2033d
commit e4303ee7f1
2 changed files with 4 additions and 0 deletions

View File

@ -3138,6 +3138,8 @@ static void dwarf_generate(void)
saa_write8(pabbrev,DW_AT_frame_base);
saa_write8(pabbrev,DW_FORM_data4);
saa_write16(pabbrev,0); /* end of entry */
/* Terminal zero entry */
saa_write8(paddrev,0);
abbrevlen = saalen = pabbrev->datalen;
abbrevbuf = pbuf = nasm_malloc(saalen);
saa_rnbytes(pabbrev, pbuf, saalen);

View File

@ -2046,6 +2046,8 @@ static void macho_dbg_generate(void)
saa_write16(p_abbrev, DW_END_default);
saa_write8(p_abbrev, 0); /* Terminal zero entry */
saa_len = p_abbrev->datalen;
p_buf = nasm_malloc(saa_len);