mirror of
https://github.com/ziglang/zig.git
synced 2026-02-03 21:23:36 +00:00
wasm linker: fix eliding empty data segments
This commit is contained in:
parent
568d9936ab
commit
5fac6f380e
@ -1410,6 +1410,14 @@ pub const DataSegment = extern struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn isEmpty(id: Id, wasm: *const Wasm) bool {
|
||||
return switch (unpack(id, wasm)) {
|
||||
.__zig_error_name_table => false,
|
||||
.object => |i| i.ptr(wasm).payload.off == .none,
|
||||
inline .uav_exe, .uav_obj, .nav_exe, .nav_obj => |i| i.value(wasm).code.off == .none,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn size(id: Id, wasm: *const Wasm) u32 {
|
||||
return switch (unpack(id, wasm)) {
|
||||
.__zig_error_name_table => {
|
||||
|
||||
@ -657,7 +657,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
|
||||
var group_index: u32 = 0;
|
||||
var offset: u32 = undefined;
|
||||
for (segment_ids, segment_offsets) |segment_id, segment_offset| {
|
||||
if (!import_memory and segment_id.isBss(wasm)) {
|
||||
if (segment_id.isEmpty(wasm)) {
|
||||
// It counted for virtual memory but it does not go into the binary.
|
||||
continue;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user