mirror of
https://github.com/ziglang/zig.git
synced 2026-01-10 17:35:12 +00:00
zld: fix the linker for 32bit comp targets
This commit is contained in:
parent
a9dd8d7543
commit
d1f60a63bd
@ -58,7 +58,7 @@ const ar_hdr = extern struct {
|
||||
|
||||
const NameOrLength = union(enum) {
|
||||
Name: []const u8,
|
||||
Length: u64,
|
||||
Length: u32,
|
||||
};
|
||||
fn nameOrLength(self: ar_hdr) !NameOrLength {
|
||||
const value = getValue(&self.ar_name);
|
||||
@ -70,14 +70,14 @@ const ar_hdr = extern struct {
|
||||
} else {
|
||||
// Name follows the header directly and its length is encoded in
|
||||
// the name field.
|
||||
const length = try std.fmt.parseInt(u64, value[slash_index + 1 ..], 10);
|
||||
const length = try std.fmt.parseInt(u32, value[slash_index + 1 ..], 10);
|
||||
return NameOrLength{ .Length = length };
|
||||
}
|
||||
}
|
||||
|
||||
fn size(self: ar_hdr) !u64 {
|
||||
fn size(self: ar_hdr) !u32 {
|
||||
const value = getValue(&self.ar_size);
|
||||
return std.fmt.parseInt(u64, value, 10);
|
||||
return std.fmt.parseInt(u32, value, 10);
|
||||
}
|
||||
|
||||
fn getValue(raw: []const u8) []const u8 {
|
||||
|
||||
@ -284,7 +284,7 @@ pub fn parseSections(self: *Object) !void {
|
||||
for (seg.sections.items) |sect| {
|
||||
log.debug("parsing section '{s},{s}'", .{ parseName(§.segname), parseName(§.sectname) });
|
||||
// Read sections' code
|
||||
var code = try self.allocator.alloc(u8, sect.size);
|
||||
var code = try self.allocator.alloc(u8, @intCast(usize, sect.size));
|
||||
_ = try self.file.?.preadAll(code, sect.offset);
|
||||
|
||||
var section = Section{
|
||||
@ -461,7 +461,7 @@ pub fn parseDebugInfo(self: *Object) !void {
|
||||
fn readSection(self: Object, allocator: *Allocator, index: u16) ![]u8 {
|
||||
const seg = self.load_commands.items[self.segment_cmd_index.?].Segment;
|
||||
const sect = seg.sections.items[index];
|
||||
var buffer = try allocator.alloc(u8, sect.size);
|
||||
var buffer = try allocator.alloc(u8, @intCast(usize, sect.size));
|
||||
_ = try self.file.?.preadAll(buffer, sect.offset);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@ -2214,7 +2214,7 @@ fn flush(self: *Zld) !void {
|
||||
const seg = self.load_commands.items[self.data_segment_cmd_index.?].Segment;
|
||||
const sect = &seg.sections.items[index];
|
||||
|
||||
var buffer = try self.allocator.alloc(u8, sect.size);
|
||||
var buffer = try self.allocator.alloc(u8, @intCast(usize, sect.size));
|
||||
defer self.allocator.free(buffer);
|
||||
_ = try self.file.?.preadAll(buffer, sect.offset);
|
||||
|
||||
|
||||
@ -179,12 +179,12 @@ pub fn parse(
|
||||
|
||||
pub const RelocIterator = struct {
|
||||
buffer: []const macho.relocation_info,
|
||||
index: i64 = -1,
|
||||
index: i32 = -1,
|
||||
|
||||
pub fn next(self: *RelocIterator) ?macho.relocation_info {
|
||||
self.index += 1;
|
||||
if (self.index < self.buffer.len) {
|
||||
const reloc = self.buffer[@intCast(u64, self.index)];
|
||||
const reloc = self.buffer[@intCast(u32, self.index)];
|
||||
log.debug("relocation", .{});
|
||||
log.debug(" | type = {}", .{reloc.r_type});
|
||||
log.debug(" | offset = {}", .{reloc.r_address});
|
||||
@ -199,6 +199,6 @@ pub const RelocIterator = struct {
|
||||
|
||||
pub fn peek(self: RelocIterator) macho.relocation_info {
|
||||
assert(self.index + 1 < self.buffer.len);
|
||||
return self.buffer[@intCast(u64, self.index + 1)];
|
||||
return self.buffer[@intCast(u32, self.index + 1)];
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user