aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Bradshaw <github@mjb.io>2024-06-10 07:43:22 -0600
committerMatthew Lugg <mlugg@mlugg.co.uk>2024-06-23 04:30:12 +0100
commit642093e04bf10f6a9a7c23dfcf219bbbc7d51b54 (patch)
treea3945fb11a5a6f71834b9aae2d163dd67f14fa46 /src
parent0fcd59eadae468284943895f50bc9fc6d1924154 (diff)
downloadzig-642093e04bf10f6a9a7c23dfcf219bbbc7d51b54.tar.gz
zig-642093e04bf10f6a9a7c23dfcf219bbbc7d51b54.zip
Rename *[UI]LEB128 functions to *[UI]leb128
Diffstat (limited to 'src')
-rw-r--r--src/arch/wasm/CodeGen.zig36
-rw-r--r--src/arch/wasm/Emit.zig42
-rw-r--r--src/link/Dwarf.zig116
-rw-r--r--src/link/MachO/Dylib.zig18
-rw-r--r--src/link/MachO/dwarf.zig30
-rw-r--r--src/link/MachO/dyld_info/Rebase.zig12
-rw-r--r--src/link/MachO/dyld_info/Trie.zig24
-rw-r--r--src/link/MachO/dyld_info/bind.zig14
-rw-r--r--src/link/MachO/eh_frame.zig10
-rw-r--r--src/link/Wasm.zig256
-rw-r--r--src/link/Wasm/Object.zig64
11 files changed, 311 insertions, 311 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index bb19cde588..b871a7b885 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -7374,7 +7374,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
var writer = body_list.writer();
// The locals of the function body (always 0)
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
// outer block
try writer.writeByte(std.wasm.opcode(.block));
@@ -7408,7 +7408,7 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
// get actual tag value (stored in 2nd parameter);
try writer.writeByte(std.wasm.opcode(.local_get));
- try leb.writeULEB128(writer, @as(u32, 1));
+ try leb.writeUleb128(writer, @as(u32, 1));
const tag_val = try mod.enumValueFieldIndex(enum_ty, @intCast(tag_index));
const tag_value = try func.lowerConstant(tag_val, enum_ty);
@@ -7416,26 +7416,26 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
switch (tag_value) {
.imm32 => |value| {
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeILEB128(writer, @as(i32, @bitCast(value)));
+ try leb.writeIleb128(writer, @as(i32, @bitCast(value)));
try writer.writeByte(std.wasm.opcode(.i32_ne));
},
.imm64 => |value| {
try writer.writeByte(std.wasm.opcode(.i64_const));
- try leb.writeILEB128(writer, @as(i64, @bitCast(value)));
+ try leb.writeIleb128(writer, @as(i64, @bitCast(value)));
try writer.writeByte(std.wasm.opcode(.i64_ne));
},
else => unreachable,
}
// if they're not equal, break out of current branch
try writer.writeByte(std.wasm.opcode(.br_if));
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
// store the address of the tagname in the pointer field of the slice
// get the address twice so we can also store the length.
try writer.writeByte(std.wasm.opcode(.local_get));
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
try writer.writeByte(std.wasm.opcode(.local_get));
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
// get address of tagname and emit a relocation to it
if (func.arch() == .wasm32) {
@@ -7450,15 +7450,15 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
// store pointer
try writer.writeByte(std.wasm.opcode(.i32_store));
- try leb.writeULEB128(writer, encoded_alignment);
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, encoded_alignment);
+ try leb.writeUleb128(writer, @as(u32, 0));
// store length
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeULEB128(writer, @as(u32, @intCast(tag_name_len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(tag_name_len)));
try writer.writeByte(std.wasm.opcode(.i32_store));
- try leb.writeULEB128(writer, encoded_alignment);
- try leb.writeULEB128(writer, @as(u32, 4));
+ try leb.writeUleb128(writer, encoded_alignment);
+ try leb.writeUleb128(writer, @as(u32, 4));
} else {
const encoded_alignment = @ctz(@as(u32, 8));
try writer.writeByte(std.wasm.opcode(.i64_const));
@@ -7471,20 +7471,20 @@ fn getTagNameFunction(func: *CodeGen, enum_ty: Type) InnerError!u32 {
// store pointer
try writer.writeByte(std.wasm.opcode(.i64_store));
- try leb.writeULEB128(writer, encoded_alignment);
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, encoded_alignment);
+ try leb.writeUleb128(writer, @as(u32, 0));
// store length
try writer.writeByte(std.wasm.opcode(.i64_const));
- try leb.writeULEB128(writer, @as(u64, @intCast(tag_name_len)));
+ try leb.writeUleb128(writer, @as(u64, @intCast(tag_name_len)));
try writer.writeByte(std.wasm.opcode(.i64_store));
- try leb.writeULEB128(writer, encoded_alignment);
- try leb.writeULEB128(writer, @as(u32, 8));
+ try leb.writeUleb128(writer, encoded_alignment);
+ try leb.writeUleb128(writer, @as(u32, 8));
}
// break outside blocks
try writer.writeByte(std.wasm.opcode(.br));
- try leb.writeULEB128(writer, @as(u32, 1));
+ try leb.writeUleb128(writer, @as(u32, 1));
// end the block for this case
try writer.writeByte(std.wasm.opcode(.end));
diff --git a/src/arch/wasm/Emit.zig b/src/arch/wasm/Emit.zig
index df7a9d9d90..716e6e3b94 100644
--- a/src/arch/wasm/Emit.zig
+++ b/src/arch/wasm/Emit.zig
@@ -265,10 +265,10 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
fn emitLocals(emit: *Emit) !void {
const writer = emit.code.writer();
- try leb128.writeULEB128(writer, @as(u32, @intCast(emit.locals.len)));
+ try leb128.writeUleb128(writer, @as(u32, @intCast(emit.locals.len)));
// emit the actual locals amount
for (emit.locals) |local| {
- try leb128.writeULEB128(writer, @as(u32, 1));
+ try leb128.writeUleb128(writer, @as(u32, 1));
try writer.writeByte(local);
}
}
@@ -290,16 +290,16 @@ fn emitBrTable(emit: *Emit, inst: Mir.Inst.Index) !void {
const writer = emit.code.writer();
try emit.code.append(std.wasm.opcode(.br_table));
- try leb128.writeULEB128(writer, extra.data.length - 1); // Default label is not part of length/depth
+ try leb128.writeUleb128(writer, extra.data.length - 1); // Default label is not part of length/depth
for (labels) |label| {
- try leb128.writeULEB128(writer, label);
+ try leb128.writeUleb128(writer, label);
}
}
fn emitLabel(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
const label = emit.mir.instructions.items(.data)[inst].label;
try emit.code.append(@intFromEnum(tag));
- try leb128.writeULEB128(emit.code.writer(), label);
+ try leb128.writeUleb128(emit.code.writer(), label);
}
fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
@@ -324,14 +324,14 @@ fn emitGlobal(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
fn emitImm32(emit: *Emit, inst: Mir.Inst.Index) !void {
const value: i32 = emit.mir.instructions.items(.data)[inst].imm32;
try emit.code.append(std.wasm.opcode(.i32_const));
- try leb128.writeILEB128(emit.code.writer(), value);
+ try leb128.writeIleb128(emit.code.writer(), value);
}
fn emitImm64(emit: *Emit, inst: Mir.Inst.Index) !void {
const extra_index = emit.mir.instructions.items(.data)[inst].payload;
const value = emit.mir.extraData(Mir.Imm64, extra_index);
try emit.code.append(std.wasm.opcode(.i64_const));
- try leb128.writeILEB128(emit.code.writer(), @as(i64, @bitCast(value.data.toU64())));
+ try leb128.writeIleb128(emit.code.writer(), @as(i64, @bitCast(value.data.toU64())));
}
fn emitFloat32(emit: *Emit, inst: Mir.Inst.Index) !void {
@@ -357,8 +357,8 @@ fn emitMemArg(emit: *Emit, tag: Mir.Inst.Tag, inst: Mir.Inst.Index) !void {
fn encodeMemArg(mem_arg: Mir.MemArg, writer: anytype) !void {
// wasm encodes alignment as power of 2, rather than natural alignment
const encoded_alignment = @ctz(mem_arg.alignment);
- try leb128.writeULEB128(writer, encoded_alignment);
- try leb128.writeULEB128(writer, mem_arg.offset);
+ try leb128.writeUleb128(writer, encoded_alignment);
+ try leb128.writeUleb128(writer, mem_arg.offset);
}
fn emitCall(emit: *Emit, inst: Mir.Inst.Index) !void {
@@ -400,7 +400,7 @@ fn emitCallIndirect(emit: *Emit, inst: Mir.Inst.Index) !void {
.relocation_type = .R_WASM_TYPE_INDEX_LEB,
});
}
- try leb128.writeULEB128(emit.code.writer(), @as(u32, 0)); // TODO: Emit relocation for table index
+ try leb128.writeUleb128(emit.code.writer(), @as(u32, 0)); // TODO: Emit relocation for table index
}
fn emitFunctionIndex(emit: *Emit, inst: Mir.Inst.Index) !void {
@@ -461,24 +461,24 @@ fn emitExtended(emit: *Emit, inst: Mir.Inst.Index) !void {
const opcode = emit.mir.extra[extra_index];
const writer = emit.code.writer();
try emit.code.append(std.wasm.opcode(.misc_prefix));
- try leb128.writeULEB128(writer, opcode);
+ try leb128.writeUleb128(writer, opcode);
switch (@as(std.wasm.MiscOpcode, @enumFromInt(opcode))) {
// bulk-memory opcodes
.data_drop => {
const segment = emit.mir.extra[extra_index + 1];
- try leb128.writeULEB128(writer, segment);
+ try leb128.writeUleb128(writer, segment);
},
.memory_init => {
const segment = emit.mir.extra[extra_index + 1];
- try leb128.writeULEB128(writer, segment);
- try leb128.writeULEB128(writer, @as(u32, 0)); // memory index
+ try leb128.writeUleb128(writer, segment);
+ try leb128.writeUleb128(writer, @as(u32, 0)); // memory index
},
.memory_fill => {
- try leb128.writeULEB128(writer, @as(u32, 0)); // memory index
+ try leb128.writeUleb128(writer, @as(u32, 0)); // memory index
},
.memory_copy => {
- try leb128.writeULEB128(writer, @as(u32, 0)); // dst memory index
- try leb128.writeULEB128(writer, @as(u32, 0)); // src memory index
+ try leb128.writeUleb128(writer, @as(u32, 0)); // dst memory index
+ try leb128.writeUleb128(writer, @as(u32, 0)); // src memory index
},
// nontrapping-float-to-int-conversion opcodes
@@ -500,7 +500,7 @@ fn emitSimd(emit: *Emit, inst: Mir.Inst.Index) !void {
const opcode = emit.mir.extra[extra_index];
const writer = emit.code.writer();
try emit.code.append(std.wasm.opcode(.simd_prefix));
- try leb128.writeULEB128(writer, opcode);
+ try leb128.writeUleb128(writer, opcode);
switch (@as(std.wasm.SimdOpcode, @enumFromInt(opcode))) {
.v128_store,
.v128_load,
@@ -551,7 +551,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void {
const opcode = emit.mir.extra[extra_index];
const writer = emit.code.writer();
try emit.code.append(std.wasm.opcode(.atomics_prefix));
- try leb128.writeULEB128(writer, opcode);
+ try leb128.writeUleb128(writer, opcode);
switch (@as(std.wasm.AtomicsOpcode, @enumFromInt(opcode))) {
.i32_atomic_load,
.i64_atomic_load,
@@ -625,7 +625,7 @@ fn emitAtomic(emit: *Emit, inst: Mir.Inst.Index) !void {
// TODO: When multi-memory proposal is accepted and implemented in the compiler,
// change this to (user-)specified index, rather than hardcode it to memory index 0.
const memory_index: u32 = 0;
- try leb128.writeULEB128(writer, memory_index);
+ try leb128.writeUleb128(writer, memory_index);
},
else => |tag| return emit.fail("TODO: Implement atomic instruction: {s}", .{@tagName(tag)}),
}
@@ -637,7 +637,7 @@ fn emitMemFill(emit: *Emit) !void {
// When multi-memory proposal reaches phase 4, we
// can emit a different memory index here.
// For now we will always emit index 0.
- try leb128.writeULEB128(emit.code.writer(), @as(u32, 0));
+ try leb128.writeUleb128(emit.code.writer(), @as(u32, 0));
}
fn emitDbgLine(emit: *Emit, inst: Mir.Inst.Index) !void {
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig
index 88d2d13e19..ccfdfd0dbf 100644
--- a/src/link/Dwarf.zig
+++ b/src/link/Dwarf.zig
@@ -148,7 +148,7 @@ pub const DeclState = struct {
// DW.AT.encoding, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(DW.ATE.boolean);
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
+ try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod));
// DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
},
@@ -162,7 +162,7 @@ pub const DeclState = struct {
.unsigned => DW.ATE.unsigned,
});
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
+ try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod));
// DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
},
@@ -173,7 +173,7 @@ pub const DeclState = struct {
// DW.AT.encoding, DW.FORM.data1
dbg_info_buffer.appendAssumeCapacity(DW.ATE.address);
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
+ try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod));
// DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
} else {
@@ -183,7 +183,7 @@ pub const DeclState = struct {
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type));
// DW.AT.byte_size, DW.FORM.udata
const abi_size = ty.abiSize(mod);
- try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), abi_size);
// DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
// DW.AT.member
@@ -209,7 +209,7 @@ pub const DeclState = struct {
try self.addTypeRelocGlobal(atom_index, payload_ty, @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
const offset = abi_size - payload_ty.abiSize(mod);
- try leb128.writeULEB128(dbg_info_buffer.writer(), offset);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), offset);
// DW.AT.structure_type delimit children
try dbg_info_buffer.append(0);
}
@@ -223,7 +223,7 @@ pub const DeclState = struct {
try dbg_info_buffer.ensureUnusedCapacity(2);
dbg_info_buffer.appendAssumeCapacity(@intFromEnum(AbbrevCode.struct_type));
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
+ try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod));
// DW.AT.name, DW.FORM.string
try dbg_info_buffer.writer().print("{}\x00", .{ty.fmt(mod)});
// DW.AT.member
@@ -279,7 +279,7 @@ pub const DeclState = struct {
try self.addTypeRelocGlobal(atom_index, Type.usize, @intCast(index));
// DW.AT.count, DW.FORM.udata
const len = ty.arrayLenIncludingSentinel(mod);
- try leb128.writeULEB128(dbg_info_buffer.writer(), len);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), len);
// DW.AT.array_type delimit children
try dbg_info_buffer.append(0);
},
@@ -287,7 +287,7 @@ pub const DeclState = struct {
// DW.AT.structure_type
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type));
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
+ try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod));
blk: {
switch (ip.indexToKey(ty.ip_index)) {
@@ -306,7 +306,7 @@ pub const DeclState = struct {
try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
const field_off = ty.structFieldOffset(field_index, mod);
- try leb128.writeULEB128(dbg_info_buffer.writer(), field_off);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), field_off);
}
},
.struct_type => {
@@ -332,7 +332,7 @@ pub const DeclState = struct {
try dbg_info_buffer.appendNTimes(0, 4);
try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), field_off);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), field_off);
}
} else {
for (
@@ -352,7 +352,7 @@ pub const DeclState = struct {
try dbg_info_buffer.appendNTimes(0, 4);
try self.addTypeRelocGlobal(atom_index, Type.fromInterned(field_ty), @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), field_off);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), field_off);
}
}
},
@@ -367,7 +367,7 @@ pub const DeclState = struct {
// DW.AT.enumeration_type
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.enum_type));
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), ty.abiSize(mod));
+ try leb128.writeUleb128(dbg_info_buffer.writer(), ty.abiSize(mod));
// DW.AT.name, DW.FORM.string
try ty.print(dbg_info_buffer.writer(), mod);
try dbg_info_buffer.append(0);
@@ -408,7 +408,7 @@ pub const DeclState = struct {
// DW.AT.structure_type
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type));
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), layout.abi_size);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), layout.abi_size);
// DW.AT.name, DW.FORM.string
try ty.print(dbg_info_buffer.writer(), mod);
try dbg_info_buffer.append(0);
@@ -424,13 +424,13 @@ pub const DeclState = struct {
dbg_info_buffer.appendNTimesAssumeCapacity(0, 4);
try self.addTypeRelocLocal(atom_index, @intCast(inner_union_index), 5);
// DW.AT.data_member_location, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), payload_offset);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), payload_offset);
}
// DW.AT.union_type
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.union_type));
// DW.AT.byte_size, DW.FORM.udata,
- try leb128.writeULEB128(dbg_info_buffer.writer(), layout.payload_size);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), layout.payload_size);
// DW.AT.name, DW.FORM.string
if (is_tagged) {
try dbg_info_buffer.writer().print("AnonUnion\x00", .{});
@@ -468,7 +468,7 @@ pub const DeclState = struct {
dbg_info_buffer.appendNTimesAssumeCapacity(0, 4);
try self.addTypeRelocGlobal(atom_index, Type.fromInterned(union_obj.enum_tag_ty), @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), tag_offset);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), tag_offset);
// DW.AT.structure_type delimit children
try dbg_info_buffer.append(0);
@@ -487,7 +487,7 @@ pub const DeclState = struct {
// DW.AT.structure_type
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.struct_type));
// DW.AT.byte_size, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), abi_size);
// DW.AT.name, DW.FORM.string
try ty.print(dbg_info_buffer.writer(), mod);
try dbg_info_buffer.append(0);
@@ -504,7 +504,7 @@ pub const DeclState = struct {
dbg_info_buffer.appendNTimesAssumeCapacity(0, 4);
try self.addTypeRelocGlobal(atom_index, payload_ty, @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), payload_off);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), payload_off);
}
{
@@ -519,7 +519,7 @@ pub const DeclState = struct {
dbg_info_buffer.appendNTimesAssumeCapacity(0, 4);
try self.addTypeRelocGlobal(atom_index, error_ty, @intCast(index));
// DW.AT.data_member_location, DW.FORM.udata
- try leb128.writeULEB128(dbg_info_buffer.writer(), error_off);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), error_off);
}
// DW.AT.structure_type delimit children
@@ -569,14 +569,14 @@ pub const DeclState = struct {
expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable;
} else {
expr_len.writer().writeByte(DW.OP.regx) catch unreachable;
- leb128.writeULEB128(expr_len.writer(), reg) catch unreachable;
+ leb128.writeUleb128(expr_len.writer(), reg) catch unreachable;
}
- leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
if (reg < 32) {
dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg);
} else {
dbg_info.appendAssumeCapacity(DW.OP.regx);
- leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable;
}
},
.register_pair => |regs| {
@@ -592,24 +592,24 @@ pub const DeclState = struct {
expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable;
} else {
expr_len.writer().writeByte(DW.OP.regx) catch unreachable;
- leb128.writeULEB128(expr_len.writer(), reg) catch unreachable;
+ leb128.writeUleb128(expr_len.writer(), reg) catch unreachable;
}
expr_len.writer().writeByte(DW.OP.piece) catch unreachable;
- leb128.writeULEB128(
+ leb128.writeUleb128(
expr_len.writer(),
@min(abi_size - reg_i * reg_bytes, reg_bytes),
) catch unreachable;
}
- leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
for (regs, 0..) |reg, reg_i| {
if (reg < 32) {
dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg);
} else {
dbg_info.appendAssumeCapacity(DW.OP.regx);
- leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable;
}
dbg_info.appendAssumeCapacity(DW.OP.piece);
- leb128.writeULEB128(
+ leb128.writeUleb128(
dbg_info.writer(),
@min(abi_size - reg_i * reg_bytes, reg_bytes),
) catch unreachable;
@@ -624,20 +624,20 @@ pub const DeclState = struct {
expr_len.writer().writeByte(DW.OP.breg0 + info.fp_register) catch unreachable;
} else {
expr_len.writer().writeByte(DW.OP.bregx) catch unreachable;
- leb128.writeULEB128(expr_len.writer(), info.fp_register) catch unreachable;
+ leb128.writeUleb128(expr_len.writer(), info.fp_register) catch unreachable;
}
- leb128.writeILEB128(expr_len.writer(), info.offset) catch unreachable;
- leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
+ leb128.writeIleb128(expr_len.writer(), info.offset) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
if (info.fp_register < 32) {
dbg_info.appendAssumeCapacity(DW.OP.breg0 + info.fp_register);
} else {
dbg_info.appendAssumeCapacity(DW.OP.bregx);
- leb128.writeULEB128(dbg_info.writer(), info.fp_register) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), info.fp_register) catch unreachable;
}
- leb128.writeILEB128(dbg_info.writer(), info.offset) catch unreachable;
+ leb128.writeIleb128(dbg_info.writer(), info.offset) catch unreachable;
},
.wasm_local => |value| {
- const leb_size = link.File.Wasm.getULEB128Size(value);
+ const leb_size = link.File.Wasm.getUleb128Size(value);
try dbg_info.ensureUnusedCapacity(3 + leb_size);
// wasm locations are encoded as follow:
// DW_OP_WASM_location wasm-op
@@ -650,7 +650,7 @@ pub const DeclState = struct {
DW.OP.WASM_location,
DW.OP.WASM_local,
});
- leb128.writeULEB128(dbg_info.writer(), value) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), value) catch unreachable;
},
else => unreachable,
}
@@ -689,14 +689,14 @@ pub const DeclState = struct {
expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable;
} else {
expr_len.writer().writeByte(DW.OP.regx) catch unreachable;
- leb128.writeULEB128(expr_len.writer(), reg) catch unreachable;
+ leb128.writeUleb128(expr_len.writer(), reg) catch unreachable;
}
- leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
if (reg < 32) {
dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg);
} else {
dbg_info.appendAssumeCapacity(DW.OP.regx);
- leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable;
}
},
@@ -712,24 +712,24 @@ pub const DeclState = struct {
expr_len.writer().writeByte(DW.OP.reg0 + reg) catch unreachable;
} else {
expr_len.writer().writeByte(DW.OP.regx) catch unreachable;
- leb128.writeULEB128(expr_len.writer(), reg) catch unreachable;
+ leb128.writeUleb128(expr_len.writer(), reg) catch unreachable;
}
expr_len.writer().writeByte(DW.OP.piece) catch unreachable;
- leb128.writeULEB128(
+ leb128.writeUleb128(
expr_len.writer(),
@min(abi_size - reg_i * reg_bytes, reg_bytes),
) catch unreachable;
}
- leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
for (regs, 0..) |reg, reg_i| {
if (reg < 32) {
dbg_info.appendAssumeCapacity(DW.OP.reg0 + reg);
} else {
dbg_info.appendAssumeCapacity(DW.OP.regx);
- leb128.writeULEB128(dbg_info.writer(), reg) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), reg) catch unreachable;
}
dbg_info.appendAssumeCapacity(DW.OP.piece);
- leb128.writeULEB128(
+ leb128.writeUleb128(
dbg_info.writer(),
@min(abi_size - reg_i * reg_bytes, reg_bytes),
) catch unreachable;
@@ -744,21 +744,21 @@ pub const DeclState = struct {
expr_len.writer().writeByte(DW.OP.breg0 + info.fp_register) catch unreachable;
} else {
expr_len.writer().writeByte(DW.OP.bregx) catch unreachable;
- leb128.writeULEB128(expr_len.writer(), info.fp_register) catch unreachable;
+ leb128.writeUleb128(expr_len.writer(), info.fp_register) catch unreachable;
}
- leb128.writeILEB128(expr_len.writer(), info.offset) catch unreachable;
- leb128.writeULEB128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
+ leb128.writeIleb128(expr_len.writer(), info.offset) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), expr_len.bytes_written) catch unreachable;
if (info.fp_register < 32) {
dbg_info.appendAssumeCapacity(DW.OP.breg0 + info.fp_register);
} else {
dbg_info.appendAssumeCapacity(DW.OP.bregx);
- leb128.writeULEB128(dbg_info.writer(), info.fp_register) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), info.fp_register) catch unreachable;
}
- leb128.writeILEB128(dbg_info.writer(), info.offset) catch unreachable;
+ leb128.writeIleb128(dbg_info.writer(), info.offset) catch unreachable;
},
.wasm_local => |value| {
- const leb_size = link.File.Wasm.getULEB128Size(value);
+ const leb_size = link.File.Wasm.getUleb128Size(value);
try dbg_info.ensureUnusedCapacity(2 + leb_size);
// wasm locals are encoded as follow:
// DW_OP_WASM_location wasm-op
@@ -770,7 +770,7 @@ pub const DeclState = struct {
DW.OP.WASM_location,
DW.OP.WASM_local,
});
- leb128.writeULEB128(dbg_info.writer(), value) catch unreachable;
+ leb128.writeUleb128(dbg_info.writer(), value) catch unreachable;
},
.memory,
@@ -832,9 +832,9 @@ pub const DeclState = struct {
if (child_ty.isSignedInt(mod)) DW.OP.consts else DW.OP.constu,
});
if (child_ty.isSignedInt(mod)) {
- try leb128.writeILEB128(dbg_info.writer(), @as(i64, @bitCast(x)));
+ try leb128.writeIleb128(dbg_info.writer(), @as(i64, @bitCast(x)));
} else {
- try leb128.writeULEB128(dbg_info.writer(), x);
+ try leb128.writeUleb128(dbg_info.writer(), x);
}
try dbg_info.append(DW.OP.stack_value);
dbg_info.items[fixup] += @intCast(dbg_info.items.len - fixup - 2);
@@ -847,9 +847,9 @@ pub const DeclState = struct {
const abi_size: u32 = @intCast(child_ty.abiSize(mod));
var implicit_value_len = std.ArrayList(u8).init(gpa);
defer implicit_value_len.deinit();
- try leb128.writeULEB128(implicit_value_len.writer(), abi_size);
+ try leb128.writeUleb128(implicit_value_len.writer(), abi_size);
const total_exprloc_len = 1 + implicit_value_len.items.len + abi_size;
- try leb128.writeULEB128(dbg_info.writer(), total_exprloc_len);
+ try leb128.writeUleb128(dbg_info.writer(), total_exprloc_len);
try dbg_info.ensureUnusedCapacity(total_exprloc_len);
dbg_info.appendAssumeCapacity(DW.OP.implicit_value);
dbg_info.appendSliceAssumeCapacity(implicit_value_len.items);
@@ -895,7 +895,7 @@ pub const DeclState = struct {
remaining: {
assert(delta_line != 0);
dbg_line.appendAssumeCapacity(DW.LNS.advance_line);
- leb128.writeILEB128(dbg_line.writer(), delta_line) catch unreachable;
+ leb128.writeIleb128(dbg_line.writer(), delta_line) catch unreachable;
break :remaining 0;
} else delta_line);
@@ -904,7 +904,7 @@ pub const DeclState = struct {
const max_op_advance: u9 = (std.math.maxInt(u8) - header.opcode_base) / header.line_range;
const remaining_op_advance: u8 = @intCast(if (op_advance >= 2 * max_op_advance) remaining: {
dbg_line.appendAssumeCapacity(DW.LNS.advance_pc);
- leb128.writeULEB128(dbg_line.writer(), op_advance) catch unreachable;
+ leb128.writeUleb128(dbg_line.writer(), op_advance) catch unreachable;
break :remaining 0;
} else if (op_advance >= max_op_advance) remaining: {
dbg_line.appendAssumeCapacity(DW.LNS.const_add_pc);
@@ -922,7 +922,7 @@ pub const DeclState = struct {
pub fn setColumn(self: *DeclState, column: u32) error{OutOfMemory}!void {
try self.dbg_line.ensureUnusedCapacity(1 + 5);
self.dbg_line.appendAssumeCapacity(DW.LNS.set_column);
- leb128.writeULEB128(self.dbg_line.writer(), column + 1) catch unreachable;
+ leb128.writeUleb128(self.dbg_line.writer(), column + 1) catch unreachable;
}
pub fn setPrologueEnd(self: *DeclState) error{OutOfMemory}!void {
@@ -1146,7 +1146,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclInde
leb128.writeUnsignedFixed(4, dbg_line_buffer.addManyAsArrayAssumeCapacity(4), file_index);
dbg_line_buffer.appendAssumeCapacity(DW.LNS.set_column);
- leb128.writeULEB128(dbg_line_buffer.writer(), func.lbrace_column + 1) catch unreachable;
+ leb128.writeUleb128(dbg_line_buffer.writer(), func.lbrace_column + 1) catch unreachable;
// Emit a line for the begin curly with prologue_end=false. The codegen will
// do the work of setting prologue_end=true and epilogue_begin=true.
@@ -2849,7 +2849,7 @@ fn addDbgInfoErrorSetNames(
try dbg_info_buffer.append(@intFromEnum(AbbrevCode.enum_type));
// DW.AT.byte_size, DW.FORM.udata
const abi_size = Type.anyerror.abiSize(mod);
- try leb128.writeULEB128(dbg_info_buffer.writer(), abi_size);
+ try leb128.writeUleb128(dbg_info_buffer.writer(), abi_size);
// DW.AT.name, DW.FORM.string
try ty.print(dbg_info_buffer.writer(), mod);
try dbg_info_buffer.append(0);
diff --git a/src/link/MachO/Dylib.zig b/src/link/MachO/Dylib.zig
index aa7fea7b6f..458b66d433 100644
--- a/src/link/MachO/Dylib.zig
+++ b/src/link/MachO/Dylib.zig
@@ -159,11 +159,11 @@ const TrieIterator = struct {
return std.io.fixedBufferStream(it.data[it.pos..]);
}
- fn readULEB128(it: *TrieIterator) !u64 {
+ fn readUleb128(it: *TrieIterator) !u64 {
var stream = it.getStream();
var creader = std.io.countingReader(stream.reader());
const reader = creader.reader();
- const value = try std.leb.readULEB128(u64, reader);
+ const value = try std.leb.readUleb128(u64, reader);
it.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow;
return value;
}
@@ -207,9 +207,9 @@ fn parseTrieNode(
) !void {
const tracy = trace(@src());
defer tracy.end();
- const size = try it.readULEB128();
+ const size = try it.readUleb128();
if (size > 0) {
- const flags = try it.readULEB128();
+ const flags = try it.readUleb128();
const kind = flags & macho.EXPORT_SYMBOL_FLAGS_KIND_MASK;
const out_flags = Export.Flags{
.abs = kind == macho.EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE,
@@ -217,15 +217,15 @@ fn parseTrieNode(
.weak = flags & macho.EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION != 0,
};
if (flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT != 0) {
- _ = try it.readULEB128(); // dylib ordinal
+ _ = try it.readUleb128(); // dylib ordinal
const name = try it.readString();
try self.addExport(allocator, if (name.len > 0) name else prefix, out_flags);
} else if (flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER != 0) {
- _ = try it.readULEB128(); // stub offset
- _ = try it.readULEB128(); // resolver offset
+ _ = try it.readUleb128(); // stub offset
+ _ = try it.readUleb128(); // resolver offset
try self.addExport(allocator, prefix, out_flags);
} else {
- _ = try it.readULEB128(); // VM offset
+ _ = try it.readUleb128(); // VM offset
try self.addExport(allocator, prefix, out_flags);
}
}
@@ -234,7 +234,7 @@ fn parseTrieNode(
for (0..nedges) |_| {
const label = try it.readString();
- const off = try it.readULEB128();
+ const off = try it.readUleb128();
const prefix_label = try std.fmt.allocPrint(arena, "{s}{s}", .{ prefix, label });
const curr = it.pos;
it.pos = math.cast(usize, off) orelse return error.Overflow;
diff --git a/src/link/MachO/dwarf.zig b/src/link/MachO/dwarf.zig
index 018c40f779..c9db7ed7b7 100644
--- a/src/link/MachO/dwarf.zig
+++ b/src/link/MachO/dwarf.zig
@@ -26,7 +26,7 @@ pub const InfoReader = struct {
.dwarf64 => 12,
} + cuh_length;
while (p.pos < end_pos) {
- const di_code = try p.readULEB128(u64);
+ const di_code = try p.readUleb128(u64);
if (di_code == 0) return error.Eof;
if (di_code == code) return;
@@ -92,14 +92,14 @@ pub const InfoReader = struct {
dwarf.FORM.block1 => try p.readByte(),
dwarf.FORM.block2 => try p.readInt(u16),
dwarf.FORM.block4 => try p.readInt(u32),
- dwarf.FORM.block => try p.readULEB128(u64),
+ dwarf.FORM.block => try p.readUleb128(u64),
else => unreachable,
};
return p.readNBytes(len);
}
pub fn readExprLoc(p: *InfoReader) ![]const u8 {
- const len: u64 = try p.readULEB128(u64);
+ const len: u64 = try p.readUleb128(u64);
return p.readNBytes(len);
}
@@ -109,8 +109,8 @@ pub const InfoReader = struct {
dwarf.FORM.data2, dwarf.FORM.ref2 => try p.readInt(u16),
dwarf.FORM.data4, dwarf.FORM.ref4 => try p.readInt(u32),
dwarf.FORM.data8, dwarf.FORM.ref8, dwarf.FORM.ref_sig8 => try p.readInt(u64),
- dwarf.FORM.udata, dwarf.FORM.ref_udata => try p.readULEB128(u64),
- dwarf.FORM.sdata => @bitCast(try p.readILEB128(i64)),
+ dwarf.FORM.udata, dwarf.FORM.ref_udata => try p.readUleb128(u64),
+ dwarf.FORM.sdata => @bitCast(try p.readIleb128(i64)),
else => return error.UnhandledConstantForm,
};
}
@@ -160,18 +160,18 @@ pub const InfoReader = struct {
};
}
- pub fn readULEB128(p: *InfoReader, comptime Type: type) !Type {
+ pub fn readUleb128(p: *InfoReader, comptime Type: type) !Type {
var stream = std.io.fixedBufferStream(p.bytes[p.pos..]);
var creader = std.io.countingReader(stream.reader());
- const value: Type = try leb.readULEB128(Type, creader.reader());
+ const value: Type = try leb.readUleb128(Type, creader.reader());
p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow;
return value;
}
- pub fn readILEB128(p: *InfoReader, comptime Type: type) !Type {
+ pub fn readIleb128(p: *InfoReader, comptime Type: type) !Type {
var stream = std.io.fixedBufferStream(p.bytes[p.pos..]);
var creader = std.io.countingReader(stream.reader());
- const value: Type = try leb.readILEB128(Type, creader.reader());
+ const value: Type = try leb.readIleb128(Type, creader.reader());
p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow;
return value;
}
@@ -191,10 +191,10 @@ pub const AbbrevReader = struct {
pub fn readDecl(p: *AbbrevReader) !?AbbrevDecl {
const pos = p.pos;
- const code = try p.readULEB128(Code);
+ const code = try p.readUleb128(Code);
if (code == 0) return null;
- const tag = try p.readULEB128(Tag);
+ const tag = try p.readUleb128(Tag);
const has_children = (try p.readByte()) > 0;
return .{
.code = code,
@@ -207,8 +207,8 @@ pub const AbbrevReader = struct {
pub fn readAttr(p: *AbbrevReader) !?AbbrevAttr {
const pos = p.pos;
- const at = try p.readULEB128(At);
- const form = try p.readULEB128(Form);
+ const at = try p.readUleb128(At);
+ const form = try p.readUleb128(Form);
return if (at == 0 and form == 0) null else .{
.at = at,
.form = form,
@@ -223,10 +223,10 @@ pub const AbbrevReader = struct {
return p.bytes[p.pos];
}
- pub fn readULEB128(p: *AbbrevReader, comptime Type: type) !Type {
+ pub fn readUleb128(p: *AbbrevReader, comptime Type: type) !Type {
var stream = std.io.fixedBufferStream(p.bytes[p.pos..]);
var creader = std.io.countingReader(stream.reader());
- const value: Type = try leb.readULEB128(Type, creader.reader());
+ const value: Type = try leb.readUleb128(Type, creader.reader());
p.pos += math.cast(usize, creader.bytes_read) orelse return error.Overflow;
return value;
}
diff --git a/src/link/MachO/dyld_info/Rebase.zig b/src/link/MachO/dyld_info/Rebase.zig
index c0cda1584a..f0121cf3dd 100644
--- a/src/link/MachO/dyld_info/Rebase.zig
+++ b/src/link/MachO/dyld_info/Rebase.zig
@@ -153,13 +153,13 @@ fn setTypePointer(writer: anytype) !void {
fn setSegmentOffset(segment_id: u8, offset: u64, writer: anytype) !void {
log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset });
try writer.writeByte(macho.REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id)));
- try std.leb.writeULEB128(writer, offset);
+ try std.leb.writeUleb128(writer, offset);
}
fn rebaseAddAddr(addr: u64, writer: anytype) !void {
log.debug(">>> rebase with add: {x}", .{addr});
try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB);
- try std.leb.writeULEB128(writer, addr);
+ try std.leb.writeUleb128(writer, addr);
}
fn rebaseTimes(count: usize, writer: anytype) !void {
@@ -168,15 +168,15 @@ fn rebaseTimes(count: usize, writer: anytype) !void {
try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_IMM_TIMES | @as(u4, @truncate(count)));
} else {
try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES);
- try std.leb.writeULEB128(writer, count);
+ try std.leb.writeUleb128(writer, count);
}
}
fn rebaseTimesSkip(count: usize, skip: u64, writer: anytype) !void {
log.debug(">>> rebase with count: {d} and skip: {x}", .{ count, skip });
try writer.writeByte(macho.REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB);
- try std.leb.writeULEB128(writer, count);
- try std.leb.writeULEB128(writer, skip);
+ try std.leb.writeUleb128(writer, count);
+ try std.leb.writeUleb128(writer, skip);
}
fn addAddr(addr: u64, writer: anytype) !void {
@@ -189,7 +189,7 @@ fn addAddr(addr: u64, writer: anytype) !void {
}
}
try writer.writeByte(macho.REBASE_OPCODE_ADD_ADDR_ULEB);
- try std.leb.writeULEB128(writer, addr);
+ try std.leb.writeUleb128(writer, addr);
}
fn done(writer: anytype) !void {
diff --git a/src/link/MachO/dyld_info/Trie.zig b/src/link/MachO/dyld_info/Trie.zig
index edef57569a..a6f717a043 100644
--- a/src/link/MachO/dyld_info/Trie.zig
+++ b/src/link/MachO/dyld_info/Trie.zig
@@ -133,14 +133,14 @@ pub const Node = struct {
var nread: usize = 0;
- const node_size = try leb.readULEB128(u64, reader);
+ const node_size = try leb.readUleb128(u64, reader);
if (node_size > 0) {
- const export_flags = try leb.readULEB128(u64, reader);
+ const export_flags = try leb.readUleb128(u64, reader);
// TODO Parse special flags.
assert(export_flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT == 0 and
export_flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER == 0);
- const vmaddr_offset = try leb.readULEB128(u64, reader);
+ const vmaddr_offset = try leb.readUleb128(u64, reader);
self.terminal_info = .{
.export_flags = export_flags,
@@ -168,7 +168,7 @@ pub const Node = struct {
break :blk try label_buf.toOwnedSlice();
};
- const seek_to = try leb.readULEB128(u64, reader);
+ const seek_to = try leb.readUleb128(u64, reader);
const return_pos = try reader.context.getPos();
nread += return_pos - edge_start_pos;
@@ -204,13 +204,13 @@ pub const Node = struct {
// TODO Implement for special flags.
assert(info.export_flags & macho.EXPORT_SYMBOL_FLAGS_REEXPORT == 0 and
info.export_flags & macho.EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER == 0);
- try leb.writeULEB128(info_stream.writer(), info.export_flags);
- try leb.writeULEB128(info_stream.writer(), info.vmaddr_offset);
+ try leb.writeUleb128(info_stream.writer(), info.export_flags);
+ try leb.writeUleb128(info_stream.writer(), info.vmaddr_offset);
// Encode the size of the terminal node info.
var size_buf: [@sizeOf(u64)]u8 = undefined;
var size_stream = std.io.fixedBufferStream(&size_buf);
- try leb.writeULEB128(size_stream.writer(), info_stream.pos);
+ try leb.writeUleb128(size_stream.writer(), info_stream.pos);
// Now, write them to the output stream.
try writer.writeAll(size_buf[0..size_stream.pos]);
@@ -226,7 +226,7 @@ pub const Node = struct {
// Write edge label and offset to next node in trie.
try writer.writeAll(edge.label);
try writer.writeByte(0);
- try leb.writeULEB128(writer, edge.to.trie_offset.?);
+ try leb.writeUleb128(writer, edge.to.trie_offset.?);
}
}
@@ -246,9 +246,9 @@ pub const Node = struct {
var node_size: u64 = 0;
if (self.terminal_info) |info| {
- try leb.writeULEB128(writer, info.export_flags);
- try leb.writeULEB128(writer, info.vmaddr_offset);
- try leb.writeULEB128(writer, stream.bytes_written);
+ try leb.writeUleb128(writer, info.export_flags);
+ try leb.writeUleb128(writer, info.vmaddr_offset);
+ try leb.writeUleb128(writer, stream.bytes_written);
} else {
node_size += 1; // 0x0 for non-terminal nodes
}
@@ -257,7 +257,7 @@ pub const Node = struct {
for (self.edges.items) |edge| {
const next_node_offset = edge.to.trie_offset orelse 0;
node_size += edge.label.len + 1;
- try leb.writeULEB128(writer, next_node_offset);
+ try leb.writeUleb128(writer, next_node_offset);
}
const trie_offset = self.trie_offset orelse 0;
diff --git a/src/link/MachO/dyld_info/bind.zig b/src/link/MachO/dyld_info/bind.zig
index 3ee55fe0fb..15d3df76e5 100644
--- a/src/link/MachO/dyld_info/bind.zig
+++ b/src/link/MachO/dyld_info/bind.zig
@@ -392,7 +392,7 @@ pub const LazyBind = struct {
fn setSegmentOffset(segment_id: u8, offset: u64, writer: anytype) !void {
log.debug(">>> set segment: {d} and offset: {x}", .{ segment_id, offset });
try writer.writeByte(macho.BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | @as(u4, @truncate(segment_id)));
- try std.leb.writeULEB128(writer, offset);
+ try std.leb.writeUleb128(writer, offset);
}
fn setSymbol(name: []const u8, flags: u8, writer: anytype) !void {
@@ -426,7 +426,7 @@ fn setDylibOrdinal(ordinal: i16, writer: anytype) !void {
try writer.writeByte(macho.BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | @as(u4, @truncate(cast)));
} else {
try writer.writeByte(macho.BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB);
- try std.leb.writeULEB128(writer, cast);
+ try std.leb.writeUleb128(writer, cast);
}
}
}
@@ -434,7 +434,7 @@ fn setDylibOrdinal(ordinal: i16, writer: anytype) !void {
fn setAddend(addend: i64, writer: anytype) !void {
log.debug(">>> set addend: {x}", .{addend});
try writer.writeByte(macho.BIND_OPCODE_SET_ADDEND_SLEB);
- try std.leb.writeILEB128(writer, addend);
+ try std.leb.writeIleb128(writer, addend);
}
fn doBind(writer: anytype) !void {
@@ -454,20 +454,20 @@ fn doBindAddAddr(addr: u64, writer: anytype) !void {
}
}
try writer.writeByte(macho.BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB);
- try std.leb.writeULEB128(writer, addr);
+ try std.leb.writeUleb128(writer, addr);
}
fn doBindTimesSkip(count: usize, skip: u64, writer: anytype) !void {
log.debug(">>> bind with count: {d} and skip: {x}", .{ count, skip });
try writer.writeByte(macho.BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB);
- try std.leb.writeULEB128(writer, count);
- try std.leb.writeULEB128(writer, skip);
+ try std.leb.writeUleb128(writer, count);
+ try std.leb.writeUleb128(writer, skip);
}
fn addAddr(addr: u64, writer: anytype) !void {
log.debug(">>> add: {x}", .{addr});
try writer.writeByte(macho.BIND_OPCODE_ADD_ADDR_ULEB);
- try std.leb.writeULEB128(writer, addr);
+ try std.leb.writeUleb128(writer, addr);
}
fn done(writer: anytype) !void {
diff --git a/src/link/MachO/eh_frame.zig b/src/link/MachO/eh_frame.zig
index 8e71960e69..b05da1b828 100644
--- a/src/link/MachO/eh_frame.zig
+++ b/src/link/MachO/eh_frame.zig
@@ -21,10 +21,10 @@ pub const Cie = struct {
var creader = std.io.countingReader(stream.reader());
const reader = creader.reader();
- _ = try leb.readULEB128(u64, reader); // code alignment factor
- _ = try leb.readULEB128(u64, reader); // data alignment factor
- _ = try leb.readULEB128(u64, reader); // return address register
- _ = try leb.readULEB128(u64, reader); // augmentation data length
+ _ = try leb.readUleb128(u64, reader); // code alignment factor
+ _ = try leb.readUleb128(u64, reader); // data alignment factor
+ _ = try leb.readUleb128(u64, reader); // return address register
+ _ = try leb.readUleb128(u64, reader); // augmentation data length
for (aug[1..]) |ch| switch (ch) {
'R' => {
@@ -185,7 +185,7 @@ pub const Fde = struct {
var stream = std.io.fixedBufferStream(data[24..]);
var creader = std.io.countingReader(stream.reader());
const reader = creader.reader();
- _ = try leb.readULEB128(u64, reader); // augmentation length
+ _ = try leb.readUleb128(u64, reader); // augmentation length
fde.lsda_ptr_offset = @intCast(creader.bytes_read + 24);
const lsda_ptr = switch (lsda_size) {
.p32 => try reader.readInt(i32, .little),
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 217c95a705..6476784a01 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -952,7 +952,7 @@ fn resolveSymbolsInArchives(wasm: *Wasm) !void {
/// Writes an unsigned 32-bit integer as a LEB128-encoded 'i32.const' value.
fn writeI32Const(writer: anytype, val: u32) !void {
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeILEB128(writer, @as(i32, @bitCast(val)));
+ try leb.writeIleb128(writer, @as(i32, @bitCast(val)));
}
fn setupInitMemoryFunction(wasm: *Wasm) !void {
@@ -984,7 +984,7 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void {
const writer = function_body.writer();
// we have 0 locals
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
if (shared_memory) {
// destination blocks
@@ -1003,16 +1003,16 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void {
try writeI32Const(writer, 0);
try writeI32Const(writer, 1);
try writer.writeByte(std.wasm.opcode(.atomics_prefix));
- try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.i32_atomic_rmw_cmpxchg));
- try leb.writeULEB128(writer, @as(u32, 2)); // alignment
- try leb.writeULEB128(writer, @as(u32, 0)); // offset
+ try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.i32_atomic_rmw_cmpxchg));
+ try leb.writeUleb128(writer, @as(u32, 2)); // alignment
+ try leb.writeUleb128(writer, @as(u32, 0)); // offset
// based on the value from the atomic check, jump to the label.
try writer.writeByte(std.wasm.opcode(.br_table));
- try leb.writeULEB128(writer, @as(u32, 2)); // length of the table (we have 3 blocks but because of the mandatory default the length is 2).
- try leb.writeULEB128(writer, @as(u32, 0)); // $init
- try leb.writeULEB128(writer, @as(u32, 1)); // $wait
- try leb.writeULEB128(writer, @as(u32, 2)); // $drop
+ try leb.writeUleb128(writer, @as(u32, 2)); // length of the table (we have 3 blocks but because of the mandatory default the length is 2).
+ try leb.writeUleb128(writer, @as(u32, 0)); // $init
+ try leb.writeUleb128(writer, @as(u32, 1)); // $wait
+ try leb.writeUleb128(writer, @as(u32, 2)); // $drop
try writer.writeByte(std.wasm.opcode(.end));
}
@@ -1034,7 +1034,7 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void {
try writeI32Const(writer, segment.offset);
try writer.writeByte(std.wasm.opcode(.global_set));
const loc = wasm.findGlobalSymbol("__tls_base").?;
- try leb.writeULEB128(writer, loc.getSymbol(wasm).index);
+ try leb.writeUleb128(writer, loc.getSymbol(wasm).index);
}
try writeI32Const(writer, 0);
@@ -1042,11 +1042,11 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void {
try writer.writeByte(std.wasm.opcode(.misc_prefix));
if (std.mem.eql(u8, entry.key_ptr.*, ".bss")) {
// fill bss segment with zeroes
- try leb.writeULEB128(writer, std.wasm.miscOpcode(.memory_fill));
+ try leb.writeUleb128(writer, std.wasm.miscOpcode(.memory_fill));
} else {
// initialize the segment
- try leb.writeULEB128(writer, std.wasm.miscOpcode(.memory_init));
- try leb.writeULEB128(writer, segment_index);
+ try leb.writeUleb128(writer, std.wasm.miscOpcode(.memory_init));
+ try leb.writeUleb128(writer, segment_index);
}
try writer.writeByte(0); // memory index immediate
}
@@ -1057,34 +1057,34 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void {
try writeI32Const(writer, flag_address);
try writeI32Const(writer, 2);
try writer.writeByte(std.wasm.opcode(.atomics_prefix));
- try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.i32_atomic_store));
- try leb.writeULEB128(writer, @as(u32, 2)); // alignment
- try leb.writeULEB128(writer, @as(u32, 0)); // offset
+ try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.i32_atomic_store));
+ try leb.writeUleb128(writer, @as(u32, 2)); // alignment
+ try leb.writeUleb128(writer, @as(u32, 0)); // offset
// notify any waiters for segment initialization completion
try writeI32Const(writer, flag_address);
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeILEB128(writer, @as(i32, -1)); // number of waiters
+ try leb.writeIleb128(writer, @as(i32, -1)); // number of waiters
try writer.writeByte(std.wasm.opcode(.atomics_prefix));
- try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.memory_atomic_notify));
- try leb.writeULEB128(writer, @as(u32, 2)); // alignment
- try leb.writeULEB128(writer, @as(u32, 0)); // offset
+ try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.memory_atomic_notify));
+ try leb.writeUleb128(writer, @as(u32, 2)); // alignment
+ try leb.writeUleb128(writer, @as(u32, 0)); // offset
try writer.writeByte(std.wasm.opcode(.drop));
// branch and drop segments
try writer.writeByte(std.wasm.opcode(.br));
- try leb.writeULEB128(writer, @as(u32, 1));
+ try leb.writeUleb128(writer, @as(u32, 1));
// wait for thread to initialize memory segments
try writer.writeByte(std.wasm.opcode(.end)); // end $wait
try writeI32Const(writer, flag_address);
try writeI32Const(writer, 1); // expected flag value
try writer.writeByte(std.wasm.opcode(.i64_const));
- try leb.writeILEB128(writer, @as(i64, -1)); // timeout
+ try leb.writeIleb128(writer, @as(i64, -1)); // timeout
try writer.writeByte(std.wasm.opcode(.atomics_prefix));
- try leb.writeULEB128(writer, std.wasm.atomicsOpcode(.memory_atomic_wait32));
- try leb.writeULEB128(writer, @as(u32, 2)); // alignment
- try leb.writeULEB128(writer, @as(u32, 0)); // offset
+ try leb.writeUleb128(writer, std.wasm.atomicsOpcode(.memory_atomic_wait32));
+ try leb.writeUleb128(writer, @as(u32, 2)); // alignment
+ try leb.writeUleb128(writer, @as(u32, 0)); // offset
try writer.writeByte(std.wasm.opcode(.drop));
try writer.writeByte(std.wasm.opcode(.end)); // end $drop
@@ -1105,8 +1105,8 @@ fn setupInitMemoryFunction(wasm: *Wasm) !void {
}
try writer.writeByte(std.wasm.opcode(.misc_prefix));
- try leb.writeULEB128(writer, std.wasm.miscOpcode(.data_drop));
- try leb.writeULEB128(writer, segment_index);
+ try leb.writeUleb128(writer, std.wasm.miscOpcode(.data_drop));
+ try leb.writeUleb128(writer, segment_index);
}
}
@@ -1147,18 +1147,18 @@ fn setupTLSRelocationsFunction(wasm: *Wasm) !void {
if (sym.tag == .data and sym.isDefined()) {
// get __tls_base
try writer.writeByte(std.wasm.opcode(.global_get));
- try leb.writeULEB128(writer, wasm.findGlobalSymbol("__tls_base").?.getSymbol(wasm).index);
+ try leb.writeUleb128(writer, wasm.findGlobalSymbol("__tls_base").?.getSymbol(wasm).index);
// add the virtual address of the symbol
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeULEB128(writer, sym.virtual_address);
+ try leb.writeUleb128(writer, sym.virtual_address);
} else if (sym.tag == .function) {
@panic("TODO: relocate GOT entry of function");
} else continue;
try writer.writeByte(std.wasm.opcode(.i32_add));
try writer.writeByte(std.wasm.opcode(.global_set));
- try leb.writeULEB128(writer, wasm.imported_globals_count + @as(u32, @intCast(wasm.wasm_globals.items.len + got_index)));
+ try leb.writeUleb128(writer, wasm.imported_globals_count + @as(u32, @intCast(wasm.wasm_globals.items.len + got_index)));
}
try writer.writeByte(std.wasm.opcode(.end));
@@ -1801,7 +1801,7 @@ fn initializeCallCtorsFunction(wasm: *Wasm) !void {
// Create the function body
{
// Write locals count (we have none)
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
// call constructors
for (wasm.init_funcs.items) |init_func_loc| {
@@ -1811,7 +1811,7 @@ fn initializeCallCtorsFunction(wasm: *Wasm) !void {
// Call function by its function index
try writer.writeByte(std.wasm.opcode(.call));
- try leb.writeULEB128(writer, symbol.index);
+ try leb.writeUleb128(writer, symbol.index);
// drop all returned values from the stack as __wasm_call_ctors has no return value
for (ty.returns) |_| {
@@ -1905,31 +1905,31 @@ fn initializeTLSFunction(wasm: *Wasm) !void {
const param_local: u32 = 0;
try writer.writeByte(std.wasm.opcode(.local_get));
- try leb.writeULEB128(writer, param_local);
+ try leb.writeUleb128(writer, param_local);
const tls_base_loc = wasm.findGlobalSymbol("__tls_base").?;
try writer.writeByte(std.wasm.opcode(.global_set));
- try leb.writeULEB128(writer, tls_base_loc.getSymbol(wasm).index);
+ try leb.writeUleb128(writer, tls_base_loc.getSymbol(wasm).index);
// load stack values for the bulk-memory operation
{
try writer.writeByte(std.wasm.opcode(.local_get));
- try leb.writeULEB128(writer, param_local);
+ try leb.writeUleb128(writer, param_local);
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeULEB128(writer, @as(u32, 0)); //segment offset
+ try leb.writeUleb128(writer, @as(u32, 0)); //segment offset
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeULEB128(writer, @as(u32, segment.size)); //segment offset
+ try leb.writeUleb128(writer, @as(u32, segment.size)); //segment offset
}
// perform the bulk-memory operation to initialize the data segment
try writer.writeByte(std.wasm.opcode(.misc_prefix));
- try leb.writeULEB128(writer, std.wasm.miscOpcode(.memory_init));
+ try leb.writeUleb128(writer, std.wasm.miscOpcode(.memory_init));
// segment immediate
- try leb.writeULEB128(writer, @as(u32, @intCast(data_index)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(data_index)));
// memory index immediate (always 0)
- try leb.writeULEB128(writer, @as(u32, 0));
+ try leb.writeUleb128(writer, @as(u32, 0));
}
// If we have to perform any TLS relocations, call the corresponding function
@@ -1937,7 +1937,7 @@ fn initializeTLSFunction(wasm: *Wasm) !void {
// generated by the linker.
if (wasm.findGlobalSymbol("__wasm_apply_global_tls_relocs")) |loc| {
try writer.writeByte(std.wasm.opcode(.call));
- try leb.writeULEB128(writer, loc.getSymbol(wasm).index);
+ try leb.writeUleb128(writer, loc.getSymbol(wasm).index);
loc.getSymbol(wasm).mark();
}
@@ -2642,14 +2642,14 @@ fn writeToFile(
const header_offset = try reserveVecSectionHeader(&binary_bytes);
log.debug("Writing type section. Count: ({d})", .{wasm.func_types.items.len});
for (wasm.func_types.items) |func_type| {
- try leb.writeULEB128(binary_writer, std.wasm.function_type);
- try leb.writeULEB128(binary_writer, @as(u32, @intCast(func_type.params.len)));
+ try leb.writeUleb128(binary_writer, std.wasm.function_type);
+ try leb.writeUleb128(binary_writer, @as(u32, @intCast(func_type.params.len)));
for (func_type.params) |param_ty| {
- try leb.writeULEB128(binary_writer, std.wasm.valtype(param_ty));
+ try leb.writeUleb128(binary_writer, std.wasm.valtype(param_ty));
}
- try leb.writeULEB128(binary_writer, @as(u32, @intCast(func_type.returns.len)));
+ try leb.writeUleb128(binary_writer, @as(u32, @intCast(func_type.returns.len)));
for (func_type.returns) |ret_ty| {
- try leb.writeULEB128(binary_writer, std.wasm.valtype(ret_ty));
+ try leb.writeUleb128(binary_writer, std.wasm.valtype(ret_ty));
}
}
@@ -2698,7 +2698,7 @@ fn writeToFile(
if (wasm.functions.count() != 0) {
const header_offset = try reserveVecSectionHeader(&binary_bytes);
for (wasm.functions.values()) |function| {
- try leb.writeULEB128(binary_writer, function.func.type_index);
+ try leb.writeUleb128(binary_writer, function.func.type_index);
}
try writeVecSectionHeader(
@@ -2716,7 +2716,7 @@ fn writeToFile(
const header_offset = try reserveVecSectionHeader(&binary_bytes);
for (wasm.tables.items) |table| {
- try leb.writeULEB128(binary_writer, std.wasm.reftype(table.reftype));
+ try leb.writeUleb128(binary_writer, std.wasm.reftype(table.reftype));
try emitLimits(binary_writer, table.limits);
}
@@ -2771,17 +2771,17 @@ fn writeToFile(
for (wasm.exports.items) |exp| {
const name = wasm.string_table.get(exp.name);
- try leb.writeULEB128(binary_writer, @as(u32, @intCast(name.len)));
+ try leb.writeUleb128(binary_writer, @as(u32, @intCast(name.len)));
try binary_writer.writeAll(name);
- try leb.writeULEB128(binary_writer, @intFromEnum(exp.kind));
- try leb.writeULEB128(binary_writer, exp.index);
+ try leb.writeUleb128(binary_writer, @intFromEnum(exp.kind));
+ try leb.writeUleb128(binary_writer, exp.index);
}
if (export_memory) {
- try leb.writeULEB128(binary_writer, @as(u32, @intCast("memory".len)));
+ try leb.writeUleb128(binary_writer, @as(u32, @intCast("memory".len)));
try binary_writer.writeAll("memory");
try binary_writer.writeByte(std.wasm.externalKind(.memory));
- try leb.writeULEB128(binary_writer, @as(u32, 0));
+ try leb.writeUleb128(binary_writer, @as(u32, 0));
}
try writeVecSectionHeader(
@@ -2813,21 +2813,21 @@ fn writeToFile(
const table_sym = table_loc.getSymbol(wasm);
const flags: u32 = if (table_sym.index == 0) 0x0 else 0x02; // passive with implicit 0-index table or set table index manually
- try leb.writeULEB128(binary_writer, flags);
+ try leb.writeUleb128(binary_writer, flags);
if (flags == 0x02) {
- try leb.writeULEB128(binary_writer, table_sym.index);
+ try leb.writeUleb128(binary_writer, table_sym.index);
}
try emitInit(binary_writer, .{ .i32_const = 1 }); // We start at index 1, so unresolved function pointers are invalid
if (flags == 0x02) {
- try leb.writeULEB128(binary_writer, @as(u8, 0)); // represents funcref
+ try leb.writeUleb128(binary_writer, @as(u8, 0)); // represents funcref
}
- try leb.writeULEB128(binary_writer, @as(u32, @intCast(wasm.function_table.count())));
+ try leb.writeUleb128(binary_writer, @as(u32, @intCast(wasm.function_table.count())));
var symbol_it = wasm.function_table.keyIterator();
while (symbol_it.next()) |symbol_loc_ptr| {
const sym = symbol_loc_ptr.getSymbol(wasm);
std.debug.assert(sym.isAlive());
std.debug.assert(sym.index < wasm.functions.count() + wasm.imported_functions_count);
- try leb.writeULEB128(binary_writer, sym.index);
+ try leb.writeUleb128(binary_writer, sym.index);
}
try writeVecSectionHeader(
@@ -2868,7 +2868,7 @@ fn writeToFile(
atom.resolveRelocs(wasm);
}
atom.offset = @intCast(binary_bytes.items.len - start_offset);
- try leb.writeULEB128(binary_writer, atom.size);
+ try leb.writeUleb128(binary_writer, atom.size);
try binary_writer.writeAll(atom.code.items);
}
@@ -2899,16 +2899,16 @@ fn writeToFile(
segment_count += 1;
var atom_index = wasm.atoms.get(segment_index).?;
- try leb.writeULEB128(binary_writer, segment.flags);
+ try leb.writeUleb128(binary_writer, segment.flags);
if (segment.flags & @intFromEnum(Wasm.Segment.Flag.WASM_DATA_SEGMENT_HAS_MEMINDEX) != 0) {
- try leb.writeULEB128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry
+ try leb.writeUleb128(binary_writer, @as(u32, 0)); // memory is always index 0 as we only have 1 memory entry
}
// when a segment is passive, it's initialized during runtime.
if (!segment.isPassive()) {
try emitInit(binary_writer, .{ .i32_const = @as(i32, @bitCast(segment.offset)) });
}
// offset into data section
- try leb.writeULEB128(binary_writer, segment.size);
+ try leb.writeUleb128(binary_writer, segment.size);
// fill in the offset table and the data segments
var current_offset: u32 = 0;
@@ -3058,7 +3058,7 @@ fn emitDebugSection(binary_bytes: *std.ArrayList(u8), data: []const u8, name: []
if (data.len == 0) return;
const header_offset = try reserveCustomSectionHeader(binary_bytes);
const writer = binary_bytes.writer();
- try leb.writeULEB128(writer, @as(u32, @intCast(name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(name.len)));
try writer.writeAll(name);
const start = binary_bytes.items.len - header_offset;
@@ -3077,10 +3077,10 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void {
const writer = binary_bytes.writer();
const producers = "producers";
- try leb.writeULEB128(writer, @as(u32, @intCast(producers.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(producers.len)));
try writer.writeAll(producers);
- try leb.writeULEB128(writer, @as(u32, 2)); // 2 fields: Language + processed-by
+ try leb.writeUleb128(writer, @as(u32, 2)); // 2 fields: Language + processed-by
// used for the Zig version
var version_buf: [100]u8 = undefined;
@@ -3089,18 +3089,18 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void {
// language field
{
const language = "language";
- try leb.writeULEB128(writer, @as(u32, @intCast(language.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(language.len)));
try writer.writeAll(language);
// field_value_count (TODO: Parse object files for producer sections to detect their language)
- try leb.writeULEB128(writer, @as(u32, 1));
+ try leb.writeUleb128(writer, @as(u32, 1));
// versioned name
{
- try leb.writeULEB128(writer, @as(u32, 3)); // len of "Zig"
+ try leb.writeUleb128(writer, @as(u32, 3)); // len of "Zig"
try writer.writeAll("Zig");
- try leb.writeULEB128(writer, @as(u32, @intCast(version.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(version.len)));
try writer.writeAll(version);
}
}
@@ -3108,18 +3108,18 @@ fn emitProducerSection(binary_bytes: *std.ArrayList(u8)) !void {
// processed-by field
{
const processed_by = "processed-by";
- try leb.writeULEB128(writer, @as(u32, @intCast(processed_by.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(processed_by.len)));
try writer.writeAll(processed_by);
// field_value_count (TODO: Parse object files for producer sections to detect other used tools)
- try leb.writeULEB128(writer, @as(u32, 1));
+ try leb.writeUleb128(writer, @as(u32, 1));
// versioned name
{
- try leb.writeULEB128(writer, @as(u32, 3)); // len of "Zig"
+ try leb.writeUleb128(writer, @as(u32, 3)); // len of "Zig"
try writer.writeAll("Zig");
- try leb.writeULEB128(writer, @as(u32, @intCast(version.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(version.len)));
try writer.writeAll(version);
}
}
@@ -3136,11 +3136,11 @@ fn emitBuildIdSection(binary_bytes: *std.ArrayList(u8), build_id: []const u8) !v
const writer = binary_bytes.writer();
const hdr_build_id = "build_id";
- try leb.writeULEB128(writer, @as(u32, @intCast(hdr_build_id.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(hdr_build_id.len)));
try writer.writeAll(hdr_build_id);
- try leb.writeULEB128(writer, @as(u32, 1));
- try leb.writeULEB128(writer, @as(u32, @intCast(build_id.len)));
+ try leb.writeUleb128(writer, @as(u32, 1));
+ try leb.writeUleb128(writer, @as(u32, @intCast(build_id.len)));
try writer.writeAll(build_id);
try writeCustomSectionHeader(
@@ -3155,17 +3155,17 @@ fn emitFeaturesSection(binary_bytes: *std.ArrayList(u8), enabled_features: []con
const writer = binary_bytes.writer();
const target_features = "target_features";
- try leb.writeULEB128(writer, @as(u32, @intCast(target_features.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(target_features.len)));
try writer.writeAll(target_features);
- try leb.writeULEB128(writer, features_count);
+ try leb.writeUleb128(writer, features_count);
for (enabled_features, 0..) |enabled, feature_index| {
if (enabled) {
const feature: types.Feature = .{ .prefix = .used, .tag = @as(types.Feature.Tag, @enumFromInt(feature_index)) };
- try leb.writeULEB128(writer, @intFromEnum(feature.prefix));
+ try leb.writeUleb128(writer, @intFromEnum(feature.prefix));
var buf: [100]u8 = undefined;
const string = try std.fmt.bufPrint(&buf, "{}", .{feature.tag});
- try leb.writeULEB128(writer, @as(u32, @intCast(string.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(string.len)));
try writer.writeAll(string);
}
}
@@ -3228,7 +3228,7 @@ fn emitNameSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), arena: std.mem
const header_offset = try reserveCustomSectionHeader(binary_bytes);
const writer = binary_bytes.writer();
- try leb.writeULEB128(writer, @as(u32, @intCast("name".len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast("name".len)));
try writer.writeAll("name");
try wasm.emitNameSubsection(.function, funcs.values(), writer);
@@ -3250,25 +3250,25 @@ fn emitNameSubsection(wasm: *Wasm, section_id: std.wasm.NameSubsection, names: a
defer section_list.deinit();
const sub_writer = section_list.writer();
- try leb.writeULEB128(sub_writer, @as(u32, @intCast(names.len)));
+ try leb.writeUleb128(sub_writer, @as(u32, @intCast(names.len)));
for (names) |name| {
log.debug("Emit symbol '{s}' type({s})", .{ name.name, @tagName(section_id) });
- try leb.writeULEB128(sub_writer, name.index);
- try leb.writeULEB128(sub_writer, @as(u32, @intCast(name.name.len)));
+ try leb.writeUleb128(sub_writer, name.index);
+ try leb.writeUleb128(sub_writer, @as(u32, @intCast(name.name.len)));
try sub_writer.writeAll(name.name);
}
// From now, write to the actual writer
- try leb.writeULEB128(writer, @intFromEnum(section_id));
- try leb.writeULEB128(writer, @as(u32, @intCast(section_list.items.len)));
+ try leb.writeUleb128(writer, @intFromEnum(section_id));
+ try leb.writeUleb128(writer, @as(u32, @intCast(section_list.items.len)));
try writer.writeAll(section_list.items);
}
fn emitLimits(writer: anytype, limits: std.wasm.Limits) !void {
try writer.writeByte(limits.flags);
- try leb.writeULEB128(writer, limits.min);
+ try leb.writeUleb128(writer, limits.min);
if (limits.hasFlag(.WASM_LIMITS_FLAG_HAS_MAX)) {
- try leb.writeULEB128(writer, limits.max);
+ try leb.writeUleb128(writer, limits.max);
}
}
@@ -3276,11 +3276,11 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void {
switch (init_expr) {
.i32_const => |val| {
try writer.writeByte(std.wasm.opcode(.i32_const));
- try leb.writeILEB128(writer, val);
+ try leb.writeIleb128(writer, val);
},
.i64_const => |val| {
try writer.writeByte(std.wasm.opcode(.i64_const));
- try leb.writeILEB128(writer, val);
+ try leb.writeIleb128(writer, val);
},
.f32_const => |val| {
try writer.writeByte(std.wasm.opcode(.f32_const));
@@ -3292,7 +3292,7 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void {
},
.global_get => |val| {
try writer.writeByte(std.wasm.opcode(.global_get));
- try leb.writeULEB128(writer, val);
+ try leb.writeUleb128(writer, val);
},
}
try writer.writeByte(std.wasm.opcode(.end));
@@ -3300,22 +3300,22 @@ fn emitInit(writer: anytype, init_expr: std.wasm.InitExpression) !void {
fn emitImport(wasm: *Wasm, writer: anytype, import: types.Import) !void {
const module_name = wasm.string_table.get(import.module_name);
- try leb.writeULEB128(writer, @as(u32, @intCast(module_name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(module_name.len)));
try writer.writeAll(module_name);
const name = wasm.string_table.get(import.name);
- try leb.writeULEB128(writer, @as(u32, @intCast(name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(name.len)));
try writer.writeAll(name);
try writer.writeByte(@intFromEnum(import.kind));
switch (import.kind) {
- .function => |type_index| try leb.writeULEB128(writer, type_index),
+ .function => |type_index| try leb.writeUleb128(writer, type_index),
.global => |global_type| {
- try leb.writeULEB128(writer, std.wasm.valtype(global_type.valtype));
+ try leb.writeUleb128(writer, std.wasm.valtype(global_type.valtype));
try writer.writeByte(@intFromBool(global_type.mutable));
},
.table => |table| {
- try leb.writeULEB128(writer, std.wasm.reftype(table.reftype));
+ try leb.writeUleb128(writer, std.wasm.reftype(table.reftype));
try emitLimits(writer, table.limits);
},
.memory => |limits| {
@@ -3767,11 +3767,11 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
const writer = binary_bytes.writer();
// emit "linking" custom section name
const section_name = "linking";
- try leb.writeULEB128(writer, section_name.len);
+ try leb.writeUleb128(writer, section_name.len);
try writer.writeAll(section_name);
// meta data version, which is currently '2'
- try leb.writeULEB128(writer, @as(u32, 2));
+ try leb.writeUleb128(writer, @as(u32, 2));
// For each subsection type (found in types.Subsection) we can emit a section.
// Currently, we only support emitting segment info and the symbol table.
@@ -3785,7 +3785,7 @@ fn emitLinkSection(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table: *std.AutoArrayHashMap(SymbolLoc, u32)) !void {
const writer = binary_bytes.writer();
- try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE));
+ try leb.writeUleb128(writer, @intFromEnum(types.SubsectionType.WASM_SYMBOL_TABLE));
const table_offset = binary_bytes.items.len;
var symbol_count: u32 = 0;
@@ -3795,30 +3795,30 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
try symbol_table.putNoClobber(sym_loc, symbol_count);
symbol_count += 1;
log.debug("Emit symbol: {}", .{symbol});
- try leb.writeULEB128(writer, @intFromEnum(symbol.tag));
- try leb.writeULEB128(writer, symbol.flags);
+ try leb.writeUleb128(writer, @intFromEnum(symbol.tag));
+ try leb.writeUleb128(writer, symbol.flags);
const sym_name = sym_loc.getName(wasm);
switch (symbol.tag) {
.data => {
- try leb.writeULEB128(writer, @as(u32, @intCast(sym_name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(sym_name.len)));
try writer.writeAll(sym_name);
if (symbol.isDefined()) {
- try leb.writeULEB128(writer, symbol.index);
+ try leb.writeUleb128(writer, symbol.index);
const atom_index = wasm.symbol_atom.get(sym_loc).?;
const atom = wasm.getAtom(atom_index);
- try leb.writeULEB128(writer, @as(u32, atom.offset));
- try leb.writeULEB128(writer, @as(u32, atom.size));
+ try leb.writeUleb128(writer, @as(u32, atom.offset));
+ try leb.writeUleb128(writer, @as(u32, atom.size));
}
},
.section => {
- try leb.writeULEB128(writer, symbol.index);
+ try leb.writeUleb128(writer, symbol.index);
},
else => {
- try leb.writeULEB128(writer, symbol.index);
+ try leb.writeUleb128(writer, symbol.index);
if (symbol.isDefined()) {
- try leb.writeULEB128(writer, @as(u32, @intCast(sym_name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(sym_name.len)));
try writer.writeAll(sym_name);
}
},
@@ -3833,20 +3833,20 @@ fn emitSymbolTable(wasm: *Wasm, binary_bytes: *std.ArrayList(u8), symbol_table:
fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void {
const writer = binary_bytes.writer();
- try leb.writeULEB128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO));
+ try leb.writeUleb128(writer, @intFromEnum(types.SubsectionType.WASM_SEGMENT_INFO));
const segment_offset = binary_bytes.items.len;
- try leb.writeULEB128(writer, @as(u32, @intCast(wasm.segment_info.count())));
+ try leb.writeUleb128(writer, @as(u32, @intCast(wasm.segment_info.count())));
for (wasm.segment_info.values()) |segment_info| {
log.debug("Emit segment: {s} align({d}) flags({b})", .{
segment_info.name,
segment_info.alignment,
segment_info.flags,
});
- try leb.writeULEB128(writer, @as(u32, @intCast(segment_info.name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(segment_info.name.len)));
try writer.writeAll(segment_info.name);
- try leb.writeULEB128(writer, segment_info.alignment.toLog2Units());
- try leb.writeULEB128(writer, segment_info.flags);
+ try leb.writeUleb128(writer, segment_info.alignment.toLog2Units());
+ try leb.writeUleb128(writer, segment_info.flags);
}
var buf: [5]u8 = undefined;
@@ -3854,7 +3854,7 @@ fn emitSegmentInfo(wasm: *Wasm, binary_bytes: *std.ArrayList(u8)) !void {
try binary_bytes.insertSlice(segment_offset, &buf);
}
-pub fn getULEB128Size(uint_value: anytype) u32 {
+pub fn getUleb128Size(uint_value: anytype) u32 {
const T = @TypeOf(uint_value);
const U = if (@typeInfo(T).Int.bits < 8) u8 else T;
var value = @as(U, @intCast(uint_value));
@@ -3879,9 +3879,9 @@ fn emitCodeRelocations(
// write custom section information
const name = "reloc.CODE";
- try leb.writeULEB128(writer, @as(u32, @intCast(name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(name.len)));
try writer.writeAll(name);
- try leb.writeULEB128(writer, section_index);
+ try leb.writeUleb128(writer, section_index);
const reloc_start = binary_bytes.items.len;
var count: u32 = 0;
@@ -3889,17 +3889,17 @@ fn emitCodeRelocations(
// for each atom, we calculate the uleb size and append that
var size_offset: u32 = 5; // account for code section size leb128
while (true) {
- size_offset += getULEB128Size(atom.size);
+ size_offset += getUleb128Size(atom.size);
for (atom.relocs.items) |relocation| {
count += 1;
const sym_loc: SymbolLoc = .{ .file = atom.file, .index = @enumFromInt(relocation.index) };
const symbol_index = symbol_table.get(sym_loc).?;
- try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type));
+ try leb.writeUleb128(writer, @intFromEnum(relocation.relocation_type));
const offset = atom.offset + relocation.offset + size_offset;
- try leb.writeULEB128(writer, offset);
- try leb.writeULEB128(writer, symbol_index);
+ try leb.writeUleb128(writer, offset);
+ try leb.writeUleb128(writer, symbol_index);
if (relocation.relocation_type.addendIsPresent()) {
- try leb.writeILEB128(writer, relocation.addend);
+ try leb.writeIleb128(writer, relocation.addend);
}
log.debug("Emit relocation: {}", .{relocation});
}
@@ -3926,9 +3926,9 @@ fn emitDataRelocations(
// write custom section information
const name = "reloc.DATA";
- try leb.writeULEB128(writer, @as(u32, @intCast(name.len)));
+ try leb.writeUleb128(writer, @as(u32, @intCast(name.len)));
try writer.writeAll(name);
- try leb.writeULEB128(writer, section_index);
+ try leb.writeUleb128(writer, section_index);
const reloc_start = binary_bytes.items.len;
var count: u32 = 0;
@@ -3937,17 +3937,17 @@ fn emitDataRelocations(
for (wasm.data_segments.values()) |segment_index| {
var atom: *Atom = wasm.getAtomPtr(wasm.atoms.get(segment_index).?);
while (true) {
- size_offset += getULEB128Size(atom.size);
+ size_offset += getUleb128Size(atom.size);
for (atom.relocs.items) |relocation| {
count += 1;
const sym_loc: SymbolLoc = .{ .file = atom.file, .index = @enumFromInt(relocation.index) };
const symbol_index = symbol_table.get(sym_loc).?;
- try leb.writeULEB128(writer, @intFromEnum(relocation.relocation_type));
+ try leb.writeUleb128(writer, @intFromEnum(relocation.relocation_type));
const offset = atom.offset + relocation.offset + size_offset;
- try leb.writeULEB128(writer, offset);
- try leb.writeULEB128(writer, symbol_index);
+ try leb.writeUleb128(writer, offset);
+ try leb.writeUleb128(writer, symbol_index);
if (relocation.relocation_type.addendIsPresent()) {
- try leb.writeILEB128(writer, relocation.addend);
+ try leb.writeIleb128(writer, relocation.addend);
}
log.debug("Emit relocation: {}", .{relocation});
}
diff --git a/src/link/Wasm/Object.zig b/src/link/Wasm/Object.zig
index b2f41a33b0..378ea34e0c 100644
--- a/src/link/Wasm/Object.zig
+++ b/src/link/Wasm/Object.zig
@@ -590,7 +590,7 @@ fn Parser(comptime ReaderType: type) type {
const reader = parser.reader.reader();
for (try readVec(&parser.object.features, reader, gpa)) |*feature| {
const prefix = try readEnum(types.Feature.Prefix, reader);
- const name_len = try leb.readULEB128(u32, reader);
+ const name_len = try leb.readUleb128(u32, reader);
const name = try gpa.alloc(u8, name_len);
defer gpa.free(name);
try reader.readNoEof(name);
@@ -613,8 +613,8 @@ fn Parser(comptime ReaderType: type) type {
/// they apply to.
fn parseRelocations(parser: *ObjectParser, gpa: Allocator) !void {
const reader = parser.reader.reader();
- const section = try leb.readULEB128(u32, reader);
- const count = try leb.readULEB128(u32, reader);
+ const section = try leb.readUleb128(u32, reader);
+ const count = try leb.readUleb128(u32, reader);
const relocations = try gpa.alloc(types.Relocation, count);
errdefer gpa.free(relocations);
@@ -628,9 +628,9 @@ fn Parser(comptime ReaderType: type) type {
const rel_type_enum = std.meta.intToEnum(types.Relocation.RelocationType, rel_type) catch return error.MalformedSection;
relocation.* = .{
.relocation_type = rel_type_enum,
- .offset = try leb.readULEB128(u32, reader),
- .index = try leb.readULEB128(u32, reader),
- .addend = if (rel_type_enum.addendIsPresent()) try leb.readILEB128(i32, reader) else 0,
+ .offset = try leb.readUleb128(u32, reader),
+ .index = try leb.readUleb128(u32, reader),
+ .addend = if (rel_type_enum.addendIsPresent()) try leb.readIleb128(i32, reader) else 0,
};
log.debug("Found relocation: type({s}) offset({d}) index({d}) addend({?d})", .{
@tagName(relocation.relocation_type),
@@ -651,7 +651,7 @@ fn Parser(comptime ReaderType: type) type {
var limited = std.io.limitedReader(parser.reader.reader(), payload_size);
const limited_reader = limited.reader();
- const version = try leb.readULEB128(u32, limited_reader);
+ const version = try leb.readUleb128(u32, limited_reader);
log.debug("Link meta data version: {d}", .{version});
if (version != 2) return error.UnsupportedVersion;
@@ -667,30 +667,30 @@ fn Parser(comptime ReaderType: type) type {
/// `parser` is used to provide access to other sections that may be needed,
/// such as access to the `import` section to find the name of a symbol.
fn parseSubsection(parser: *ObjectParser, gpa: Allocator, reader: anytype) !void {
- const sub_type = try leb.readULEB128(u8, reader);
+ const sub_type = try leb.readUleb128(u8, reader);
log.debug("Found subsection: {s}", .{@tagName(@as(types.SubsectionType, @enumFromInt(sub_type)))});
- const payload_len = try leb.readULEB128(u32, reader);
+ const payload_len = try leb.readUleb128(u32, reader);
if (payload_len == 0) return;
var limited = std.io.limitedReader(reader, payload_len);
const limited_reader = limited.reader();
// every subsection contains a 'count' field
- const count = try leb.readULEB128(u32, limited_reader);
+ const count = try leb.readUleb128(u32, limited_reader);
switch (@as(types.SubsectionType, @enumFromInt(sub_type))) {
.WASM_SEGMENT_INFO => {
const segments = try gpa.alloc(types.Segment, count);
errdefer gpa.free(segments);
for (segments) |*segment| {
- const name_len = try leb.readULEB128(u32, reader);
+ const name_len = try leb.readUleb128(u32, reader);
const name = try gpa.alloc(u8, name_len);
errdefer gpa.free(name);
try reader.readNoEof(name);
segment.* = .{
.name = name,
- .alignment = @enumFromInt(try leb.readULEB128(u32, reader)),
- .flags = try leb.readULEB128(u32, reader),
+ .alignment = @enumFromInt(try leb.readUleb128(u32, reader)),
+ .flags = try leb.readUleb128(u32, reader),
};
log.debug("Found segment: {s} align({d}) flags({b})", .{
segment.name,
@@ -711,8 +711,8 @@ fn Parser(comptime ReaderType: type) type {
errdefer gpa.free(funcs);
for (funcs) |*func| {
func.* = .{
- .priority = try leb.readULEB128(u32, reader),
- .symbol_index = try leb.readULEB128(u32, reader),
+ .priority = try leb.readUleb128(u32, reader),
+ .symbol_index = try leb.readUleb128(u32, reader),
};
log.debug("Found function - prio: {d}, index: {d}", .{ func.priority, func.symbol_index });
}
@@ -722,23 +722,23 @@ fn Parser(comptime ReaderType: type) type {
const comdats = try gpa.alloc(types.Comdat, count);
errdefer gpa.free(comdats);
for (comdats) |*comdat| {
- const name_len = try leb.readULEB128(u32, reader);
+ const name_len = try leb.readUleb128(u32, reader);
const name = try gpa.alloc(u8, name_len);
errdefer gpa.free(name);
try reader.readNoEof(name);
- const flags = try leb.readULEB128(u32, reader);
+ const flags = try leb.readUleb128(u32, reader);
if (flags != 0) {
return error.UnexpectedValue;
}
- const symbol_count = try leb.readULEB128(u32, reader);
+ const symbol_count = try leb.readUleb128(u32, reader);
const symbols = try gpa.alloc(types.ComdatSym, symbol_count);
errdefer gpa.free(symbols);
for (symbols) |*symbol| {
symbol.* = .{
- .kind = @as(types.ComdatSym.Type, @enumFromInt(try leb.readULEB128(u8, reader))),
- .index = try leb.readULEB128(u32, reader),
+ .kind = @as(types.ComdatSym.Type, @enumFromInt(try leb.readUleb128(u8, reader))),
+ .index = try leb.readUleb128(u32, reader),
};
}
@@ -799,8 +799,8 @@ fn Parser(comptime ReaderType: type) type {
/// requires access to `Object` to find the name of a symbol when it's
/// an import and flag `WASM_SYM_EXPLICIT_NAME` is not set.
fn parseSymbol(parser: *ObjectParser, gpa: Allocator, reader: anytype) !Symbol {
- const tag = @as(Symbol.Tag, @enumFromInt(try leb.readULEB128(u8, reader)));
- const flags = try leb.readULEB128(u32, reader);
+ const tag = @as(Symbol.Tag, @enumFromInt(try leb.readUleb128(u8, reader)));
+ const flags = try leb.readUleb128(u32, reader);
var symbol: Symbol = .{
.flags = flags,
.tag = tag,
@@ -811,7 +811,7 @@ fn Parser(comptime ReaderType: type) type {
switch (tag) {
.data => {
- const name_len = try leb.readULEB128(u32, reader);
+ const name_len = try leb.readUleb128(u32, reader);
const name = try gpa.alloc(u8, name_len);
defer gpa.free(name);
try reader.readNoEof(name);
@@ -819,14 +819,14 @@ fn Parser(comptime ReaderType: type) type {
// Data symbols only have the following fields if the symbol is defined
if (symbol.isDefined()) {
- symbol.index = try leb.readULEB128(u32, reader);
+ symbol.index = try leb.readUleb128(u32, reader);
// @TODO: We should verify those values
- _ = try leb.readULEB128(u32, reader);
- _ = try leb.readULEB128(u32, reader);
+ _ = try leb.readUleb128(u32, reader);
+ _ = try leb.readUleb128(u32, reader);
}
},
.section => {
- symbol.index = try leb.readULEB128(u32, reader);
+ symbol.index = try leb.readUleb128(u32, reader);
const section_data = parser.object.relocatable_data.get(.custom).?;
for (section_data) |*data| {
if (data.section_index == symbol.index) {
@@ -837,11 +837,11 @@ fn Parser(comptime ReaderType: type) type {
}
},
else => {
- symbol.index = try leb.readULEB128(u32, reader);
+ symbol.index = try leb.readUleb128(u32, reader);
const is_undefined = symbol.isUndefined();
const explicit_name = symbol.hasFlag(.WASM_SYM_EXPLICIT_NAME);
symbol.name = if (!is_undefined or (is_undefined and explicit_name)) name: {
- const name_len = try leb.readULEB128(u32, reader);
+ const name_len = try leb.readUleb128(u32, reader);
const name = try gpa.alloc(u8, name_len);
defer gpa.free(name);
try reader.readNoEof(name);
@@ -867,13 +867,13 @@ fn ElementType(comptime ptr: type) type {
return meta.Elem(meta.Child(ptr));
}
-/// Uses either `readILEB128` or `readULEB128` depending on the
+/// Uses either `readIleb128` or `readUleb128` depending on the
/// signedness of the given type `T`.
/// Asserts `T` is an integer.
fn readLeb(comptime T: type, reader: anytype) !T {
return switch (@typeInfo(T).Int.signedness) {
- .signed => try leb.readILEB128(T, reader),
- .unsigned => try leb.readULEB128(T, reader),
+ .signed => try leb.readIleb128(T, reader),
+ .unsigned => try leb.readUleb128(T, reader),
};
}