mirror of
https://github.com/ziglang/zig.git
synced 2025-12-26 08:03:08 +00:00
Revert "macho: allow unaligned offsets in object files"
This reverts commit 45c444ff18b43d30a7277e346174ba6eca4a6193.
This commit is contained in:
parent
74673b7f69
commit
cc56400e62
@ -99,11 +99,10 @@ pub fn parse(self: *Object, allocator: Allocator, cpu_arch: std.Target.Cpu.Arch)
|
||||
},
|
||||
.SYMTAB => {
|
||||
const symtab = cmd.cast(macho.symtab_command).?;
|
||||
// Sadly, SYMTAB may be at an unaligned offset within the object file.
|
||||
self.in_symtab = @alignCast(@alignOf(macho.nlist_64), @ptrCast(
|
||||
[*]align(1) const macho.nlist_64,
|
||||
self.contents.ptr + symtab.symoff,
|
||||
))[0..symtab.nsyms];
|
||||
self.in_symtab = @ptrCast(
|
||||
[*]const macho.nlist_64,
|
||||
@alignCast(@alignOf(macho.nlist_64), &self.contents[symtab.symoff]),
|
||||
)[0..symtab.nsyms];
|
||||
self.in_strtab = self.contents[symtab.stroff..][0..symtab.strsize];
|
||||
try self.symtab.appendSlice(allocator, self.in_symtab);
|
||||
},
|
||||
@ -303,10 +302,10 @@ pub fn splitIntoAtomsOneShot(self: *Object, macho_file: *MachO, object_id: u32)
|
||||
const code: ?[]const u8 = if (!sect.isZerofill()) try self.getSectionContents(sect) else null;
|
||||
|
||||
// Read section's list of relocations
|
||||
const relocs = @alignCast(@alignOf(macho.relocation_info), @ptrCast(
|
||||
[*]align(1) const macho.relocation_info,
|
||||
self.contents.ptr + sect.reloff,
|
||||
))[0..sect.nreloc];
|
||||
const relocs = @ptrCast(
|
||||
[*]const macho.relocation_info,
|
||||
@alignCast(@alignOf(macho.relocation_info), &self.contents[sect.reloff]),
|
||||
)[0..sect.nreloc];
|
||||
|
||||
// Symbols within this section only.
|
||||
const filtered_syms = filterSymbolsByAddress(
|
||||
@ -549,10 +548,10 @@ pub fn parseDataInCode(self: Object) ?[]const macho.data_in_code_entry {
|
||||
.DATA_IN_CODE => {
|
||||
const dice = cmd.cast(macho.linkedit_data_command).?;
|
||||
const ndice = @divExact(dice.datasize, @sizeOf(macho.data_in_code_entry));
|
||||
return @alignCast(@alignOf(macho.data_in_code_entry), @ptrCast(
|
||||
[*]align(1) const macho.data_in_code_entry,
|
||||
self.contents.ptr + dice.dataoff,
|
||||
))[0..ndice];
|
||||
return @ptrCast(
|
||||
[*]const macho.data_in_code_entry,
|
||||
@alignCast(@alignOf(macho.data_in_code_entry), &self.contents[dice.dataoff]),
|
||||
)[0..ndice];
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user