mirror of
https://github.com/ziglang/zig.git
synced 2025-01-06 10:20:26 +00:00
zig objcopy: Fix corrupted hex output
Do not return stack local data for hex record payload data.
This commit is contained in:
parent
0e66df2094
commit
c2d37224c8
@ -432,7 +432,7 @@ const HexWriter = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn getPayloadBytes(self: Record) []const u8 {
|
||||
fn getPayloadBytes(self: *const Record) []const u8 {
|
||||
return switch (self.payload) {
|
||||
.Data => |d| d,
|
||||
.EOF => @as([]const u8, &.{}),
|
||||
@ -518,6 +518,16 @@ fn padFile(f: File, opt_size: ?u64) !void {
|
||||
try f.setEndPos(size);
|
||||
}
|
||||
|
||||
test "HexWriter.Record.Address has correct payload and checksum" {
|
||||
const record = HexWriter.Record.Address(0x0800_0000);
|
||||
const payload = record.getPayloadBytes();
|
||||
const sum = record.checksum();
|
||||
try std.testing.expect(sum == 0xF2);
|
||||
try std.testing.expect(payload.len == 2);
|
||||
try std.testing.expect(payload[0] == 8);
|
||||
try std.testing.expect(payload[1] == 0);
|
||||
}
|
||||
|
||||
test "containsValidAddressRange" {
|
||||
var segment = BinaryElfSegment{
|
||||
.physicalAddress = 0,
|
||||
|
Loading…
Reference in New Issue
Block a user