aboutsummaryrefslogtreecommitdiff
path: root/src/link/Elf
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2023-11-05 12:56:17 +0100
committerJakub Konka <kubkon@jakubkonka.com>2023-11-05 12:56:17 +0100
commit55fa8a04f1853deb473339cdc610cbf012ae0d61 (patch)
treee614530b5be669123ed4278d532d7827ae982589 /src/link/Elf
parent5c482361034a0b1575ecb719724c942b5709b449 (diff)
downloadzig-55fa8a04f1853deb473339cdc610cbf012ae0d61.tar.gz
zig-55fa8a04f1853deb473339cdc610cbf012ae0d61.zip
elf: add hooks for archiving Objects
Diffstat (limited to 'src/link/Elf')
-rw-r--r--src/link/Elf/Object.zig2
-rw-r--r--src/link/Elf/file.zig25
2 files changed, 27 insertions, 0 deletions
diff --git a/src/link/Elf/Object.zig b/src/link/Elf/Object.zig
index 8c3c851dbe..673bf08247 100644
--- a/src/link/Elf/Object.zig
+++ b/src/link/Elf/Object.zig
@@ -20,6 +20,7 @@ alive: bool = true,
num_dynrelocs: u32 = 0,
output_symtab_size: Elf.SymtabSize = .{},
+output_ar_state: Archive.ArState = .{},
pub fn isObject(path: []const u8) !bool {
const file = try std.fs.cwd().openFile(path, .{});
@@ -924,6 +925,7 @@ const math = std.math;
const mem = std.mem;
const Allocator = mem.Allocator;
+const Archive = @import("Archive.zig");
const Atom = @import("Atom.zig");
const Cie = eh_frame.Cie;
const Elf = @import("../Elf.zig");
diff --git a/src/link/Elf/file.zig b/src/link/Elf/file.zig
index e31170a178..ed15ff93f3 100644
--- a/src/link/Elf/file.zig
+++ b/src/link/Elf/file.zig
@@ -204,6 +204,31 @@ pub const File = union(enum) {
};
}
+ pub fn updateArStrtab(file: File, allocator: Allocator, ar_strtab: *Archive.ArStrtab) !void {
+ return switch (file) {
+ .zig_object => |x| x.updateArStrtab(allocator, ar_strtab),
+ .object => @panic("TODO"),
+ inline else => unreachable,
+ };
+ }
+
+ pub fn updateArSize(file: File, elf_file: *Elf) void {
+ return switch (file) {
+ .zig_object => |x| x.updateArSize(elf_file),
+ .object => @panic("TODO"),
+ inline else => unreachable,
+ };
+ }
+
+ pub fn writeAr(file: File, elf_file: *Elf, writer: anytype) !void {
+ return switch (file) {
+ .zig_object => |x| x.writeAr(elf_file, writer),
+ // .object => |x| x.writeAr(elf_file, writer),
+ .object => @panic("TODO"),
+ inline else => unreachable,
+ };
+ }
+
pub const Index = u32;
pub const Entry = union(enum) {