aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/CodeSignature.zig
AgeCommit message (Collapse)Author
2022-08-03macho: sync with zldJakub Konka
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24 https://github.com/kubkon/zld/commit/a2c32e972f8c5adfcda8ed2d99379ae868f59c24
2022-07-01macho: implement pruning of unused segments and sectionsJakub Konka
This is a prelude to a more elaborate work which will implement `-dead_strip` flag - garbage collection of unreachable atoms. Here, when sorting sections, we also check that the section is actually populated with some atoms, and if not, we exclude it from the final linked image. This can happen when we do not import any symbols from dynamic libraries in which case we will not be populating the stubs sections or the GOT table, implying we can skip allocating those sections. Furthermore, we also make a check that a segment is actually occupied too, with the exception of `__TEXT` segment which is non-optional given that it wraps the header and load commands and thus is required by the `dyld` to perform dynamic linking, and `__PAGEZERO` which is generally non-optional when the linked image is an executable. For any other segment, if its section count is zero, we mark it as dead and skip allocating it and generating a load command for it. This commit also includes some minor improvements to the linker such as refactoring of the segment allocating codepaths, skipping `__PAGEZERO` generation for dylibs, and skipping generation of zero-sized atoms for special symbols such as `__mh_execute_header` and `___dso_handle`. These special symbols are only allocated local and global symbol pair and their VM addresses is set to the start of the `__TEXT` segment, but no `Atom` is created, as it's not necessary given that they never carry any machine code. Finally, we now always force-link against `libSystem` which turns out to be required for `dyld` to properly handle `LC_MAIN` load command on older macOS versions such as 10.15.7.
2022-04-01macho: set CS_LINKER_SIGNED flag in code signature generated by zldJakub Konka
This way, if the user wants to use `codesign` (or other tool) they will not be forced to `-f` force signature update. This matches the behavior promoted by Apple's `ld64` linker.
2022-03-22macho: extend CodeSignature to accept entitlementsJakub Konka
With this change, we can now bake in entitlements into the binary. Additionally, I see this as the first step towards full code signature support which includes baking in Apple issued certificates for redistribution, etc.
2021-11-30allocgate: std Allocator interface refactorLee Cannon
2021-11-01Update ensureTotalCapacity to ensureTotalCapacityPrecise where it makes senseRyan Liptak
These calls are all late-initialization of ArrayList's that were initialized outside the current scope. This allows us to still get the potential memory-saving benefits of the 'precision' of initCapacity.
2021-09-19Update all ensureCapacity calls to the relevant non-deprecated versionRyan Liptak
2021-08-01macho: fix Trie and CodeSignature unit testsJakub Konka
after the cleanup.
2021-08-01macho: make CodeSignature accept allocator as paramJakub Konka
instead storing it within the struct.
2021-05-08update usage of std.testing in stage2Veikka Tuominen
2021-01-15macho: use target arch page_size for codesigJakub Konka
It turns out I was wrong and we can set the page size to the actual page size used by the target architecture when dividing the binary into chunks and calculating a hash of each chunk for embedding within the adhoc code signature. This shaves of a considerable amount of bytes since we divide the code signature section by at least 2x. I've also unified the `write` interface of `CodeSignature` struct to follow that used in every other bit of `MachO`; namely, the functions now accept a writer instead of a buffer, therefore, there is no need to manually track where to write each struct field anymore.
2021-01-01macho: unblock stage2 on 32bit platforms (#7632)Jakub Konka
* macho: unblock stage2 on 32bit platforms Unblocks compilation of stage2 on 32bit platforms, and fixes #7630. * Use libstd convention: reads - usize, writes - u64
2020-12-19macho: auto-coerce to sliceJakub Konka
2020-12-01macho: dynamically calculate code signature paddingJakub Konka
2020-12-01macho: unify code signature between stage1 and stage2Jakub Konka
2020-12-01lld: use commands.LoadCommand in self-hosted linkerJakub Konka
2020-12-01lld: add code signature to lld outputJakub Konka
2020-11-26stage2 macho: first, rough draft at trampoliningJakub Konka
2020-11-26stage2 macho: cleanup logsJakub Konka
2020-11-26stage2 macho: fix issues with codesigningJakub Konka
2020-11-26stage2 macho: generate a code sig (not valid yet)Jakub Konka
2020-11-26stage2 macho: add info about __TEXT segmentJakub Konka
2020-11-26stage2 macho: add empty CodeDirectory blobJakub Konka
2020-11-26stage2 macho: move code signature logic into structJakub Konka