Jakub Konka
d8c4838c7d
zld: fix incorrect global symbol collision check
2021-07-17 18:43:28 +02:00
Jakub Konka
9f20a51555
zld: demote logging back to debug from warn
2021-07-17 18:33:47 +02:00
Jakub Konka
fccac48a55
zld: fix committing stub info into final binary
2021-07-17 18:19:32 +02:00
Jakub Konka
97914d93a9
zld: fixup flush function
2021-07-17 17:30:16 +02:00
Jakub Konka
d81783375c
zld: allocate TextBlocks and symbols
2021-07-17 15:13:16 +02:00
Jakub Konka
71384a383e
zld: correctly set n_sect for sections as symbols
2021-07-17 11:29:40 +02:00
Jakub Konka
db8020ac0d
zld: adjust resolving relocs logic to the new approach
2021-07-17 11:01:10 +02:00
Jakub Konka
407745a5e9
zld: simplify and move Relocations into TextBlock
...
It makes sense to have them as a dependent type since they only ever
deal with TextBlocks. Simplify Relocations to rely on symbol indices
and symbol resolver rather than pointers.
2021-07-17 01:03:40 +02:00
Jakub Konka
54a403d4ff
zld: replace parsed reloc with a simple wrapper around macho.relocation_info
2021-07-16 17:18:53 +02:00
Jakub Konka
5a2bea2931
zld: draft symbol resolver on macho.nlist_64 only
2021-07-16 13:02:02 +02:00
Jakub Konka
f519e781c6
zld: move TextBlock into standalone file
...
which should make managing the logic of parsing and resolving relocs
that much simpler to parse.
2021-07-15 18:49:48 +02:00
Jakub Konka
c47ce31071
zld: thin out Relocation by not storing *TextBlock
...
this way we shave off 8 bytes per Relocation structure, and instead
we can pass the *TextBlock as args to resolve function.
2021-07-15 18:49:47 +02:00
Jakub Konka
f8678c48ff
zld: reuse string table for symbol names
...
rather than manage allocs separately per symbol.
2021-07-15 18:49:47 +02:00
Jakub Konka
ec874a9b2b
zld: move tracking binding for proxies into TextBlock
...
which is the source of binding rather than its target. That is,
we now track by source.
2021-07-15 18:49:47 +02:00
Jakub Konka
0135b46659
zld: remove StringTable abstraction
2021-07-15 18:49:47 +02:00
Jakub Konka
f87424ab63
zld: invoke traditional linker if has LLVM as a temp measure
2021-07-15 18:49:47 +02:00
Jakub Konka
9ca69c51e7
zld: error out if LTO is requested targeting Darwin
2021-07-15 18:49:47 +02:00
Jakub Konka
e3575cdad4
zld: decommision use_lld for MachO
...
Invoke `linkAsArchive` directly in MachO backend when LLVM is available
and we are asked to create a static lib.
2021-07-15 18:49:47 +02:00
Jakub Konka
398672eb30
zld: add temp basic handling of debugging stabs
2021-07-15 18:49:47 +02:00
Jakub Konka
e17f12dd64
zld: fix incorrectly worked out section size
...
Also, add a solution to a degenerate case where on x86_64 a relocation
refers to a cell in a section via section start address even though
a symbol exists. In such case, make the section spawned symbol an alias
of the actual symbol.
2021-07-15 18:49:47 +02:00
Jakub Konka
de30a704b1
zld: map [section addr, first symbol) to a tracked TextBlock
...
which applies exclusively to x86_64-macos.
2021-07-15 18:49:47 +02:00
Jakub Konka
da07251000
zld: make addend i64 in Signed reloc
2021-07-15 18:49:47 +02:00
Jakub Konka
496903c6a8
zld: add DICE support mainly for x86_64-macos
2021-07-15 18:49:47 +02:00
Jakub Konka
e3fe9a9df5
zld: fix parsing and resolving Signed relocs
...
on x86_64-macos since this an x86_64 only relocation type.
2021-07-15 18:49:47 +02:00
Jakub Konka
b8fce705ad
zld: refactor nlist and reloc filtering logic
2021-07-15 18:49:47 +02:00
Jakub Konka
2a880897b0
zld: add basic Signed reloc resolution
...
and fix handling Unsigned for x86_64.
2021-07-15 18:49:47 +02:00
Jakub Konka
570660bb46
zld: ___dso_handle is regular at 0x100000000
...
which points at the start of the __TEXT segment.
Also, ensure C++ initializers and terminators are rebased.
2021-07-15 18:49:47 +02:00
Jakub Konka
9e051e365b
zld: correctly estimate TextBlock's alignment with
...
section's alignment serving as the maximum alignment that
can be seen in this particular section. However, TextBlocks are
still allowed to have at most that alignment.
2021-07-15 18:49:47 +02:00
Jakub Konka
95aeb09b9b
zld: populate sections from the top rather than from bottom
2021-07-15 18:49:47 +02:00
Jakub Konka
714e0c4761
zld: re-enable logging of TextBlocks
2021-07-15 18:49:47 +02:00
Jakub Konka
7aefea614f
zld: fix allocating tentative defs
2021-07-15 18:49:47 +02:00
Jakub Konka
3bdb3b574e
zld: turn logging off
2021-07-15 18:49:47 +02:00
Jakub Konka
dd5c7588d1
zld: fix resolving TLV offset relocations
2021-07-15 18:49:47 +02:00
Jakub Konka
322be2698d
zld: TextBlock needs to be written to an aligend offset too
2021-07-15 18:49:47 +02:00
Jakub Konka
bb5b82cab9
zld: dedup symbols in the symbol table
2021-07-15 18:49:47 +02:00
Jakub Konka
0cc4938419
zld: re-enable all of linker after complete rewrite
2021-07-15 18:49:47 +02:00
Jakub Konka
12187586d1
zld: fix alloc alignment and resolve relocs
2021-07-15 18:49:47 +02:00
Jakub Konka
961b463fad
zld: track symbols defined within TextBlock
...
in case TextBlock represents an entire section with symbols
defined within.
2021-07-15 18:49:47 +02:00
Jakub Konka
7aeedc0912
zld: allocate TextBlocks
...
temporarily by iterating over all defined TextBlocks. However,
once we merge this with MachO incremental, updates will be done
at the point of creation and/or update.
Also, fix mining TLV knowledge for working out TLV pointers.
2021-07-15 18:49:47 +02:00
Jakub Konka
e524f43a6f
zld: save rebase and TLV offset as part of TextBlock
...
instead of as part of the Symbol. This seems to be more
optimal way of handling dyld ops in presence of no splittable
input sections in object files.
2021-07-15 18:49:47 +02:00
Jakub Konka
7c662db8d9
zld: keep text blocks per segment,section pair
2021-07-15 18:49:47 +02:00
Jakub Konka
a04bc1ed14
zld: update relocs and start prepping for segment allocs
2021-07-15 18:49:47 +02:00
Jakub Konka
dfa69e3c30
zld: dealloc TextBlock if omitted
2021-07-15 18:49:47 +02:00
Jakub Konka
555b66c255
zld: move should_rebase logic into Symbol
2021-07-15 18:49:47 +02:00
Jakub Konka
dbd2eb7c7f
zld: simplify relocation parsing
2021-07-15 18:49:47 +02:00
Jakub Konka
15b85df3dd
zld: parse relocs per generated TextBlock
2021-07-15 18:49:47 +02:00
Jakub Konka
54888c6f46
zld: create TextBlocks for tentative definitions
...
and fix the links in the `TextBlock`s linked list!
2021-07-15 18:49:47 +02:00
Jakub Konka
51e334af44
zld: refactor section into TextBlocks conversion
2021-07-15 18:49:47 +02:00
Jakub Konka
7b4063d558
zld: convert section in linked list of TextBlocks
2021-07-15 18:49:47 +02:00
Jakub Konka
5649242025
zld: draft up final format of TextBlock
2021-07-15 18:49:47 +02:00