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.
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.
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.
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.
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.