58 Commits

Author SHA1 Message Date
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
679accd887 elf: initialize output sections from input objects in a separate step 2023-10-16 19:33:04 +02:00
Jakub Konka
75f4420c2d elf: increase Atom.Index resolution to u32 2023-10-16 19:33:04 +02:00
Jakub Konka
605e3eb08c elf: clean up generating GOT symbol names 2023-10-16 19:33:03 +02:00
Jakub Konka
43406c0696 elf: update .strtab with GOT symbols 2023-10-16 19:33:03 +02:00
Jakub Konka
af40bce08a x86_64: emit R_X86_64_GOT32 for non-PIC GOT references 2023-10-01 21:09:35 +02:00
Jakub Konka
5381bfd348 elf: fix setting st_value of _end synthetic symbol 2023-09-29 22:18:38 +02:00
Jakub Konka
04a7051c4b elf: fix 32bit build 2023-09-28 21:42:09 +02:00
Jakub Konka
89c2151a97 elf: move logic for extracing atom's code into input files 2023-09-28 18:35:26 +02:00
Jakub Konka
785bd270ed elf: correctly allocate TLS segment 2023-09-28 14:59:09 +02:00
Jakub Konka
af00ac53b5 elf: report fatal linker error for unhandled relocation types 2023-09-28 14:06:12 +02:00
Jakub Konka
1200a5a240 elf: allow expanding segments in virtual memory 2023-09-27 09:59:59 +02:00
Jakub Konka
eb497c50e3 elf: dynamically allocate remaining alloc sections (and segments) 2023-09-26 21:07:47 +02:00
Jakub Konka
ab8a5bfe83 elf: implement markLive for ZigModule 2023-09-23 17:17:20 +02:00
Jakub Konka
29ebd96818 elf: improve decl-to-section mapping logic 2023-09-23 17:15:41 +02:00
Andrew Kelley
accd5701c2 compiler: move struct types into InternPool proper
Structs were previously using `SegmentedList` to be given indexes, but
were not actually backed by the InternPool arrays.

After this, the only remaining uses of `SegmentedList` in the compiler
are `Module.Decl` and `Module.Namespace`. Once those last two are
migrated to become backed by InternPool arrays as well, we can introduce
state serialization via writing these arrays to disk all at once.

Unfortunately there are a lot of source code locations that touch the
struct type API, so this commit is still work-in-progress. Once I get it
compiling and passing the test suite, I can provide some interesting
data points such as how it affected the InternPool memory size and
performance comparison against master branch.

I also couldn't resist migrating over a bunch of alignment API over to
use the log2 Alignment type rather than a mismash of u32 and u64 byte
units with 0 meaning something implicitly different and special at every
location. Turns out you can do all the math you need directly on the
log2 representation of alignments.
2023-09-21 14:48:40 -07:00
Jakub Konka
fc86b80b3b elf: correctly handle overflows on non-64bit hosts 2023-09-13 22:38:44 +02:00
Jakub Konka
d37cb60621 elf: re-enable linking compiler_rt 2023-09-13 21:51:43 +02:00
Jakub Konka
ce88df497c elf: do not store Symbol's index in Symbol 2023-09-13 21:51:43 +02:00
Jakub Konka
dbde746f9d elf: parse archives 2023-09-13 21:51:43 +02:00
Jakub Konka
5eef7577d1 elf: handle more relocs with GOT relaxation 2023-09-13 21:51:43 +02:00
Jakub Konka
6910a50ae5 elf: add u64 to usize casts where required 2023-09-13 00:31:41 +02:00
Jakub Konka
1a6d12ea92 elf: clean up and unify symbol ref handling in relocs
Also, this lets us re-enable proper undefined symbols tracking.
2023-09-12 23:27:14 +02:00
Jakub Konka
ae74a36af0 elf: resolve and write objects to file 2023-09-12 19:17:57 +02:00
Jakub Konka
9db472cff6 elf: set output section index of a global when resolving 2023-09-12 17:52:55 +02:00
Jakub Konka
472d326a8c elf: set output section index when parsing objects 2023-09-12 17:35:56 +02:00
Jakub Konka
44e84af874 elf: add simplistic reloc scanning mechanism 2023-09-12 16:32:55 +02:00
Jakub Konka
c654f3b0ee elf: claim unresolved dangling symbols that can be claimed 2023-09-12 15:44:16 +02:00
Jakub Konka
b478a0dd1a elf: mark imports-exports; populate symtab with objects 2023-09-12 15:14:38 +02:00
Jakub Konka
962b46148d elf: add simplistic symbol resolution 2023-09-12 14:36:55 +02:00
Jakub Konka
53c3757c00 elf: start fixing symbol resolution 2023-09-12 14:02:15 +02:00
Jakub Konka
00787885f4 elf: report undefined symbols in objects 2023-09-12 00:10:54 +02:00
Jakub Konka
67d458370d elf: add prelim impl of Object parsing 2023-09-11 22:49:42 +02:00
Jakub Konka
7a9eba2f85 elf: emit relocation to an extern function 2023-09-11 10:52:30 +02:00
Jakub Konka
d07edfabd6 elf: simplify handling of relocs for atoms 2023-09-11 07:59:54 +02:00
Jakub Konka
4b082d89c9 elf: decouple notion of atom free list from shdrs
Not every section will have the need for such a free list.
2023-09-10 21:58:45 +02:00
Jakub Konka
1c3fd16c37 elf: write linker-defined symbols to symtab 2023-09-10 09:10:00 +02:00
Jakub Konka
a455b5692a elf: create required linker-defined symbols 2023-09-10 08:41:13 +02:00
Jakub Konka
a3372050b1 elf: rename program_headers to phdrs 2023-09-08 23:21:44 +02:00
Jakub Konka
465431807b elf: write $got symbols into the symtab 2023-09-08 22:53:53 +02:00
Jakub Konka
69738a07c2 elf: store Index rather than ?Index in Atom; gen ABS STT_FILE for zig source 2023-09-08 21:09:45 +02:00
Jakub Konka
6ad5db030c elf: store GOT index in symbol extra array; use GotSection for GOT 2023-09-08 18:12:53 +02:00
Jakub Konka
9691d1a30f elf: use zld's update mechanism for symtab for Zig module 2023-09-07 15:45:58 +02:00
Jakub Konka
93120a81fe elf: lift-off - get it to compile and run until the error! 2023-09-06 14:42:32 +02:00
Jakub Konka
a9df098cd2 elf: make everything upside down - track by Symbol.Index rather than Atom.Index 2023-09-06 13:14:00 +02:00
Jakub Konka
d9fffd431a elf: start porting abstraction of input file 2023-09-05 15:55:00 +02:00
Jakub Konka
02451bdebf elf: atom.index of 0 reserved for null atom 2023-09-04 22:41:50 +02:00
Jakub Konka
bc37c95e56 elf: simplify accessors to symbols, atoms, etc 2023-09-04 11:23:19 +02:00