aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-01-07 22:01:05 +0900
committernsfisis <nsfisis@gmail.com>2026-01-07 22:03:58 +0900
commit1082a32431dcd8f58432a6ce610d35cf37c553ad (patch)
treeb696bf55665d6d8faf44486e28f478b1cb2e25fb
parent6082c2cb0d9101a8e926a399de553f5fb0f0b164 (diff)
downloadducc-1082a32431dcd8f58432a6ce610d35cf37c553ad.tar.gz
ducc-1082a32431dcd8f58432a6ce610d35cf37c553ad.tar.zst
ducc-1082a32431dcd8f58432a6ce610d35cf37c553ad.zip
fix: make string literals compatible with PIE
-rw-r--r--Makefile4
-rw-r--r--src/codegen.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 514eef9..bf073bc 100644
--- a/Makefile
+++ b/Makefile
@@ -26,13 +26,13 @@ $(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
# TODO: provide release build?
+# TODO: use --std=c23 instead of --std=gnu23
$(BUILD_ROOT_DIR)/$(TARGET): $(OBJECTS)
- # TODO: use --std=c23 instead of --std=gnu23
$(CC) -Wall -MMD -g -O0 --std=gnu23 -o $@ $^
# TODO: provide release build?
+# TODO: use --std=c23 instead of --std=gnu23
$(BUILD_DIR)/%.o: src/%.c
- # TODO: use --std=c23 instead of --std=gnu23
$(CC) -c $(CFLAGS) -Wall -MMD -g -O0 --std=gnu23 -o $@ $<
-include $(BUILD_DIR)/*.d
diff --git a/src/codegen.c b/src/codegen.c
index 4387449..4e93e89 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -74,7 +74,7 @@ static void codegen_int_expr(CodeGen* g, AstNode* ast) {
}
static void codegen_str_expr(CodeGen* g, AstNode* ast) {
- fprintf(g->out, " mov rax, OFFSET FLAG:.Lstr__%d\n", ast->node_idx);
+ fprintf(g->out, " lea rax, .Lstr__%d[rip]\n", ast->node_idx);
fprintf(g->out, " push rax\n");
}