aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/81_global_addr.sy
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/81_global_addr.sy')
-rw-r--r--tests/functional/81_global_addr.sy17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/functional/81_global_addr.sy b/tests/functional/81_global_addr.sy
new file mode 100644
index 0000000..7089f70
--- /dev/null
+++ b/tests/functional/81_global_addr.sy
@@ -0,0 +1,17 @@
+// 回归用例: rv64 全局符号取址走 `la` (medany), 而非 lui %hi/addi %lo (medlow)
+// 触发 (修前): bare-metal/高地址链接脚本下 R_RISCV_HI20 relocation truncated
+int g[10];
+int read_arr(int a[], int idx) {
+ return a[idx];
+}
+int main() {
+ int i;
+ i = 0;
+ while (i < 10) {
+ g[i] = i * i;
+ i = i + 1;
+ }
+ putint(read_arr(g, 7));
+ putch(10);
+ return 0;
+}