Add a short-data-directory PE and a large-common ELF object - #205
Conversation
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head
Rebuild, 2026-08-28, superseding the earlier note that the build scripts had not been rerun: Caveats: this repository has no test suite, so the record is header verification of the committed artifacts plus the load attempts above. Re-keyed 2026-08-29. The figures above were taken at head Re-keyed 2026-09-04. Head is now |
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Searching every ELF object under Before — neither header shape occurs anywhere in the repository: angr/binaries at the merge baseAfter — one object per shape, read back out of the committed files: with this change |
343eead to
c74d6f3
Compare
gcc -mcmodel=medium puts a common symbol larger than the large-data threshold at SHN_X86_64_LCOMMON (0xff02) rather than SHN_COMMON. That is a reserved processor-specific tag, not a section header table index, and cle subscripted the section list with it. No object in this repository had one, so cle test_elf_symbols.py retagged gzip.o with struct.pack_into instead. This is the real thing, 1.4 KB, with its source and build recipe beside it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
NumberOfRvaAndSizes may be smaller than the 16 directories the PE format
defines; EFI stub images commonly declare 6, and the trailing directories are
then absent. Every PE in this repository declares 16, so cle test_pe.py
rewrote printenv.exe with struct.pack_into to get a short one.
No linker will emit it: GNU ld, LLD, tcc, Zig, Go, Open Watcom wlink and EDK2
GenFw all write 16, and neither ld nor lld-link has a flag for it. Real EFI
stubs get there by writing the header in assembly and letting the assembler
count the entries, which is what the Linux kernel does in
arch/x86/boot/header.S and arch/arm64/kernel/efi-header.S. efi_header.S does
the same, deriving the field with
.long (section_table - .) / 8
so it follows from the directory entries actually declared rather than being
asserted; ld computes the rest of the layout from efi.lds. build.sh reads the
field back out of the built image and fails if it is not 6.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
c74d6f3 to
8790756
Compare
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
Problem
Two header shapes make a consumer index a table past its declared length, and this repository has neither. Searching every ELF and every PE under
tests/:Every PE image here declares sixteen data directories, and no symbol here uses a processor-specific reserved
st_shndx. So the arithmetic that assumes both cannot be tested against an input that breaks it.Root cause
Neither shape falls out of an ordinary build. No linker flag produces fewer than sixteen data directories — real firmware gets a short one by writing the header in assembly and letting the assembler count the entries — and a symbol only lands in the large-common area under
-mcmodel=mediumwith-fcommon, which gcc has not defaulted to since gcc 10.Fix
Add two objects, and nothing else.
tests/x86_64/efi_short_data_directory.efiis a UEFI application whose optional header declares six data directories:NumberOfRvaAndSizes6,SizeOfOptionalHeader160, which is 112 fixed PE32+ fields plus six eight-byte entries, so the short directory is real rather than padded.efi_header.Sderives the count as.long (section_table - .) / 8, the wayarch/x86/boot/header.Sdoes, and the build script reads the field back out of the linked image and asserts it.tests/x86_64/large_common.ocarriesbig_bufferwithst_shndx0xff02,SHN_X86_64_LCOMMON, produced by compiling an oversized common object rather than by retagging a symbol table. Sources and build scripts for both are intests_src.Testing
tests_src/pe_short_data_directory/build.shrebuilds the.efibyte for byte, sha256dd3d110220f9ab53653be746166f9b5a051b2a93c0998788843e8373a8cc37ab.tests_src/elf_large_common/build.shdoes not: under GCC 15.3.0 from nixpkgs it emits a 41-byte.textwhere the committed object's is 17, at every optimization level tried, so that script records how the fixture was made rather than reproducing it. The property the fixture exists for holds either way —readelf -sprintsbig_bufferasLARGE_COM. This repository has no suite of its own; angr/cle#732 is the consumer that exercises both.Validation: #205 (comment)
session: sharpen