| author | |
| committer | |
| log | 7305184203dd94fd48da69f8a468b3094b848533 |
| tree | c176221151b9079e54e5977f5e9f1a027b5d9c1d |
| parent | f0c0f697a6be87f1e926a03b6a61579cddde08e7 |
3 files changed, 11 insertions(+), 47 deletions(-)
src/link/Dwarf.zig+1-1| ... | ... | @@ -3825,7 +3825,7 @@ pub fn flushModule(dwarf: *Dwarf, pt: Zcu.PerThread) FlushError!void { |
| 3825 | 3825 | sleb128(header.fixedWriter(), dwarf.debug_frame.header.data_alignment_factor) catch unreachable; |
| 3826 | 3826 | uleb128(header.fixedWriter(), dwarf.debug_frame.header.return_address_register) catch unreachable; |
| 3827 | 3827 | uleb128(header.fixedWriter(), 1) catch unreachable; |
| 3828 | header.appendAssumeCapacity(0x10 | 0x08 | 0x03); | |
| 3828 | header.appendAssumeCapacity(DW.EH.PE.pcrel | DW.EH.PE.sdata4); | |
| 3829 | 3829 | header.appendAssumeCapacity(DW.CFA.def_cfa_sf); |
| 3830 | 3830 | uleb128(header.fixedWriter(), Register.rsp.dwarfNum()) catch unreachable; |
| 3831 | 3831 | sleb128(header.fixedWriter(), -1) catch unreachable; |
src/link/Elf/eh_frame.zig+4-22| ... | ... | @@ -482,9 +482,9 @@ pub fn writeEhFrameHdr(elf_file: *Elf, writer: anytype) !void { |
| 482 | 482 | const gpa = comp.gpa; |
| 483 | 483 | |
| 484 | 484 | try writer.writeByte(1); // version |
| 485 | try writer.writeByte(EH_PE.pcrel | EH_PE.sdata4); | |
| 486 | try writer.writeByte(EH_PE.udata4); | |
| 487 | try writer.writeByte(EH_PE.datarel | EH_PE.sdata4); | |
| 485 | try writer.writeByte(DW_EH_PE.pcrel | DW_EH_PE.sdata4); | |
| 486 | try writer.writeByte(DW_EH_PE.udata4); | |
| 487 | try writer.writeByte(DW_EH_PE.datarel | DW_EH_PE.sdata4); | |
| 488 | 488 | |
| 489 | 489 | const shdrs = elf_file.sections.items(.shdr); |
| 490 | 490 | const eh_frame_shdr = shdrs[elf_file.eh_frame_section_index.?]; |
| ... | ... | @@ -543,25 +543,6 @@ pub fn writeEhFrameHdr(elf_file: *Elf, writer: anytype) !void { |
| 543 | 543 | |
| 544 | 544 | const eh_frame_hdr_header_size: usize = 12; |
| 545 | 545 | |
| 546 | const EH_PE = struct { | |
| 547 | pub const absptr = 0x00; | |
| 548 | pub const uleb128 = 0x01; | |
| 549 | pub const udata2 = 0x02; | |
| 550 | pub const udata4 = 0x03; | |
| 551 | pub const udata8 = 0x04; | |
| 552 | pub const sleb128 = 0x09; | |
| 553 | pub const sdata2 = 0x0A; | |
| 554 | pub const sdata4 = 0x0B; | |
| 555 | pub const sdata8 = 0x0C; | |
| 556 | pub const pcrel = 0x10; | |
| 557 | pub const textrel = 0x20; | |
| 558 | pub const datarel = 0x30; | |
| 559 | pub const funcrel = 0x40; | |
| 560 | pub const aligned = 0x50; | |
| 561 | pub const indirect = 0x80; | |
| 562 | pub const omit = 0xFF; | |
| 563 | }; | |
| 564 | ||
| 565 | 546 | const x86_64 = struct { |
| 566 | 547 | fn resolveReloc(rec: anytype, elf_file: *Elf, rel: elf.Elf64_Rela, source: i64, target: i64, data: []u8) !void { |
| 567 | 548 | const r_type: elf.R_X86_64 = @enumFromInt(rel.r_type()); |
| ... | ... | @@ -619,6 +600,7 @@ const relocation = @import("relocation.zig"); |
| 619 | 600 | |
| 620 | 601 | const Allocator = std.mem.Allocator; |
| 621 | 602 | const Atom = @import("Atom.zig"); |
| 603 | const DW_EH_PE = std.dwarf.EH.PE; | |
| 622 | 604 | const Elf = @import("../Elf.zig"); |
| 623 | 605 | const Object = @import("Object.zig"); |
| 624 | 606 | const Symbol = @import("Symbol.zig"); |
src/link/MachO/eh_frame.zig+6-24| ... | ... | @@ -29,22 +29,22 @@ pub const Cie = struct { |
| 29 | 29 | for (aug[1..]) |ch| switch (ch) { |
| 30 | 30 | 'R' => { |
| 31 | 31 | const enc = try reader.readByte(); |
| 32 | if (enc & 0xf != EH_PE.absptr or enc & EH_PE.pcrel == 0) { | |
| 32 | if (enc != DW_EH_PE.pcrel | DW_EH_PE.absptr) { | |
| 33 | 33 | @panic("unexpected pointer encoding"); // TODO error |
| 34 | 34 | } |
| 35 | 35 | }, |
| 36 | 36 | 'P' => { |
| 37 | 37 | const enc = try reader.readByte(); |
| 38 | if (enc != EH_PE.pcrel | EH_PE.indirect | EH_PE.sdata4) { | |
| 38 | if (enc != DW_EH_PE.pcrel | DW_EH_PE.indirect | DW_EH_PE.sdata4) { | |
| 39 | 39 | @panic("unexpected personality pointer encoding"); // TODO error |
| 40 | 40 | } |
| 41 | 41 | _ = try reader.readInt(u32, .little); // personality pointer |
| 42 | 42 | }, |
| 43 | 43 | 'L' => { |
| 44 | 44 | const enc = try reader.readByte(); |
| 45 | switch (enc & 0xf) { | |
| 46 | EH_PE.sdata4 => cie.lsda_size = .p32, | |
| 47 | EH_PE.absptr => cie.lsda_size = .p64, | |
| 45 | switch (enc & DW_EH_PE.type_mask) { | |
| 46 | DW_EH_PE.sdata4 => cie.lsda_size = .p32, | |
| 47 | DW_EH_PE.absptr => cie.lsda_size = .p64, | |
| 48 | 48 | else => unreachable, // TODO error |
| 49 | 49 | } |
| 50 | 50 | }, |
| ... | ... | @@ -538,25 +538,6 @@ pub fn writeRelocs(macho_file: *MachO, code: []u8, relocs: []macho.relocation_in |
| 538 | 538 | assert(relocs.len == i); |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | pub const EH_PE = struct { | |
| 542 | pub const absptr = 0x00; | |
| 543 | pub const uleb128 = 0x01; | |
| 544 | pub const udata2 = 0x02; | |
| 545 | pub const udata4 = 0x03; | |
| 546 | pub const udata8 = 0x04; | |
| 547 | pub const sleb128 = 0x09; | |
| 548 | pub const sdata2 = 0x0A; | |
| 549 | pub const sdata4 = 0x0B; | |
| 550 | pub const sdata8 = 0x0C; | |
| 551 | pub const pcrel = 0x10; | |
| 552 | pub const textrel = 0x20; | |
| 553 | pub const datarel = 0x30; | |
| 554 | pub const funcrel = 0x40; | |
| 555 | pub const aligned = 0x50; | |
| 556 | pub const indirect = 0x80; | |
| 557 | pub const omit = 0xFF; | |
| 558 | }; | |
| 559 | ||
| 560 | 541 | const assert = std.debug.assert; |
| 561 | 542 | const leb = std.leb; |
| 562 | 543 | const macho = std.macho; |
| ... | ... | @@ -567,6 +548,7 @@ const trace = @import("../../tracy.zig").trace; |
| 567 | 548 | |
| 568 | 549 | const Allocator = std.mem.Allocator; |
| 569 | 550 | const Atom = @import("Atom.zig"); |
| 551 | const DW_EH_PE = std.dwarf.EH.PE; | |
| 570 | 552 | const File = @import("file.zig").File; |
| 571 | 553 | const MachO = @import("../MachO.zig"); |
| 572 | 554 | const Object = @import("Object.zig"); |