03-reloc-annotations.sh (887B)
1 # Golden: relocation records + inline disasm annotation for an rv64 2 # call site. Asserts the auipc/jalr pair carries the symbol annotation 3 # AND the relocation table prints the ELF-canonical kind name 4 # (R_RISCV_CALL, via the per-arch ObjElfArchOps.reloc_name table — matching 5 # binutils objdump). The inline disasm annotation keeps the arch-neutral 6 # spelling ([RV_CALL]); it comes from the disassembler, not the obj reader. 7 8 cat > t.c <<'EOF' 9 extern int helper(int); 10 int caller(int x) { return helper(x) + 1; } 11 EOF 12 "$KIT" cc -target riscv64-linux -c t.c -o t.o 13 echo "== reloc records ==" 14 "$KIT" objdump -r t.o | awk ' 15 /^RELOCATION RECORDS/ {print; next} 16 /^OFFSET/ {print; next} 17 /helper/ {print $2, $3}' 18 echo "== call site annotation ==" 19 # Strip leading address+bytes, keep just the mnemonic..end-of-line. 20 "$KIT" objdump -d t.o | grep "auipc" | grep "helper" | sed 's/.*auipc/auipc/'