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
1efc0519ce
elf: make init/fini sorting deterministic
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
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
Jakub Konka
d565f8bef2
elf: check for null atom in ZigModule
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
43406c0696
elf: update .strtab with GOT symbols
2023-10-16 19:33:03 +02:00
Jakub Konka
d06aa21e48
elf: for now always update .shstrtab and .strtab sections
2023-10-16 19:33:03 +02:00
Jakub Konka
ff1423c4ce
elf: reuse addSection in alloc functions
2023-10-16 19:33:03 +02:00
Jakub Konka
c8c50a058e
elf: do not prealloc space for .symtab
2023-10-16 19:33:03 +02:00
Jakub Konka
52f8a1a24c
elf: move initializing string buffers out of populateMissingMetadata
2023-10-16 19:33:03 +02:00
Andrew Kelley
f708c5fafc
CLI: finish updating module API usage
...
Finish the work started in 4c4fb839972f66f55aa44fc0aca5f80b0608c731.
Now the compiler compiles again.
Wire up dependency tree fetching code in the CLI for `zig build`.
Everything is hooked up except for `createDependenciesModule` is not yet
implemented.
2023-10-08 16:54:31 -07:00
Jakub Konka
cbdf4858e8
elf: assert llvm_object is null in getAnonDeclVAddr
2023-10-03 12:49:24 -07:00
Jakub Konka
0134e5d2a1
codegen: separate getAnonDeclVAddr into lowerAnonDecl and the former
...
Implement the stub for Elf.
I believe that separating the concerns, namely, having an interface
function that is responsible for signalling the linker to lower
the anon decl only, and a separate function to obtain the decl's
vaddr is preferable since it allows us to handle codegen errors
in a simpler way.
2023-10-03 12:49:12 -07:00
Andrew Kelley
0483b4a512
link: stub out getAnonDeclVAddr
2023-10-03 12:12:51 -07:00
Stephen Gregoratto
285970982a
Add illumos OS tag
...
- Adds `illumos` to the `Target.Os.Tag` enum. A new function,
`isSolarish` has been added that returns true if the tag is either
Solaris or Illumos. This matches the naming convention found in Rust's
`libc` crate[1].
- Add the tag wherever `.solaris` is being checked against.
- Check for the C pre-processor macro `__illumos__` in CMake to set the
proper target tuple. Illumos distros patch their compilers to have
this in the "built-in" set (verified with `echo | cc -dM -E -`).
Alternatively you could check the output of `uname -o`.
Right now, both Solaris and Illumos import from `c/solaris.zig`. In the
future it may be worth putting the shared ABI bits in a base file, and
mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files.
[1]: 6e02a329a2/src/unix/solarish
2023-10-02 15:31:49 -06:00
Jakub Konka
e72fd185e0
elf: skip writing out zerofill atoms to file
2023-09-30 00:52:10 +02:00
Jakub Konka
6c50ad6e9f
elf: set sh_size to 0 for nobit sections in collision detection
...
`SHT_NOBITS` sections take no file space after all.
2023-09-29 22:37:59 +02:00
Jakub Konka
e5e6984652
elf: dump state for debugging after writing it all out
2023-09-29 22:29:06 +02:00
Jakub Konka
5381bfd348
elf: fix setting st_value of _end synthetic symbol
2023-09-29 22:18:38 +02:00
Jakub Konka
8e90b41ae0
elf: set shdr/phdr file size before growing in VM
2023-09-29 21:43:01 +02:00
Jakub Konka
304d38e844
elf: simplify logic for growing non-alloc sections
2023-09-29 20:35:28 +02:00