| author | |
| committer | |
| log | af00ac53b50ca9dc606560f106ef17c488e71249 |
| tree | 9dd7a1745d4aacede1f97bea02b6fe573a1c079f |
| parent | a63ce5a37c9655f4f453d848285b85fb91625390 |
3 files changed, 15 insertions(+), 9 deletions(-)
src/link/Elf.zig+1-1| ... | ... | @@ -4098,7 +4098,7 @@ const ErrorWithNotes = struct { |
| 4098 | 4098 | } |
| 4099 | 4099 | }; |
| 4100 | 4100 | |
| 4101 | fn addErrorWithNotes(self: *Elf, note_count: usize) error{OutOfMemory}!ErrorWithNotes { | |
| 4101 | pub fn addErrorWithNotes(self: *Elf, note_count: usize) error{OutOfMemory}!ErrorWithNotes { | |
| 4102 | 4102 | try self.misc_errors.ensureUnusedCapacity(self.base.allocator, 1); |
| 4103 | 4103 | return self.addErrorWithNotesAssumeCapacity(note_count); |
| 4104 | 4104 | } |
src/link/Elf/Atom.zig+12-5| ... | ... | @@ -388,7 +388,17 @@ pub fn scanRelocs(self: Atom, elf_file: *Elf, undefs: anytype) !void { |
| 388 | 388 | |
| 389 | 389 | elf.R_X86_64_PC32 => {}, |
| 390 | 390 | |
| 391 | else => @panic("TODO"), | |
| 391 | else => { | |
| 392 | var err = try elf_file.addErrorWithNotes(1); | |
| 393 | try err.addMsg(elf_file, "fatal linker error: unhandled relocation type {}", .{ | |
| 394 | fmtRelocType(rel.r_type()), | |
| 395 | }); | |
| 396 | try err.addNote(elf_file, "in {}:{s} at offset 0x{x}", .{ | |
| 397 | self.file(elf_file).?.fmtPath(), | |
| 398 | self.name(elf_file), | |
| 399 | rel.r_offset, | |
| 400 | }); | |
| 401 | }, | |
| 392 | 402 | } |
| 393 | 403 | } |
| 394 | 404 | } |
| ... | ... | @@ -512,10 +522,7 @@ pub fn resolveRelocs(self: Atom, elf_file: *Elf, code: []u8) !void { |
| 512 | 522 | try cwriter.writeIntLittle(i32, @as(i32, @intCast(G + GOT + A - P))); |
| 513 | 523 | }, |
| 514 | 524 | |
| 515 | else => { | |
| 516 | log.err("TODO: unhandled relocation type {}", .{fmtRelocType(rel.r_type())}); | |
| 517 | @panic("TODO unhandled relocation type"); | |
| 518 | }, | |
| 525 | else => {}, | |
| 519 | 526 | } |
| 520 | 527 | } |
| 521 | 528 | } |
src/link/Elf/Object.zig+2-3| ... | ... | @@ -233,8 +233,7 @@ fn getOutputSectionIndex(self: *Object, elf_file: *Elf, shdr: elf.Elf64_Shdr) er |
| 233 | 233 | const is_alloc = flags & elf.SHF_ALLOC != 0; |
| 234 | 234 | const is_write = flags & elf.SHF_WRITE != 0; |
| 235 | 235 | const is_exec = flags & elf.SHF_EXECINSTR != 0; |
| 236 | const is_tls = flags & elf.SHF_TLS != 0; | |
| 237 | if (!is_alloc or is_tls) { | |
| 236 | if (!is_alloc) { | |
| 238 | 237 | log.err("{}: output section {s} not found", .{ self.fmtPath(), name }); |
| 239 | 238 | @panic("TODO: missing output section!"); |
| 240 | 239 | } |
| ... | ... | @@ -243,7 +242,7 @@ fn getOutputSectionIndex(self: *Object, elf_file: *Elf, shdr: elf.Elf64_Shdr) er |
| 243 | 242 | if (is_exec) phdr_flags |= elf.PF_X; |
| 244 | 243 | const phdr_index = try elf_file.allocateSegment(.{ |
| 245 | 244 | .size = Elf.padToIdeal(shdr.sh_size), |
| 246 | .alignment = if (is_tls) shdr.sh_addralign else elf_file.page_size, | |
| 245 | .alignment = elf_file.page_size, | |
| 247 | 246 | .flags = phdr_flags, |
| 248 | 247 | }); |
| 249 | 248 | const shndx = try elf_file.allocateAllocSection(.{ |