| ... | @@ -691,7 +691,7 @@ pub const DwarfInfo = struct { | ... | @@ -691,7 +691,7 @@ pub const DwarfInfo = struct { |
| 691 | is_macho: bool, | 691 | is_macho: bool, |
| 692 | | 692 | |
| 693 | pub fn section(di: DwarfInfo, dwarf_section: DwarfSection) ?[]const u8 { | 693 | pub fn section(di: DwarfInfo, dwarf_section: DwarfSection) ?[]const u8 { |
| 694 | return if (di.sections[@enumToInt(dwarf_section)]) |s| s.data else null; | 694 | return if (di.sections[@intFromEnum(dwarf_section)]) |s| s.data else null; |
| 695 | } | 695 | } |
| 696 | | 696 | |
| 697 | pub fn deinit(di: *DwarfInfo, allocator: mem.Allocator) void { | 697 | pub fn deinit(di: *DwarfInfo, allocator: mem.Allocator) void { |
| ... | @@ -1506,12 +1506,12 @@ pub const DwarfInfo = struct { | ... | @@ -1506,12 +1506,12 @@ pub const DwarfInfo = struct { |
| 1506 | if (table_enc == EH.PE.omit) break :blk; | 1506 | if (table_enc == EH.PE.omit) break :blk; |
| 1507 | | 1507 | |
| 1508 | const eh_frame_ptr = std.math.cast(usize, try readEhPointer(reader, eh_frame_ptr_enc, @sizeOf(usize), .{ | 1508 | const eh_frame_ptr = std.math.cast(usize, try readEhPointer(reader, eh_frame_ptr_enc, @sizeOf(usize), .{ |
| 1509 | .pc_rel_base = @ptrToInt(&eh_frame_hdr[stream.pos]), | 1509 | .pc_rel_base = @intFromPtr(&eh_frame_hdr[stream.pos]), |
| 1510 | .follow_indirect = true, | 1510 | .follow_indirect = true, |
| 1511 | }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf(); | 1511 | }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf(); |
| 1512 | | 1512 | |
| 1513 | const fde_count = std.math.cast(usize, try readEhPointer(reader, fde_count_enc, @sizeOf(usize), .{ | 1513 | const fde_count = std.math.cast(usize, try readEhPointer(reader, fde_count_enc, @sizeOf(usize), .{ |
| 1514 | .pc_rel_base = @ptrToInt(&eh_frame_hdr[stream.pos]), | 1514 | .pc_rel_base = @intFromPtr(&eh_frame_hdr[stream.pos]), |
| 1515 | .follow_indirect = true, | 1515 | .follow_indirect = true, |
| 1516 | }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf(); | 1516 | }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf(); |
| 1517 | | 1517 | |
| ... | @@ -1538,7 +1538,7 @@ pub const DwarfInfo = struct { | ... | @@ -1538,7 +1538,7 @@ pub const DwarfInfo = struct { |
| 1538 | .cie => { | 1538 | .cie => { |
| 1539 | const cie = try CommonInformationEntry.parse( | 1539 | const cie = try CommonInformationEntry.parse( |
| 1540 | entry_header.entry_bytes, | 1540 | entry_header.entry_bytes, |
| 1541 | -@intCast(isize, @ptrToInt(binary_mem.ptr)), | 1541 | -@intCast(isize, @intFromPtr(binary_mem.ptr)), |
| 1542 | //@ptrToInt(eh_frame.ptr), | 1542 | //@ptrToInt(eh_frame.ptr), |
| 1543 | //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr), | 1543 | //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr), |
| 1544 | true, | 1544 | true, |
| ... | @@ -1552,7 +1552,7 @@ pub const DwarfInfo = struct { | ... | @@ -1552,7 +1552,7 @@ pub const DwarfInfo = struct { |
| 1552 | const cie = di.cie_map.get(cie_offset) orelse return badDwarf(); | 1552 | const cie = di.cie_map.get(cie_offset) orelse return badDwarf(); |
| 1553 | const fde = try FrameDescriptionEntry.parse( | 1553 | const fde = try FrameDescriptionEntry.parse( |
| 1554 | entry_header.entry_bytes, | 1554 | entry_header.entry_bytes, |
| 1555 | -@intCast(isize, @ptrToInt(binary_mem.ptr)), | 1555 | -@intCast(isize, @intFromPtr(binary_mem.ptr)), |
| 1556 | //@ptrToInt(eh_frame.ptr), | 1556 | //@ptrToInt(eh_frame.ptr), |
| 1557 | //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr), | 1557 | //@ptrToInt(eh_frame.ptr) - @ptrToInt(binary_mem.ptr), |
| 1558 | true, | 1558 | true, |
| ... | @@ -1594,7 +1594,7 @@ pub const DwarfInfo = struct { | ... | @@ -1594,7 +1594,7 @@ pub const DwarfInfo = struct { |
| 1594 | | 1594 | |
| 1595 | if (di.eh_frame_hdr) |header| { | 1595 | if (di.eh_frame_hdr) |header| { |
| 1596 | mapped_pc = context.pc; | 1596 | mapped_pc = context.pc; |
| 1597 | try header.findEntry(context.isValidMemory, @ptrToInt(di.section(.eh_frame_hdr).?.ptr), mapped_pc, &cie, &fde); | 1597 | try header.findEntry(context.isValidMemory, @intFromPtr(di.section(.eh_frame_hdr).?.ptr), mapped_pc, &cie, &fde); |
| 1598 | } else { | 1598 | } else { |
| 1599 | mapped_pc = context.pc - module_base_address; | 1599 | mapped_pc = context.pc - module_base_address; |
| 1600 | const index = std.sort.binarySearch(FrameDescriptionEntry, mapped_pc, di.fde_list.items, {}, struct { | 1600 | const index = std.sort.binarySearch(FrameDescriptionEntry, mapped_pc, di.fde_list.items, {}, struct { |
| ... | @@ -1790,7 +1790,7 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo | ... | @@ -1790,7 +1790,7 @@ fn readEhPointer(reader: anytype, enc: u8, addr_size_bytes: u8, ctx: EhPointerCo |
| 1790 | | 1790 | |
| 1791 | const native_ptr = math.cast(usize, ptr) orelse return error.PointerOverflow; | 1791 | const native_ptr = math.cast(usize, ptr) orelse return error.PointerOverflow; |
| 1792 | return switch (addr_size_bytes) { | 1792 | return switch (addr_size_bytes) { |
| 1793 | 2, 4, 8 => return @intToPtr(*const usize, native_ptr).*, | 1793 | 2, 4, 8 => return @ptrFromInt(*const usize, native_ptr).*, |
| 1794 | else => return error.UnsupportedAddrSize, | 1794 | else => return error.UnsupportedAddrSize, |
| 1795 | }; | 1795 | }; |
| 1796 | } else { | 1796 | } else { |
| ... | @@ -1842,7 +1842,7 @@ pub const ExceptionFrameHeader = struct { | ... | @@ -1842,7 +1842,7 @@ pub const ExceptionFrameHeader = struct { |
| 1842 | | 1842 | |
| 1843 | try stream.seekTo(mid * entry_size); | 1843 | try stream.seekTo(mid * entry_size); |
| 1844 | const pc_begin = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{ | 1844 | const pc_begin = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{ |
| 1845 | .pc_rel_base = @ptrToInt(&self.entries[stream.pos]), | 1845 | .pc_rel_base = @intFromPtr(&self.entries[stream.pos]), |
| 1846 | .follow_indirect = true, | 1846 | .follow_indirect = true, |
| 1847 | .data_rel_base = eh_frame_hdr_ptr, | 1847 | .data_rel_base = eh_frame_hdr_ptr, |
| 1848 | }, builtin.cpu.arch.endian()) orelse return badDwarf(); | 1848 | }, builtin.cpu.arch.endian()) orelse return badDwarf(); |
| ... | @@ -1857,13 +1857,13 @@ pub const ExceptionFrameHeader = struct { | ... | @@ -1857,13 +1857,13 @@ pub const ExceptionFrameHeader = struct { |
| 1857 | | 1857 | |
| 1858 | // Read past pc_begin | 1858 | // Read past pc_begin |
| 1859 | _ = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{ | 1859 | _ = try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{ |
| 1860 | .pc_rel_base = @ptrToInt(&self.entries[stream.pos]), | 1860 | .pc_rel_base = @intFromPtr(&self.entries[stream.pos]), |
| 1861 | .follow_indirect = true, | 1861 | .follow_indirect = true, |
| 1862 | .data_rel_base = eh_frame_hdr_ptr, | 1862 | .data_rel_base = eh_frame_hdr_ptr, |
| 1863 | }, builtin.cpu.arch.endian()) orelse return badDwarf(); | 1863 | }, builtin.cpu.arch.endian()) orelse return badDwarf(); |
| 1864 | | 1864 | |
| 1865 | const fde_ptr = math.cast(usize, try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{ | 1865 | const fde_ptr = math.cast(usize, try readEhPointer(reader, self.table_enc, @sizeOf(usize), .{ |
| 1866 | .pc_rel_base = @ptrToInt(&self.entries[stream.pos]), | 1866 | .pc_rel_base = @intFromPtr(&self.entries[stream.pos]), |
| 1867 | .follow_indirect = true, | 1867 | .follow_indirect = true, |
| 1868 | .data_rel_base = eh_frame_hdr_ptr, | 1868 | .data_rel_base = eh_frame_hdr_ptr, |
| 1869 | }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf(); | 1869 | }, builtin.cpu.arch.endian()) orelse return badDwarf()) orelse return badDwarf(); |
| ... | @@ -1872,20 +1872,20 @@ pub const ExceptionFrameHeader = struct { | ... | @@ -1872,20 +1872,20 @@ pub const ExceptionFrameHeader = struct { |
| 1872 | | 1872 | |
| 1873 | // The length of the .eh_frame section is unknown at this point, since .eh_frame_hdr only provides the start | 1873 | // The length of the .eh_frame section is unknown at this point, since .eh_frame_hdr only provides the start |
| 1874 | if (!isValidMemory(fde_ptr) or fde_ptr < self.eh_frame_ptr) return badDwarf(); | 1874 | if (!isValidMemory(fde_ptr) or fde_ptr < self.eh_frame_ptr) return badDwarf(); |
| 1875 | const eh_frame = @intToPtr([*]const u8, self.eh_frame_ptr)[0..math.maxInt(usize)]; | 1875 | const eh_frame = @ptrFromInt([*]const u8, self.eh_frame_ptr)[0..math.maxInt(usize)]; |
| 1876 | const fde_offset = fde_ptr - self.eh_frame_ptr; | 1876 | const fde_offset = fde_ptr - self.eh_frame_ptr; |
| 1877 | | 1877 | |
| 1878 | var eh_frame_stream = io.fixedBufferStream(eh_frame); | 1878 | var eh_frame_stream = io.fixedBufferStream(eh_frame); |
| 1879 | try eh_frame_stream.seekTo(fde_offset); | 1879 | try eh_frame_stream.seekTo(fde_offset); |
| 1880 | | 1880 | |
| 1881 | const fde_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian()); | 1881 | const fde_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian()); |
| 1882 | if (!isValidMemory(@ptrToInt(&fde_entry_header.entry_bytes[fde_entry_header.entry_bytes.len - 1]))) return badDwarf(); | 1882 | if (!isValidMemory(@intFromPtr(&fde_entry_header.entry_bytes[fde_entry_header.entry_bytes.len - 1]))) return badDwarf(); |
| 1883 | if (fde_entry_header.type != .fde) return badDwarf(); | 1883 | if (fde_entry_header.type != .fde) return badDwarf(); |
| 1884 | | 1884 | |
| 1885 | const cie_offset = fde_entry_header.type.fde; | 1885 | const cie_offset = fde_entry_header.type.fde; |
| 1886 | try eh_frame_stream.seekTo(cie_offset); | 1886 | try eh_frame_stream.seekTo(cie_offset); |
| 1887 | const cie_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian()); | 1887 | const cie_entry_header = try EntryHeader.read(&eh_frame_stream, builtin.cpu.arch.endian()); |
| 1888 | if (!isValidMemory(@ptrToInt(&cie_entry_header.entry_bytes[cie_entry_header.entry_bytes.len - 1]))) return badDwarf(); | 1888 | if (!isValidMemory(@intFromPtr(&cie_entry_header.entry_bytes[cie_entry_header.entry_bytes.len - 1]))) return badDwarf(); |
| 1889 | if (cie_entry_header.type != .cie) return badDwarf(); | 1889 | if (cie_entry_header.type != .cie) return badDwarf(); |
| 1890 | | 1890 | |
| 1891 | cie.* = try CommonInformationEntry.parse( | 1891 | cie.* = try CommonInformationEntry.parse( |
| ... | @@ -2083,7 +2083,7 @@ pub const CommonInformationEntry = struct { | ... | @@ -2083,7 +2083,7 @@ pub const CommonInformationEntry = struct { |
| 2083 | personality_enc.?, | 2083 | personality_enc.?, |
| 2084 | addr_size_bytes, | 2084 | addr_size_bytes, |
| 2085 | .{ | 2085 | .{ |
| 2086 | .pc_rel_base = try pcRelBase(@ptrToInt(&cie_bytes[stream.pos]), pc_rel_offset), | 2086 | .pc_rel_base = try pcRelBase(@intFromPtr(&cie_bytes[stream.pos]), pc_rel_offset), |
| 2087 | .follow_indirect = is_runtime, | 2087 | .follow_indirect = is_runtime, |
| 2088 | }, | 2088 | }, |
| 2089 | endian, | 2089 | endian, |
| ... | @@ -2161,7 +2161,7 @@ pub const FrameDescriptionEntry = struct { | ... | @@ -2161,7 +2161,7 @@ pub const FrameDescriptionEntry = struct { |
| 2161 | cie.fde_pointer_enc, | 2161 | cie.fde_pointer_enc, |
| 2162 | addr_size_bytes, | 2162 | addr_size_bytes, |
| 2163 | .{ | 2163 | .{ |
| 2164 | .pc_rel_base = try pcRelBase(@ptrToInt(&fde_bytes[stream.pos]), pc_rel_offset), | 2164 | .pc_rel_base = try pcRelBase(@intFromPtr(&fde_bytes[stream.pos]), pc_rel_offset), |
| 2165 | .follow_indirect = is_runtime, | 2165 | .follow_indirect = is_runtime, |
| 2166 | }, | 2166 | }, |
| 2167 | endian, | 2167 | endian, |
| ... | @@ -2190,7 +2190,7 @@ pub const FrameDescriptionEntry = struct { | ... | @@ -2190,7 +2190,7 @@ pub const FrameDescriptionEntry = struct { |
| 2190 | cie.lsda_pointer_enc, | 2190 | cie.lsda_pointer_enc, |
| 2191 | addr_size_bytes, | 2191 | addr_size_bytes, |
| 2192 | .{ | 2192 | .{ |
| 2193 | .pc_rel_base = try pcRelBase(@ptrToInt(&fde_bytes[stream.pos]), pc_rel_offset), | 2193 | .pc_rel_base = try pcRelBase(@intFromPtr(&fde_bytes[stream.pos]), pc_rel_offset), |
| 2194 | .follow_indirect = is_runtime, | 2194 | .follow_indirect = is_runtime, |
| 2195 | }, | 2195 | }, |
| 2196 | endian, | 2196 | endian, |