ddn.elf.test_parsers

Output parser utilities for external ELF tools.

This module provides parsers for output from GNU binutils tools like readelf, nm, and objdump. These parsers enable automated comparison of library-generated ELF files against verified tool output.

Types 5

Parsed ELF header from readelf -h output.

Fields
string elfClassELF class (32-bit or 64-bit)
string dataEncodingData encoding (little endian or big endian)
string elfVersionVersion
string osAbiOS/ABI
string abiVersionABI version
string typeELF type (REL, EXEC, DYN, etc.)
string machineMachine architecture
ulong entryPointEntry point address
ulong phOffsetStart of program headers (bytes into file)
ulong shOffsetStart of section headers (bytes into file)
ulong flagsFlags
uint ehSizeSize of this header (bytes)
uint phEntSizeSize of program headers (bytes)
uint phNumNumber of program headers
uint shEntSizeSize of section headers (bytes)
uint shNumNumber of section headers
uint shStrNdxSection header string table index

Parsed section header from readelf -S output.

Fields
uint numberSection number
string nameSection name
string typeSection type
ulong addressAddress
ulong offsetOffset
ulong sizeSize
ulong entSizeEntry size
string flagsFlags (as string, e.g., "WA", "AX", etc.)
uint linkLink section index
uint infoInfo
ulong alignmentAlignment

Parsed symbol from readelf -s output.

Fields
uint numberSymbol number
ulong valueSymbol value (address)
ulong sizeSymbol size
string typeSymbol type (FUNC, OBJECT, NOTYPE, etc.)
string bindSymbol binding (LOCAL, GLOBAL, WEAK, etc.)
string visibilitySymbol visibility (DEFAULT, HIDDEN, INTERNAL, etc.)
string ndxSection index (number or "UND", "ABS", "COM")
string nameSymbol name

Parsed segment/program header from readelf -l output.

Fields
string typeSegment type (LOAD, DYNAMIC, INTERP, etc.)
ulong offsetSegment offset
ulong vaddrVirtual address
ulong paddrPhysical address
ulong fileSizeFile size
ulong memSizeMemory size
string flagsFlags (R, W, X, or combinations)
ulong alignmentAlignment
string[] sectionsSections in this segment (from section mapping)
structNmSymbol

Parsed symbol from nm output.

Fields
ulong valueSymbol value (address)
string typeSymbol type (T, U, D, B, W, etc.)
string nameSymbol name

Functions 12

fnReadelfHeader parseReadelfHeader(string output)Parser for readelf -h output.
fnReadelfSection[] parseReadelfSections(string output)Parser for readelf -S output.
fnReadelfSymbol[] parseReadelfSymbols(string output)Parser for readelf -s output.
fnReadelfSegment[] parseReadelfSegments(string output)Parser for readelf -l output.
fnNmSymbol[] parseNmOutput(string output)Parser for nm output.
fnulong parseHexUlong(string hexStr)Parse a hexadecimal string to an unsigned long.
fnulong parseUlong(string decStr)Parse a decimal string to an unsigned long.
private fnuint safeParseUint(string s)Safely parse a string as an unsigned int.
private fnulong safeParseHex(string s)Safely parse a string as a hexadecimal ulong.
fnbool compareHeaders(const ref ReadelfHeader expected, const ref ReadelfHeader actual)Compare two ReadelfHeader structs.
fnbool compareSections(const ref ReadelfSection[] expected, const ref ReadelfSection[] actual)Compare two ReadelfSection arrays.
fnbool compareSymbols(const ref ReadelfSymbol[] expected, const ref ReadelfSymbol[] actual)Compare two ReadelfSymbol arrays.