kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

04-disasm-stripped-segment.sh (935B)


      1 # Golden: `-d` over a *fully section-stripped* aarch64 ELF executable. We
      2 # derive the fixture from the committed exec.elf by zeroing the section-header
      3 # table fields (e_shoff / e_shnum / e_shstrndx) — the same shape objcopy
      4 # --strip-sections / packers produce. With no section table, objdump's normal
      5 # section-driven disassembly finds nothing, so this locks in the fallback:
      6 # disassemble the executable PT_LOAD segment directly, using its vaddr as the
      7 # base (note the `bl 0x4041xx` targets resolve against that base, not 0). The
      8 # stripping is format-agnostic ELF-header surgery; the disasm path is not.
      9 python3 - "$(dirname "$0")/exec.elf" exec.stripped.elf <<'PY'
     10 import sys
     11 data = bytearray(open(sys.argv[1], "rb").read())
     12 data[0x28:0x30] = b"\x00" * 8  # e_shoff
     13 data[0x3c:0x3e] = b"\x00" * 2  # e_shnum
     14 data[0x3e:0x40] = b"\x00" * 2  # e_shstrndx
     15 open(sys.argv[2], "wb").write(data)
     16 PY
     17 "$KIT" objdump -d exec.stripped.elf