46 Commits

Author SHA1 Message Date
Jakub Konka
1f8dd27e40 elf: correctly format output .eh_frame when emitting relocatable 2023-11-09 14:46:28 +01:00
Jakub Konka
ae08f9bfe9 elf: claim unresolved dangling symbols as undef externs in -r mode 2023-11-08 11:51:11 +01:00
Jakub Konka
e87c751558 elf: reference .rela sections via output section index 2023-11-08 10:57:34 +01:00
Jakub Konka
5e78600f0f elf: actually track output symtab index of symbols 2023-11-07 23:18:41 +01:00
Jakub Konka
0211d6bf4f elf: create link between .rela and output section 2023-11-07 14:42:27 +01:00
Jakub Konka
e22b3595c1 elf: update .rela section sizes 2023-11-07 14:29:44 +01:00
Jakub Konka
c7ed7c4690 elf: generate section symbols when writing symtab 2023-11-07 13:31:31 +01:00
Jakub Konka
3df53d1722 elf: create skeleton of required changes for supporting -r mode 2023-11-07 11:19:55 +01:00
Jakub Konka
8142925c7e elf: hook up saving object files in an archive 2023-11-05 13:37:13 +01:00
Jakub Konka
55fa8a04f1 elf: add hooks for archiving Objects 2023-11-05 12:56:17 +01:00
Jakub Konka
5c48236103 elf: init objects after parsing them 2023-11-05 12:37:15 +01:00
Jakub Konka
25c53f08a6 elf: redo strings management in the linker
* atom names - are stored locally and pulled from defining object's
  strtab
* local symbols - same
* global symbols - in principle, we could store them locally, but
  for better debugging experience - when things go wrong - we
  store the offsets in a global strtab used by the symbol resolver
2023-11-04 09:08:16 +01:00
Jakub Konka
8087ec8e8c elf: improve parsing of ld scripts and actually test linking against them 2023-10-24 19:03:00 +02:00
Jakub Konka
52e0ca1312 elf: parse GNU ld script as system lib indirection 2023-10-18 13:54:43 +02:00
Jakub Konka
d2727b808c elf: fix 32bit build 2023-10-16 19:56:47 +02:00
Jakub Konka
7b2cbcf0fe codegen+elf: check if extern is a variable ref 2023-10-16 19:33:06 +02:00
Jakub Konka
1efc0519ce elf: make init/fini sorting deterministic 2023-10-16 19:33:05 +02:00
Jakub Konka
def7190e84 elf: hook up common symbols handler 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
04a8f217c6 elf: fix COMDAT deduping logic 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
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
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
89c2151a97 elf: move logic for extracing atom's code into input files 2023-09-28 18:35:26 +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
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
dbde746f9d elf: parse archives 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