Skip to content

Commit 67f61dc

Browse files
committed
fix misformed elfclass32 bug
1 parent ced3eb0 commit 67f61dc

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

docs/add-symbol-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ However, when I use qemu-user to debug an aarch32 binary and make an aarch32 fil
9797
```bash
9898
zig cc main.c --target=arm-linux-musleabi -o mainarm -static
9999
llvm-strip mainarm
100-
qemu-user -g 1234 mainarm
100+
qemu-arm -g 1234 mainarm
101101

102102
gdb mainarm
103103
gdb> tar rem :1234

niche_elf/builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,9 @@ def add_symbols(self, symbols: list[Symbol]) -> None:
149149
# FIXME: Check does GDB actually look at this?
150150
sh_info=1,
151151
sh_addralign=8,
152-
sh_entsize=24,
152+
# Fucking crucial, or you'll fail a check in GDB's bfd/elf.c:bfd_section_from_shdr
153+
# if (hdr->sh_entsize != bed->s->sizeof_sym)
154+
sh_entsize=ctypes.sizeof(self.ElfSym),
153155
sh_offset=-1,
154156
),
155157
)

niche_elf/elf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def __init__(self, textbase: int) -> None:
2727
# For some reason, this works for me even when debugging other architectures (e.g. aarch32),
2828
# and when debugging from different host architectures (e.g. aarch64). So I'm pinning it to
2929
# x86_64 with ELFCLASS64 (which is what ptrbits controls) until we encounter some issues.
30-
# Important to note: ELFCLASS32 does not work at all for me for some reason. And ELFCLASS64
31-
# with zig_target_arch set to a more obscure architecture also doesn't work.
30+
# Important to note: ELFCLASS64 with zig_target_arch set to a more obscure architecture
31+
# doesn't work.
3232
# My stupid chungus life.
3333
ptrbits = 64
3434
zig_target_arch = "x86_64"

0 commit comments

Comments
 (0)