aboutsummaryrefslogtreecommitdiff
path: root/src/link/Dwarf.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-09-13 15:27:25 +0200
committerJakub Konka <kubkon@jakubkonka.com>2022-09-18 10:00:04 +0200
commite601969244d9e3da7f6c88792932297d87c821eb (patch)
tree272c198c88b1edb5f366d20ffa887f4298bba19e /src/link/Dwarf.zig
parent79ab46ec918edc5d31c87a2535a30b8d2207228c (diff)
downloadzig-e601969244d9e3da7f6c88792932297d87c821eb.tar.gz
zig-e601969244d9e3da7f6c88792932297d87c821eb.zip
macho: rewrite how we allocate space in incremental context
Diffstat (limited to 'src/link/Dwarf.zig')
-rw-r--r--src/link/Dwarf.zig17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index 474c822ae6..d7a64bc0d7 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -948,7 +948,7 @@ pub fn commitDeclState(
new_offset,
});
- try File.MachO.copyRangeAllOverlappingAlloc(
+ try copyRangeAllOverlappingAlloc(
gpa,
d_sym.file,
debug_line_sect.offset,
@@ -1247,7 +1247,7 @@ fn writeDeclDebugInfo(self: *Dwarf, file: *File, atom: *Atom, dbg_info_buf: []co
new_offset,
});
- try File.MachO.copyRangeAllOverlappingAlloc(
+ try copyRangeAllOverlappingAlloc(
gpa,
d_sym.file,
debug_info_sect.offset,
@@ -2338,3 +2338,16 @@ fn addDbgInfoErrorSet(
// DW.AT.enumeration_type delimit children
try dbg_info_buffer.append(0);
}
+
+fn copyRangeAllOverlappingAlloc(
+ allocator: Allocator,
+ file: std.fs.File,
+ in_offset: u64,
+ out_offset: u64,
+ len: usize,
+) !void {
+ const buf = try allocator.alloc(u8, len);
+ defer allocator.free(buf);
+ const amt = try file.preadAll(buf, in_offset);
+ try file.pwriteAll(buf[0..amt], out_offset);
+}