aboutsummaryrefslogtreecommitdiff
path: root/src/link/MachO.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2020-12-14 17:40:27 +0100
committerJakub Konka <kubkon@jakubkonka.com>2020-12-17 10:04:53 +0100
commitb42ef0e6ea0fed8e592e474bd09e070e10fca920 (patch)
tree7141feb2c606fc78fe548e0b897e4ca4ccb9a540 /src/link/MachO.zig
parent3e9e79378d4776323bb37a3bc1ebf6506efac88d (diff)
downloadzig-b42ef0e6ea0fed8e592e474bd09e070e10fca920.tar.gz
zig-b42ef0e6ea0fed8e592e474bd09e070e10fca920.zip
macho: refactor calculating LEB128 sizes
Diffstat (limited to 'src/link/MachO.zig')
-rw-r--r--src/link/MachO.zig16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig
index e71b89e0b6..a80e272935 100644
--- a/src/link/MachO.zig
+++ b/src/link/MachO.zig
@@ -826,7 +826,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
// Write update dyld info
const dyld_info = self.load_commands.items[self.dyld_info_cmd_index.?].DyldInfoOnly;
{
- const size = self.binding_info_table.calcSize();
+ const size = try self.binding_info_table.calcSize();
assert(dyld_info.bind_size >= size);
var buffer = try self.base.allocator.alloc(u8, size);
@@ -838,7 +838,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
try self.base.file.?.pwriteAll(buffer, dyld_info.bind_off);
}
{
- const size = self.lazy_binding_info_table.calcSize();
+ const size = try self.lazy_binding_info_table.calcSize();
assert(dyld_info.lazy_bind_size >= size);
var buffer = try self.base.allocator.alloc(u8, size);
@@ -2204,15 +2204,3 @@ fn parseLazyBindingInfoTable(self: *MachO) !void {
var stream = std.io.fixedBufferStream(buffer);
try self.lazy_binding_info_table.read(stream.reader(), self.base.allocator);
}
-
-/// Calculates number of bytes in LEB128 encoding of value.
-pub fn sizeLEB128(value: anytype) usize {
- var res: usize = 0;
- var v = value;
- while (true) {
- v = v >> 7;
- res += 1;
- if (v == 0) break;
- }
- return res;
-}