Jakub Konka
17635e4f2a
x86_64: add -fPIC support targeting ELF
2023-10-16 19:33:06 +02:00
Jakub Konka
b3d98a4b88
elf: emit dynamic base relocs for .zig.got entries when required
2023-10-16 19:33:06 +02:00
Jakub Konka
315cd7623e
elf: fix section sorting logic
2023-10-16 19:33:05 +02:00
Jakub Konka
5fad683791
elf: emit (broken) debug sections
2023-10-16 19:33:05 +02:00
Jakub Konka
85d451f96c
elf: re-enable self-hosted backends
2023-10-16 19:33:05 +02:00
Jakub Konka
7be983ac92
elf: create new synthetic section ZigGotSection
2023-10-16 19:33:05 +02:00
Jakub Konka
9b6337ab06
elf: exclude Zig special sections from bulk alloc
2023-10-16 19:33:05 +02:00
Jakub Konka
9da6574f7b
elf: refactor
2023-10-16 19:33:05 +02:00
Jakub Konka
716a45a209
elf: use findFreeSpace mechanics to allocate object-extracted segments
2023-10-16 19:33:05 +02:00
Jakub Konka
5ff12003ee
elf: dynamically allocate SHDR table
2023-10-16 19:33:05 +02:00
Jakub Konka
1939c7d182
elf: clean up logic for allocating TLS segment
2023-10-16 19:33:05 +02:00
Jakub Konka
c87e73b19f
elf: allocate non-alloc sections using incremental mechanism
2023-10-16 19:33:05 +02:00
Jakub Konka
2aa6099ad9
elf: assume only one TLS segment for now
2023-10-16 19:33:05 +02:00
Jakub Konka
8be71906d9
elf: split allocating sections/segments into alloc and non-alloc
2023-10-16 19:33:05 +02:00
Jakub Konka
bcce035636
elf: bring back PT_LOAD for PT_PHDR for incremental codepath
2023-10-16 19:33:05 +02:00
Jakub Konka
43397bbdc4
elf: always write SHDR table, at least for now
2023-10-16 19:33:05 +02:00
Jakub Konka
6a7a20520d
elf: always write PHDR table, at least for now
2023-10-16 19:33:05 +02:00
Jakub Konka
5148e38751
elf: create and allocate special PHDRs out of the loop
2023-10-16 19:33:05 +02:00
Jakub Konka
59fcf16732
elf: move creation of PT_PHDR out of initPhdrs and initMetadata
2023-10-16 19:33:05 +02:00
Jakub Konka
e571208433
elf: rename Zig-specific section handles to _zig_ infixed
2023-10-16 19:33:05 +02:00
Jakub Konka
871591ca1c
elf: fix conflicts after rebase gone bad
2023-10-16 19:33:05 +02:00
Jakub Konka
0b37a9c78d
elf: fix GotSection.write in presence of TLSLD symbol
2023-10-16 19:33:05 +02:00
Jakub Konka
1efc0519ce
elf: make init/fini sorting deterministic
2023-10-16 19:33:05 +02:00
Jakub Konka
1772dbb503
elf: fix generating .plt.got indirection
2023-10-16 19:33:05 +02:00
Jakub Konka
06f3b385c4
elf: fix alignment of .eh_frame_hdr section
2023-10-16 19:33:05 +02:00
Jakub Konka
a748ca3725
elf: populate symtab with symbols coming from DSOs
2023-10-16 19:33:05 +02:00
Jakub Konka
2f497f9f05
elf: emit .got.plt when emitting .plt
2023-10-16 19:33:04 +02:00
Jakub Konka
def7190e84
elf: hook up common symbols handler
2023-10-16 19:33:04 +02:00
Jakub Konka
f4c1b1d9ad
elf: implement --verbose-link, and other fixes
2023-10-16 19:33:04 +02:00
Jakub Konka
4af5caa81f
elf: add missing generators for special dynamic sections
2023-10-16 19:33:04 +02:00
Jakub Konka
5fa90afb64
elf: fix synthetic section handling and actually parse DSOs
2023-10-16 19:33:04 +02:00
Jakub Konka
d1446565a1
elf: re-enable dynamic linking codepaths
2023-10-16 19:33:04 +02:00
Jakub Konka
04a8f217c6
elf: fix COMDAT deduping logic
2023-10-16 19:33:04 +02:00
Jakub Konka
9a80ac0429
elf: add garbage collection of sections
2023-10-16 19:33:04 +02:00
Jakub Konka
f1b9c365f2
elf: add incomplete handling of build-obj -fllvm -fno-lld
2023-10-16 19:33:04 +02:00
Jakub Konka
727d9431c8
elf: link hello-world in c++
2023-10-16 19:33:04 +02:00
Jakub Konka
d6cec5a586
elf: add more prepwork for linking c++ objects
2023-10-16 19:33:04 +02:00
Jakub Konka
66f34b15e8
elf: add symbols to .got section directly
2023-10-16 19:33:04 +02:00
Jakub Konka
2c2bc66ce1
elf: handle .eh_frame and non-alloc sections
2023-10-16 19:33:04 +02:00
Jakub Konka
9ccd94d560
elf: refactor object.shdrContents to never error out
2023-10-16 19:33:04 +02:00
Jakub Konka
53340544c6
elf: get hello-world with LLVM in Zig working
2023-10-16 19:33:04 +02:00
Jakub Konka
1b70ad622b
elf: port zld's allocation mechanism
2023-10-16 19:33:04 +02:00
Jakub Konka
860beda55f
elf: remove dirty from synthetic .got section
2023-10-16 19:33:04 +02:00
Jakub Konka
6faed6269f
elf: update section sizes accumulated from objects
2023-10-16 19:33:04 +02:00
Jakub Konka
14cff77d87
elf: create atom lists indexed by section index
2023-10-16 19:33:04 +02:00
Jakub Konka
540ef3e010
elf: sort sections by their rank to combine them by segment flags
...
Currently this ignores ZigModule, however, I believe we can make it
so that this is done excluding sections/segments emitted by ZigModule
and everything should work out just fine.
2023-10-16 19:33:04 +02:00
Jakub Konka
679accd887
elf: initialize output sections from input objects in a separate step
2023-10-16 19:33:04 +02:00
Jakub Konka
509da2316c
elf: run populateMissingMetadata only if ZigModule exists
2023-10-16 19:33:04 +02:00
Jakub Konka
f0f19e18c7
elf: write shdr_table in flush
2023-10-16 19:33:04 +02:00
Jakub Konka
87602092fa
elf: write .got in bulk after scanning objects
2023-10-16 19:33:04 +02:00