aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO/Object.zig
AgeCommit message (Collapse)Author
2023-03-22macho+zld: refactor parsing of relocation targetJakub Konka
2023-03-21macho+zld: when finding by address, note the end of section symbols tooJakub Konka
Previously, if we were looking for the very last symbol by address in some section, and the next symbol happened to also have the same address value but would reside in a different section, we would keep going finding the wrong symbol in the wrong section. This mechanism turns out vital for correct linking of Go binaries where the runtime looks for specially crafted synthetic symbols which mark the beginning and end of each section. In this case, we had an unfortunate clash between the end of PC marked machine code section (`_runtime.etext`) and beginning of read-only data (`_runtime.rodata`).
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-02-06macho: parse and sort data-in-code entries ahead of timeJakub Konka
2023-02-06macho: downgrade alignment requirements for symtab in object filesJakub Konka
Parse and sort relocations by address descending.
2023-01-21macho: fix sorting symbols by seniorityJakub Konka
2023-01-21macho: synthesise unwind records in absence of compact unwind sectionJakub Konka
Unlike Apple ld, we will not do any DWARF CFI parsing and simply output DWARF type unwind records.
2023-01-20zld: parse, synthesise and emit unwind recordsJakub Konka
2022-10-30macho: fix regression in dead strip for x86_64Jakub Konka
Correctly handle calculating encompassing atoms for local relocations (`r_extern == 0`).
2022-10-22macho: some docsJakub Konka
2022-10-22macho: gracefully handle uninitialized symtabs in objectsJakub Konka
2022-10-22macho: fix handling of lack of subsections and tracking of inner symbolsJakub Konka
2022-10-22macho: fix bug in incorrectly splicing nodes in trieJakub Konka
2022-10-22macho: do not assume __la_symbol_ptr was createdJakub Konka
2022-10-22macho: upstream rewritten traditional linker, zldJakub Konka
kubkon/zld gitrev 5733ed87abe2f07e1330c3232a252e9defec638a
2022-09-18macho: fix after sync with masterJakub Konka
2022-09-18macho: rewrite how we allocate space in incremental contextJakub Konka
2022-09-18macho: do not call populateMissingMetadata in full link modeJakub Konka
2022-09-18macho: clean up use of section idsJakub Konka
2022-09-18macho: move main driver loop for one-shot into standalone zld moduleJakub Konka
2022-09-17macho: do not assume every object has a symtabJakub Konka
For example, building stage2 requires an empty `empty.cc` source file compiling which generates a valid translation unit with no symtab/strtab. In this case, we cannot simply assume that every translation unit will have a valid symtab; instead, we cautiously default the input symtab and strtab fields to optional `null` to signal symtab's presence or its lack of. In case the symtab is not present, we catch this fact when splitting input sections into subsections and create a synthetic symbol per every suitable section.
2022-08-24Merge pull request #12574 from Vexu/remove-bit-op-type-paramAndrew Kelley
stage2+stage1: remove type parameter from bit builtins
2022-08-23macho: fix compile errors in std.debugJakub Konka
2022-08-23std.debug: implement support for DWARFv5Andrew Kelley
2022-08-22Dwarf: Added stroffsetsptr support (#12270)Keith Chambers
* Added support for stroffsetsptr class in Dwarf stdlib * Proper initializion of debug_str_offsets in DwarfInfo * Added missing null initializer to DwarfInfo in Macho * Added missing is_64 field to getAttrString in DwarfInfo * Fixed formatting * Added missing is_64 param to getAttrString * Added required cast to usize * Adding missing .debug_str_offsets initialization * getAttrString now uses the str_offsets_base attr
2022-08-22stage2+stage1: remove type parameter from bit builtinsVeikka Tuominen
Closes #12529 Closes #12511 Closes #6835
2022-08-10link.MachO: use accurate alignment attribute on pointersAndrew Kelley
Also adds a new method to ArrayList: appendUnalignedSlice
2022-08-10Revert "macho: allow unaligned offsets in object files"Andrew Kelley
This reverts commit 45c444ff18b43d30a7277e346174ba6eca4a6193.
2022-08-10macho: allow unaligned offsets in object filesJakub Konka
2022-08-03macho: update how we insert output sectionsJakub Konka
Instead of generating sections upfront, allow generation by scanning the object files for input -> output sections mapping. Next, always strive to keep output sections in the final container sorted as they appear in the final binary. This makes the linker less messy wrt handling of output sections sort order for dyld/macOS not to complain. There's still more work to be done for incremental context though to make this work but looks promising already.
2022-08-03macho: sync with zldJakub Konka
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24 https://github.com/kubkon/zld/commit/a2c32e972f8c5adfcda8ed2d99379ae868f59c24
2022-07-27std.fmt: add more invalid format string errorsr00ster91
2022-07-25macho: fix memory leak and refactor Target usageJakub Konka
2022-07-22macho: move GC code into dead_strip.zig moduleJakub Konka
Implement marking live atoms that reference other live atoms if required by the compiler (via section attribute).
2022-07-22macho: sort subsection symbols by seniorityJakub Konka
2022-07-22macho: do not GC local symbols unless reference dead symbolsJakub Konka
If a local references another local, we keep it. If it doesn't reference anything, we keep it. Otherwise, we dead strip it.
2022-07-22macho: parse data-in-code when writing LINKEDIT segmentJakub Konka
2022-07-22macho: do not store stabs; generate on-the-fly insteadJakub Konka
2022-07-22macho: don't store GC roots globallyJakub Konka
Instead, if dead-strip was requested, create a temp container and pass it around.
2022-07-22macho: link atom starting section by orig section idJakub Konka
In x86_64 relocs, it can so happen that the compiler refers to the same atom by both the actual assigned symbol and the start of the section. In this case, we need to link the two together so add an alias.
2022-07-22macho: rework symbol handling for incremental stage2 buildsJakub Konka
2022-07-22macho: fix compilation issues on 32bit hostsJakub Konka
2022-07-22macho: rework symbol handling to match zld/ELFJakub Konka
Now, each object file will store a mutable table of symbols that it defines. Upon symbol resolution between object files, the symbol will be updated with a globally allocated section ordinal and address in virtual memory. If the object defines a globally available symbol, its location only (comprising of the symbol index and object index) will be stored in the globals map for easy access when relocating, etc. This approach cleans up the symbol management significantly, and matches the status quo used in zld/ELF. Additionally, this makes scoping symbol stabs easier too as they are now naturally contained within each object file.
2022-07-22macho: split section into subsections if requested and/or possibleJakub Konka
2022-07-22macho: put parsing into an atom into a helperJakub Konka
2022-07-22macho: read the entire file contents into memory at onceJakub Konka
2022-05-27math: make `cast` return optional instead of an errorAli Chraghi
2022-04-21dwarf: clean up allocations in std.dwarf moduleJakub Konka
While this code probably could do with some love and a redesign, this commit fixes the allocations by making sure we explicitly pass an allocator where required, and we use arenas for temporary or narrowly-scoped objects such as a `Die` (for `Die` in particular, not every `FormValue` will be allocated - we could duplicate, or we can use an arena which is the proposal of this commit).
2022-04-15stage2 macho: workaround stage2 bugsVeikka Tuominen
2022-04-14stage2: progress towards stage3Andrew Kelley
* The `@bitCast` workaround is removed in favor of `@ptrCast` properly doing element casting for slice element types. This required an enhancement both to stage1 and stage2. * stage1 incorrectly accepts `.{}` instead of `{}`. stage2 code that abused this is fixed. * Make some parameters comptime to support functions in switch expressions (as opposed to making them function pointers). * Avoid relying on local temporaries being mutable. * Workarounds for when stage1 and stage2 disagree on function pointer types. * Workaround recursive formatting bug with a `@panic("TODO")`. * Remove unreachable `else` prongs for some inferred error sets. All in effort towards #89.