| Age | Commit message (Collapse) | Author |
|
|
|
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`).
|
|
|
|
|
|
Parse and sort relocations by address descending.
|
|
|
|
Unlike Apple ld, we will not do any DWARF CFI parsing and simply
output DWARF type unwind records.
|
|
|
|
Correctly handle calculating encompassing atoms for local
relocations (`r_extern == 0`).
|
|
|
|
|
|
|
|
|
|
|
|
kubkon/zld gitrev 5733ed87abe2f07e1330c3232a252e9defec638a
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
stage2+stage1: remove type parameter from bit builtins
|
|
|
|
|
|
* 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
|
|
Closes #12529
Closes #12511
Closes #6835
|
|
Also adds a new method to ArrayList: appendUnalignedSlice
|
|
This reverts commit 45c444ff18b43d30a7277e346174ba6eca4a6193.
|
|
|
|
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.
|
|
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24
https://github.com/kubkon/zld/commit/a2c32e972f8c5adfcda8ed2d99379ae868f59c24
|
|
|
|
|
|
Implement marking live atoms that reference other live atoms if
required by the compiler (via section attribute).
|
|
|
|
If a local references another local, we keep it. If it doesn't
reference anything, we keep it. Otherwise, we dead strip it.
|
|
|
|
|
|
Instead, if dead-strip was requested, create a temp container and
pass it around.
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
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).
|
|
|
|
* 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.
|