[nasm:nasm-2.15.xx] dwarf: don't emit a dummy .debug_loc section
nasm-bot for H. Peter Anvin (Intel)
hpa at zytor.com
Fri Jun 26 15:24:04 PDT 2020
Commit-ID: eb571a3ac387a721d52fdab448da7c8768bdaa18
Gitweb: http://repo.or.cz/w/nasm.git?a=commitdiff;h=eb571a3ac387a721d52fdab448da7c8768bdaa18
Author: H. Peter Anvin (Intel) <hpa at zytor.com>
AuthorDate: Fri, 26 Jun 2020 15:22:26 -0700
Committer: H. Peter Anvin (Intel) <hpa at zytor.com>
CommitDate: Fri, 26 Jun 2020 15:22:26 -0700
dwarf: don't emit a dummy .debug_loc section
It seems DWARF parsers get really snippy about a section which only
contains an end token. Instead, leave unused sections empty. Already
did that with .debug_frame, do it with .debug_loc too.
Signed-off-by: H. Peter Anvin (Intel) <hpa at zytor.com>
---
output/outelf.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/output/outelf.c b/output/outelf.c
index 8af0f120..911a8529 100644
--- a/output/outelf.c
+++ b/output/outelf.c
@@ -3438,29 +3438,31 @@ static void dwarf_generate(void)
saa_rnbytes(plinesrel, pbuf, saalen);
saa_free(plinesrel);
- /* build frame section */
+ /* build .debug_frame section */
if (0) {
- /* This only applies if there is at least one frame defined */
framelen = 4;
framebuf = pbuf = nasm_malloc(framelen);
WRITELONG(pbuf,framelen-4); /* initial length */
} else {
+ /* Leave .debug_frame empty if not used! */
framelen = 0;
}
- /* build loc section */
- loclen = 16;
- locbuf = pbuf = nasm_malloc(loclen);
- if (is_elf32()) {
- WRITELONG(pbuf,0); /* null beginning offset */
- WRITELONG(pbuf,0); /* null ending offset */
- } else if (is_elfx32()) {
- WRITELONG(pbuf,0); /* null beginning offset */
- WRITELONG(pbuf,0); /* null ending offset */
+ /* build .debug_loc section */
+ if (0) {
+ loclen = 16;
+ locbuf = pbuf = nasm_malloc(loclen);
+ if (is_elf32() || is_elfx32()) {
+ WRITELONG(pbuf,0); /* null beginning offset */
+ WRITELONG(pbuf,0); /* null ending offset */
+ } else {
+ nasm_assert(is_elf64());
+ WRITEDLONG(pbuf,0); /* null beginning offset */
+ WRITEDLONG(pbuf,0); /* null ending offset */
+ }
} else {
- nasm_assert(is_elf64());
- WRITEDLONG(pbuf,0); /* null beginning offset */
- WRITEDLONG(pbuf,0); /* null ending offset */
+ /* Leave .debug_frame empty if not used! */
+ loclen = 0;
}
}
More information about the Nasm-commits
mailing list