aboutsummaryrefslogtreecommitdiff
path: root/src/link
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-09-12 18:07:10 +0200
committerJakub Konka <kubkon@jakubkonka.com>2023-09-12 18:07:10 +0200
commit652ebf3b6a62007d37fb7fd4def393f11bb6159f (patch)
treea0202d6cae5600d701bfbcbd960924716a062618 /src/link
parent9db472cff6573fd1d0f50c8ea1b5ecb536aeff1e (diff)
downloadzig-652ebf3b6a62007d37fb7fd4def393f11bb6159f.tar.gz
zig-652ebf3b6a62007d37fb7fd4def393f11bb6159f.zip
elf: allocate objects, currently atom-by-atom
Diffstat (limited to 'src/link')
-rw-r--r--src/link/Elf.zig20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 9ee1389397..ca75a1e863 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -1053,7 +1053,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node
try self.scanRelocs();
// Allocate atoms parsed from input object files
- self.allocateObjects();
+ try self.allocateObjects();
self.allocateLinkerDefinedSymbols();
// Beyond this point, everything has been allocated a virtual address and we can resolve
@@ -1405,8 +1405,22 @@ fn scanRelocs(self: *Elf) !void {
}
}
-fn allocateObjects(self: *Elf) void {
- _ = self;
+fn allocateObjects(self: *Elf) !void {
+ for (self.objects.items) |index| {
+ const object = self.file(index).?.object;
+ for (object.atoms.items) |atom_index| {
+ const atom_ptr = self.atom(atom_index) orelse continue;
+ if (!atom_ptr.alive) continue;
+ try atom_ptr.allocate(self);
+ }
+
+ for (object.globals()) |global_index| {
+ const global = self.symbol(global_index);
+ if (global.file_index == index) {
+ global.value = global.atom(self).?.value;
+ }
+ }
+ }
}
fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !void {