diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2025-11-11 13:58:06 -0500 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2025-11-11 14:11:32 -0500 |
| commit | 61a1cefeb30fab3aa82e0d47385ca4f2c4b36c1b (patch) | |
| tree | 5a53f185e35120eb85922978f68ecb34633b652e /src/link.zig | |
| parent | 79a9f3a4180dfe395c816b86a2afc79edc302e65 (diff) | |
| download | zig-61a1cefeb30fab3aa82e0d47385ca4f2c4b36c1b.tar.gz zig-61a1cefeb30fab3aa82e0d47385ca4f2c4b36c1b.zip | |
Elf2: implement PLT
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/link.zig b/src/link.zig index c0a8facb77..1524c9a23e 100644 --- a/src/link.zig +++ b/src/link.zig @@ -1069,7 +1069,7 @@ pub const File = struct { errdefer archive.file.close(); loadInput(base, .{ .archive = archive }) catch |err| switch (err) { error.BadMagic, error.UnexpectedEndOfFile => { - if (base.tag != .elf) return err; + if (base.tag != .elf and base.tag != .elf2) return err; try loadGnuLdScript(base, path, query, archive.file); archive.file.close(); return; @@ -1091,7 +1091,7 @@ pub const File = struct { errdefer dso.file.close(); loadInput(base, .{ .dso = dso }) catch |err| switch (err) { error.BadMagic, error.UnexpectedEndOfFile => { - if (base.tag != .elf) return err; + if (base.tag != .elf and base.tag != .elf2) return err; try loadGnuLdScript(base, path, query, dso.file); dso.file.close(); return; @@ -1101,8 +1101,9 @@ pub const File = struct { } fn loadGnuLdScript(base: *File, path: Path, parent_query: UnresolvedInput.Query, file: fs.File) anyerror!void { - const diags = &base.comp.link_diags; - const gpa = base.comp.gpa; + const comp = base.comp; + const diags = &comp.link_diags; + const gpa = comp.gpa; const stat = try file.stat(); const size = std.math.cast(u32, stat.size) orelse return error.FileTooBig; const buf = try gpa.alloc(u8, size); @@ -1124,7 +1125,11 @@ pub const File = struct { @panic("TODO"); } else { if (fs.path.isAbsolute(arg.path)) { - const new_path = Path.initCwd(try gpa.dupe(u8, arg.path)); + const new_path = Path.initCwd(path: { + comp.mutex.lock(); + defer comp.mutex.unlock(); + break :path try comp.arena.dupe(u8, arg.path); + }); switch (Compilation.classifyFileExt(arg.path)) { .shared_library => try openLoadDso(base, new_path, query), .object => try openLoadObject(base, new_path), |
