Conversation
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Since the original codebase already implemented the immediate binding flag for the x86-64 and AArch64 architectures, this commit introduces a "-z" option so that the Arm32 and RV32 targets can also use immediate binding. When the command-line arguments contain "-z now", the compiler sets its internal flag (imm_binding) to true and generates the Elf32_Dyn/Elf64_Dyn objects to enable exectuables to perform immediate binding at runtime. For 64-bit targets, immediate binding is always used under the dynamic linking mode as is.
Since the compiler supports the "-z" option for lazy or immediate binding, a new "BINDING" variable has benn added to the Makefile so that users can choose which binding mode to use. For example, users can build dynamically linked compilers with immediate binding as follows: $ make DYNLINK=1 BINDING=now
Since the compiler has implemented dynamic linking with immediate binding, the test suites have been enhance to validate immediate binding mode. The approach is to add an additional command-line argument to determine which mode, lazy or immediate, is enabled during the tests.
0d1e98b to
3c3998d
Compare
There was a problem hiding this comment.
2 issues found across 7 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/riscv-abi.sh">
<violation number="1" location="tests/riscv-abi.sh:149">
P2: An unvalidated `binding` argument is inserted into a command string executed by `eval`, so invoking this test script with a crafted third argument executes arbitrary shell commands. Validate the value against `lazy|now` or shell-escape it before constructing the command.</violation>
</file>
<file name="tests/arm-abi.sh">
<violation number="1" location="tests/arm-abi.sh:149">
P2: When the binding argument contains shell syntax, this line inserts it into an `eval` string, so the ABI test executes it as a separate command. Escape the value or execute the compiler through an argv array.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| local compile_cmd="$SHECC" | ||
| if [[ "$DYNLINK" == "1" ]]; then | ||
| compile_cmd="$compile_cmd --dynlink" | ||
| compile_cmd="$compile_cmd --dynlink -z $BINDING" |
There was a problem hiding this comment.
P2: An unvalidated binding argument is inserted into a command string executed by eval, so invoking this test script with a crafted third argument executes arbitrary shell commands. Validate the value against lazy|now or shell-escape it before constructing the command.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/riscv-abi.sh, line 149:
<comment>An unvalidated `binding` argument is inserted into a command string executed by `eval`, so invoking this test script with a crafted third argument executes arbitrary shell commands. Validate the value against `lazy|now` or shell-escape it before constructing the command.</comment>
<file context>
@@ -144,7 +146,7 @@ run_abi_test()
local compile_cmd="$SHECC"
if [[ "$DYNLINK" == "1" ]]; then
- compile_cmd="$compile_cmd --dynlink"
+ compile_cmd="$compile_cmd --dynlink -z $BINDING"
fi
compile_cmd="$compile_cmd -o /tmp/shecc_abi_test_$$.elf $test_file"
</file context>
| compile_cmd="$compile_cmd --dynlink -z $BINDING" | |
| compile_cmd="$compile_cmd --dynlink -z $(printf '%q' "$BINDING")" |
| local compile_cmd="$SHECC" | ||
| if [[ "$DYNLINK" == "1" ]]; then | ||
| compile_cmd="$compile_cmd --dynlink" | ||
| compile_cmd="$compile_cmd --dynlink -z $BINDING" |
There was a problem hiding this comment.
P2: When the binding argument contains shell syntax, this line inserts it into an eval string, so the ABI test executes it as a separate command. Escape the value or execute the compiler through an argv array.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/arm-abi.sh, line 149:
<comment>When the binding argument contains shell syntax, this line inserts it into an `eval` string, so the ABI test executes it as a separate command. Escape the value or execute the compiler through an argv array.</comment>
<file context>
@@ -144,7 +146,7 @@ run_abi_test()
local compile_cmd="$SHECC"
if [[ "$DYNLINK" == "1" ]]; then
- compile_cmd="$compile_cmd --dynlink"
+ compile_cmd="$compile_cmd --dynlink -z $BINDING"
fi
compile_cmd="$compile_cmd -o /tmp/shecc_abi_test_$$.elf $test_file"
</file context>
| compile_cmd="$compile_cmd --dynlink -z $BINDING" | |
| compile_cmd="$compile_cmd --dynlink -z $(printf '%q' "$BINDING")" |
jserv
left a comment
There was a problem hiding this comment.
Rebase latest master branch and resolve conflicts.
Since the immediate binding has already been implemented for the x86-64 and AArch64 architectures, the proposed changes extend its use by introducing a new "-z" command-line option, allowing the Arm32 and RV32 targets to also generate dynamically linked executables with immediate binding.
For the two 64-bit targets, immediate binding is always used under the dynamic linking mode as is.
The update usage:
TODO:
Summary by cubic
Adds a
-zoption to control dynamic binding:lazy(default) ornow(immediate). It replaces the hardcoded immediate binding on x86-64 and AArch64 and lets Arm32 and RV32 dynamically linked executables use immediate binding.BINDINGvariable, so builds can pass-z nowviamake DYNLINK=1 BINDING=now; the ABI and driver tests now take the binding to cover both modes.nowin dynamic mode, so-z lazyis ignored there.Written for commit 3c3998d. Summary will update on new commits.