aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-13 02:25:32 +0900
committernsfisis <nsfisis@gmail.com>2025-08-15 10:06:21 +0900
commita5ab4f4dfacd1938a64df4d07df346774f62c541 (patch)
tree2eca028cfb7afbca9bb3668e89685d6768174e92
parentd38303ba5860cdfb3f2532a3cc1e787a8cccbafd (diff)
downloadducc-a5ab4f4dfacd1938a64df4d07df346774f62c541.tar.gz
ducc-a5ab4f4dfacd1938a64df4d07df346774f62c541.tar.zst
ducc-a5ab4f4dfacd1938a64df4d07df346774f62c541.zip
feat: output .note.GNU-stack section and remove "-z noexecstack" from ld flags
-rw-r--r--codegen.c4
-rw-r--r--justfile2
-rw-r--r--tests/050.sh2
-rw-r--r--tests/test_diff.sh2
-rw-r--r--tests/test_example.sh2
-rw-r--r--tests/test_exit_code.sh2
-rw-r--r--tests/test_output.sh2
7 files changed, 10 insertions, 6 deletions
diff --git a/codegen.c b/codegen.c
index 59cee04..92a8619 100644
--- a/codegen.c
+++ b/codegen.c
@@ -531,6 +531,10 @@ void codegen(Program* prog) {
printf(".intel_syntax noprefix\n\n");
+ // For GNU ld:
+ // https://sourceware.org/binutils/docs/ld/Options.html
+ printf(".section .note.GNU-stack,\"\",@progbits\n\n");
+
printf(".section .rodata\n\n");
for (int i = 0; prog->str_literals[i]; ++i) {
printf(".Lstr__%d:\n", i + 1);
diff --git a/justfile b/justfile
index 016fa19..8ebf5ac 100644
--- a/justfile
+++ b/justfile
@@ -11,7 +11,7 @@ build N="1":
prev=$(({{N}} - 1))
fi
"./ducc${prev}" main.c > main{{N}}.s
- gcc -s -Wl,-z,noexecstack -o ducc{{N}} main{{N}}.s
+ gcc -s -o ducc{{N}} main{{N}}.s
fi
build-upto-5-gen:
diff --git a/tests/050.sh b/tests/050.sh
index 295ac2d..7e05ec2 100644
--- a/tests/050.sh
+++ b/tests/050.sh
@@ -17,7 +17,7 @@ if [[ $? -ne 0 ]]; then
cat main.s >&2
exit 1
fi
-gcc -Wl,-z,noexecstack -o a.out main.s
+gcc -o a.out main.s
./a.out "$@" > output
exit_code=$?
diff --git a/tests/test_diff.sh b/tests/test_diff.sh
index 14e5200..adc281e 100644
--- a/tests/test_diff.sh
+++ b/tests/test_diff.sh
@@ -4,7 +4,7 @@ cat > main.c
if [[ $? -ne 0 ]]; then
exit 1
fi
-gcc -Wl,-z,noexecstack -o a.out main.s
+gcc -o a.out main.s
if [[ ! -f input ]]; then
touch input
fi
diff --git a/tests/test_example.sh b/tests/test_example.sh
index d5feaab..f76b606 100644
--- a/tests/test_example.sh
+++ b/tests/test_example.sh
@@ -4,7 +4,7 @@ filename="../../../examples/$1.c"
if [[ $? -ne 0 ]]; then
exit 1
fi
-gcc -Wl,-z,noexecstack -o a.out main.s
+gcc -o a.out main.s
if [[ ! -f input ]]; then
touch input
fi
diff --git a/tests/test_exit_code.sh b/tests/test_exit_code.sh
index 7119b1d..4cdee0a 100644
--- a/tests/test_exit_code.sh
+++ b/tests/test_exit_code.sh
@@ -4,7 +4,7 @@ cat > main.c
if [[ $? -ne 0 ]]; then
exit 1
fi
-gcc -Wl,-z,noexecstack -o a.out main.s
+gcc -o a.out main.s
./a.out
exit_code=$?
diff --git a/tests/test_output.sh b/tests/test_output.sh
index a286a4a..63dce46 100644
--- a/tests/test_output.sh
+++ b/tests/test_output.sh
@@ -4,7 +4,7 @@ cat > main.c
if [[ $? -ne 0 ]]; then
exit 1
fi
-gcc -Wl,-z,noexecstack -o a.out main.s
+gcc -o a.out main.s
output="$(./a.out)"
exit_code=$?