summaryrefslogtreecommitdiff
path: root/output
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-26 15:22:26 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-26 15:22:26 -0700
commiteb571a3ac387a721d52fdab448da7c8768bdaa18 (patch)
tree29943f2b8658bdd40f816ac9c5631394c82bfea0 /output
parent241697306cf0e9ee87aac4f7fe0946f436db7bfa (diff)
downloadnasm-eb571a3ac387a721d52fdab448da7c8768bdaa18.tar.gz
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@zytor.com>
Diffstat (limited to 'output')
-rw-r--r--output/outelf.c30
1 files 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;
}
}