Skip to content

Commit 04f981e

Browse files
author
Fabian Giesen
committed
output/elf: Don't set data symbol type/size in ABS sections
I'm dealing with a FreeBSD-derived embedded target that ends up showing such symbols (which is mainly NASM struct definitions) in backtraces after calling NULL function pointers, since these symbols _are_ technically covering bytes around address zero. Needless to say, this is extremely confusing and generates nonsensical bug reports. (Essentially, random unrelated crashes get cross-referenced to a random ASM struct, whatever the linker picked for address 0). These symbols are already a bit strange to begin with (they're purely an artifact of how NASM happens to implement structs), leaving their sizes at 0 seems reasonable. Signed-off-by: Fabian Giesen <fabian.giesen@epicgames.com>
1 parent 3aebb20 commit 04f981e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

output/outelf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,11 @@ static void debug_typevalue(int32_t type)
26962696
stype = STT_NOTYPE;
26972697
break;
26982698
}
2699-
if (stype == STT_OBJECT && lastsym && !lastsym->type) {
2699+
/* Set type and size info on most recently seen symbol if we haven't set it already.
2700+
But avoid setting size info on object (data) symbols in absolute sections (which
2701+
is primarily structs); some environments get confused with non-zero-extent absolute
2702+
object symbols and end up showing them in backtraces for NULL fn pointer calls. */
2703+
if (stype == STT_OBJECT && lastsym && !lastsym->type && lastsym->section != XSHN_ABS) {
27002704
lastsym->size = ssize;
27012705
lastsym->type = stype;
27022706
}

0 commit comments

Comments
 (0)