139 Commits

Author SHA1 Message Date
Philip Craig 3e9d3a47f6 readobj/elf: handle relocation sections with link 0 (#800)
This is valid when none of the relocations use symbols.
2025-08-07 11:50:51 +10:00
Mateusz Mikuła 31a232f3c7 elf: Add constants for GNU SFrame (#799) 2025-08-06 14:15:12 +10:00
Philip Craig 17b94ac511 Fix clippy warnings
Allow clippy::uninlined_format_args for now since fixing it is a lot of noise.
2025-08-01 17:21:28 +10:00
Philip Craig 5fc89663a1 read/elf: various CREL fixes (#784)
- The delta offset and flags combined may be larger than u64,
  so handle the first byte separately.
- Use wrapping arithmetic.
- Change `Crel::r_sym` and `Crel::r_type` to u32.
- Add `Crel::symbol()`.
- Fuse `CrelIterator` on error.
- Replace `ElfRelaIterator` with `ElfRelocationIterator` which returns
  `Crel`. This avoid the need to byteswap the `Crel`, and thus avoids
  the use of `Endian::default` (which may not match the file).
- Add test outputs.
2025-07-02 11:01:25 +10:00
Martin Liška d65992b858 Add support for experimental CREL relocation format (#782)
The format was suggested here:
https://groups.google.com/g/generic-abi/c/ppkaxtLb0P0/m/awgqZ_1CBAAJ
and become part of the LLVM toolchain since release 19, and it's
used by default in the Chromium build system. Recently, the Mold
linker added support for the format as well.
2025-06-30 17:30:34 +10:00
Luke Street 16ff70aa6f Support big-endian PowerPC COFF (#783)
Also adds PPC COFF magic to File::parse
2025-06-30 16:23:06 +10:00
Martin Liška e32d8830c5 Add EF_RISCV_RV64ILP32 constant (#779) 2025-06-19 12:13:33 +10:00
Philip Craig 8130a962a0 read/macho: implement dyld slide version 2 and 3 2025-06-02 12:46:26 +10:00
Philip Craig 5c9425a15d read/macho: add None variant to DyldCacheSlideInfoSlice
This takes the place of wrapping it in Option.
Also shorten its name.
2025-06-02 12:46:26 +10:00
Philip Craig 1fbd4a1f6c readobj/macho: print more dyld cache headers
Print the cache header and mappings for every subcache, instead
of only the primary cache file.

Also print the mapping slide information headers.
2025-06-02 12:46:26 +10:00
Philip Craig e8fb5ee18a read/macho: simplify DyldCacheMappingSlice
Delete fields that are duplicates of information in DyldCache and
DyldFile. This makes the enum similar to DyldSubCacheSlice.
2025-06-02 12:46:26 +10:00
Philip Craig fd0e96500a readobj/macho: fix symbol table in dyld cache
The symbol table data is stored in the linkedit segment,
but that segment may be in a different subcache from the
one containing the image headers. This occurs for the
arm dyld cache in macOS 13.

MachOFile::parse_dyld_cache_image already handled this
correctly, but readobj doesn't use that.
2025-06-02 12:46:26 +10:00
hev 013fac75da elf: Update LoongArch relocation types per LoongArch ABI v2.30 (#773) 2025-05-25 13:58:51 +10:00
Philip Craig d1091fbb68 read/coff: fix has_aux_function for weak externals (#772)
has_aux_function previously matched weak externals too, resulting in
a wrong interpretation of their auxiliary symbol in the readobj
example.

Removed use of `else` for checking auxiliary symbols in readobj
so that it is more apparent when these are wrong.

Also add objdump and readobj test output for weak externals.
2025-05-25 13:55:00 +10:00
Philip Craig 61474b7de8 read/wasm: support symbol table in linking section 2025-04-25 16:29:20 +10:00
Philip Craig 49290f5825 wasm: add object file test case 2025-04-25 16:29:20 +10:00
Martin Liška 6848ca0a50 elf: Add missing R_RISCV_TLSDESC dynamic relocation (#768) 2025-04-24 20:48:40 +10:00
Martin Liška 3bd26eb05e Add R_RISCV_GOT32_PCREL relocation (#767)
The relocation reuses an existing ID that was removed in the spec and later on reused.
2025-04-24 20:45:09 +10:00
Philip Craig acffa26020 readobj: fix handling of dyld subcache images 2025-01-17 14:05:25 +10:00
Philip Craig b2ce28d471 read/macho: add DyldCache::subcache_suffixes 2025-01-17 14:05:25 +10:00
Sam Collinson 4f55dd7301 read/macho: add iterators for mappings and relocations in dyld cache (#738) 2025-01-04 15:45:13 +10:00
Philip Craig ab8f993cd6 read/elf: add SHT_RELR support 2024-12-01 13:52:34 +10:00
Philip Craig 90ef466011 Add testfile for ELF SHT_RELR section 2024-12-01 13:52:34 +10:00
Alisa Sireneva 61dc7b00e0 elf: Add SHT_LLVM_DEPENDENT_LIBRARIES (#737) 2024-10-18 13:37:04 +10:00
Martin Liška 3872c29072 elf: add 2 section flag constants (#720) 2024-08-19 15:51:22 +10:00