diff --git a/src/Elf/Atom.zig b/src/Elf/Atom.zig index f143ce9f..5d816297 100644 --- a/src/Elf/Atom.zig +++ b/src/Elf/Atom.zig @@ -328,13 +328,15 @@ inline fn checkTextReloc(self: Atom, symbol: *const Symbol, elf_file: *Elf) void const is_writeable = self.getInputShdr(elf_file).sh_flags & elf.SHF_WRITE != 0; if (!is_writeable) { if (elf_file.options.z_text) { - elf_file.base.fatal("{s}: relocation against symbol '{s}' in read-only section", .{ + elf_file.base.fatal("{s}: {s}: relocation against symbol '{s}' in read-only section", .{ + self.getObject(elf_file).fmtPath(), self.getName(elf_file), symbol.getName(elf_file), }); } else { // TODO - elf_file.base.fatal("{s}: TODO handle relocations in read-only section", .{ + elf_file.base.fatal("{s}: {s}: TODO handle relocations in read-only section", .{ + self.getObject(elf_file).fmtPath(), self.getName(elf_file), }); } @@ -348,7 +350,8 @@ inline fn unhandledRelocError( action: RelocAction, elf_file: *Elf, ) void { - elf_file.base.fatal("{s}: unhandled {} relocation at offset 0x{x} against symbol '{s}': action {s}", .{ + elf_file.base.fatal("{s}: {s}: unhandled {} relocation at offset 0x{x} against symbol '{s}': action {s}", .{ + self.getObject(elf_file).fmtPath(), self.getName(elf_file), fmtRelocType(rel.r_type()), rel.r_offset, @@ -359,8 +362,9 @@ inline fn unhandledRelocError( inline fn noPicError(self: Atom, symbol: *const Symbol, rel: elf.Elf64_Rela, elf_file: *Elf) void { elf_file.base.fatal( - "{s}: {} relocation at offset 0x{x} against symbol '{s}' cannot be used; recompile with -fno-PIC", + "{s}: {s}: {} relocation at offset 0x{x} against symbol '{s}' cannot be used; recompile with -fno-PIC", .{ + self.getObject(elf_file).fmtPath(), self.getName(elf_file), fmtRelocType(rel.r_type()), rel.r_offset, @@ -371,8 +375,9 @@ inline fn noPicError(self: Atom, symbol: *const Symbol, rel: elf.Elf64_Rela, elf inline fn picError(self: Atom, symbol: *const Symbol, rel: elf.Elf64_Rela, elf_file: *Elf) void { elf_file.base.fatal( - "{s}: {} relocation at offset 0x{x} against symbol '{s}' cannot be used; recompile with -fPIC", + "{s}: {s}: {} relocation at offset 0x{x} against symbol '{s}' cannot be used; recompile with -fPIC", .{ + self.getObject(elf_file).fmtPath(), self.getName(elf_file), fmtRelocType(rel.r_type()), rel.r_offset, diff --git a/src/Elf/Options.zig b/src/Elf/Options.zig index 89939763..5ce41e53 100644 --- a/src/Elf/Options.zig +++ b/src/Elf/Options.zig @@ -15,6 +15,7 @@ const usage = \\--dynamic Alias for --Bdynamic \\--dynamic-linker=[value], -I [value] \\ Set the dynamic linker to use + \\--no-dynamic-linker Don't set the dynamic linker \\--end-group Ignored for compatibility with GNU \\--eh-frame-hdr Create .eh_frame_hdr section (default) \\--export-dynamic, -E Export all dynamic symbols @@ -212,6 +213,8 @@ pub fn parse(arena: Allocator, args: []const []const u8, ctx: anytype) !Options try positionals.append(.{ .tag = .pop_state }); } else if (p.argAny("dynamic-linker")) |path| { opts.dynamic_linker = path; + } else if (p.flagAny("no-dynamic-linker")) { + opts.dynamic_linker = null; } else if (p.arg1("I")) |path| { opts.dynamic_linker = path; } else if (p.flagAny("eh-frame-hdr")) { diff --git a/src/Elf/Symbol.zig b/src/Elf/Symbol.zig index d46de064..7d8e42a6 100644 --- a/src/Elf/Symbol.zig +++ b/src/Elf/Symbol.zig @@ -32,10 +32,8 @@ extra: u32 = 0, pub fn isAbs(symbol: Symbol, elf_file: *Elf) bool { const file = symbol.getFile(elf_file).?; - if (file == .shared) - return symbol.getSourceSymbol(elf_file).st_shndx == elf.SHN_ABS; - - return !symbol.flags.import and symbol.getAtom(elf_file) == null and symbol.shndx == 0; + if (file == .shared) return symbol.getSourceSymbol(elf_file).st_shndx == elf.SHN_ABS; + return !symbol.flags.import and symbol.getAtom(elf_file) == null and symbol.shndx == 0 and file != .internal; } pub fn isLocal(symbol: Symbol) bool {