11 Commits

Author SHA1 Message Date
Philip Craig acffa26020 readobj: fix handling of dyld subcache images 2025-01-17 14:05:25 +10:00
Philip Craig 1119a2a1fe build/elf: add Builder (#618)
The Builder can be created from an existing ELF file, modified,
and then written out again.

Also add the `object-rewrite` crate which provides higher
level operations for modification. Use this to replace
the elfcopy example.
2024-03-01 18:52:56 +10:00
Philip Craig fb0d876a0b Fix clippy warnings (#636) 2024-02-23 17:43:09 +10:00
Philip Craig 789c859abb Allow generation of all output testfiles (#628)
Some of the output testfiles are only the partial output.
Extend the OBJECT_TESTFILES_UPDATE support to handle these too.

Also, reverse the derivation of filenames: now the input filename
is derived from the output filename. This allows us to detect
output files that don't have a corresponding input file.
2024-02-01 15:10:45 +10:00
Philip Craig 567edaf246 readobj: add command line options (#625) 2024-01-27 16:42:22 +10:00
Philip Craig 5d607b2a8d macho: add some objcopy tests (#583)
Currently only x86-64 and AArch64 work.

i386 and ARM are missing support for scattered relocations and
paired relocations.

Also add support for an environment variable called OBJECT_TESTFILES_UPDATE
which causes the tests to update the output files.
2023-10-25 12:09:43 +10:00
Philip Craig 1eb82ffa16 Change xcoff to be an unstable feature (#485)
The xcoff feature needs further work before being ready for release.

Also, the default resolver can be changed to "2" now that the MSRV is
at least 1.51. This works better with features in workspaces.
2022-11-20 14:44:41 +10:00
Xi Ruoyao b706982aa7 Skip wasm tests if the feature is not enabled (#437) 2022-05-24 22:32:00 +10:00
Markus Stange 4261d56e6f Add support for split dyld shared cache. (#398)
Fixes #358.

This adds support for the dyld cache format that is used on macOS 12 and
iOS 15. The cache is split over multiple files, with a "root" cache
and one or more subcaches, for example:

```
/System/Library/dyld/dyld_shared_cache_x86_64
/System/Library/dyld/dyld_shared_cache_x86_64.1
/System/Library/dyld/dyld_shared_cache_x86_64.2
/System/Library/dyld/dyld_shared_cache_x86_64.3
```

Additionally, on iOS, there is a separate .symbols subcache, which
contains local symbols.

Each file has a set of mappings. For each image in the cache, the
segments of that image can be distributed over multiple files: For
example, on macOS 12.0.1, the image for libsystem_malloc.dylib for the
arm64e architecture has its __TEXT segment in the root cache and the
__LINKEDIT segment in the .1 subcache - there's a single __LINKEDIT
segment which is shared between all images across both files. The
remaining libsystem_malloc.dylib segments are in the same file as the
__TEXT segment.

The DyldCache API now requires the data for all subcaches to be supplied
to the constructor.

The parse_at methods have been removed and been replaced with a
parse_dyld_cache_image method.

With this patch, the following command outputs correct symbols for
libsystem_malloc.dylib:

```
cargo run --release --bin objdump -- /System/Library/dyld/dyld_shared_cache_arm64e /usr/lib/system/libsystem_malloc.dylib
```

Support for local symbols is not implemented. But, as a first step,
DyldCache::parse requires the .symbols subcache to be supplied (if the
root cache expects one to be present) and checks that its UUID is correct.
MachOFile doesn't do anything with ilocalsym and nlocalsym yet, and we
don't yet have the struct definitions for dyld_cache_local_symbols_info
and dyld_cache_local_symbols_entry.
2021-11-27 15:12:52 +10:00
Philip Craig ad4e2924dd Add pe to write feature 2021-10-14 18:56:22 +10:00
Philip Craig e65f5a9660 Add initial ELF/PE/Wasm file tests 2021-08-26 12:24:52 +10:00