Hi all,
I pushed the following fix to mob:
fada98b1ce9ee0c36771183177218828ccb9b9de fix(riscv64-link): pair pcrel lo
relocations by hi address
Environment:
-
Runtime OS: kairOS (custom OS), riscv64
-
TinyCC target string: riscv64 Linux (as reported by tcc -vv)
Problem: On riscv64, linking could fail with: "unsupported hi/lo pcrel
reloc scheme".
Root cause: PCREL_LO relocations could be matched against a wrong "last
seen" HI relocation when HI/LO are not adjacent.
Fix:
-
Track PCREL_HI/GOT_HI relocations by address.
-
Resolve PCREL_LO against the referenced HI relocation.
-
Reset/free per-link pairing state.
Files: riscv64-link.c tcc.h tccelf.c
Reproduction and result: Source: #include <stdio.h> int main(void) {
printf("hello world\n"); return 0; }
Before fix: $ tcc hello.c -o hello tcc: error: unsupported hi/lo pcrel
reloc scheme
After fix: $ tcc hello.c -o hello && ./hello hello world
Validation scope:
-
Verified the above repro on kairOS/riscv64.
-
Verified kairOS tcc smoke path in my environment.
Please review.
Thanks, TianYi Chen
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel