Skip to content

Commit 3c8e433

Browse files
committed
Change L.%u to L.0, .rela%s to .rela.text
1 parent 2f06401 commit 3c8e433

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

docs/tcc-wasm.wasm

485 Bytes
Binary file not shown.

tcc-wasm.wasm

485 Bytes
Binary file not shown.

zig/tcc-wasm.zig

+16-4
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,29 @@ export fn fprintf(stream: *FILE, format: [*:0]const u8, ...) c_int {
181181

182182
export fn sprintf(str: [*:0]u8, format: [*:0]const u8, ...) c_int {
183183
debug("TODO: sprintf: format={s}", .{format});
184-
_ = memcpy(str, format, strlen(format));
185-
str[strlen(format)] = 0;
184+
if (strcmp(format, "L.%u") == 0) {
185+
const s = "L.0";
186+
_ = memcpy(str, s, strlen(s));
187+
str[strlen(s)] = 0;
188+
} else {
189+
_ = memcpy(str, format, strlen(format));
190+
str[strlen(format)] = 0;
191+
}
186192
debug("TODO: sprintf: return str={s}", .{str});
187193
return @intCast(strlen(str));
188194
}
189195

190196
export fn snprintf(str: [*:0]u8, size: size_t, format: [*:0]const u8, ...) c_int {
191197
debug("TODO: snprintf: size={}, format={s}", .{ size, format });
192198
// TODO: Catch overflow
193-
_ = memcpy(str, format, strlen(format));
194-
str[strlen(format)] = 0;
199+
if (strcmp(format, ".rela%s") == 0) {
200+
const s = ".rela.text";
201+
_ = memcpy(str, s, strlen(s));
202+
str[strlen(s)] = 0;
203+
} else {
204+
_ = memcpy(str, format, strlen(format));
205+
str[strlen(format)] = 0;
206+
}
195207
debug("TODO: snprintf: return str={s}", .{str});
196208
return @intCast(strlen(str));
197209
}

0 commit comments

Comments
 (0)