[PATCH] D120362: [sanitizer][sancov] Refactor GetNextInstructionPc/GetPreviousInstructionPc
Xiaodong Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 23:59:24 PST 2022
XiaodongLoong added a comment.
> For sancov, `getPreviousInstructionPc` does not use the `PC - 8` code path for
> Sparc. Triple.h does not have isSparc yet and I hope someone can investigate
> why Mips/Sparc use the weird -8.
@MaskRay
IMO, The SPARC and MIPS branching operations have a branch delay slot, 4 more bytes occupied.
I did an experiment on MIPS64EL machine as following:
// cat caller.c
void foo() {
void *caller_pc = __builtin_return_address(0);
}
int main() {
foo();
}
Debug with gdb:
print caller_pc variable :
(gdb) p caller_pc
$1 = (void *) 0x555555554b54 <main+48>
Dump of assembler code for function main:
...
0x0000555555554b38 <+20>: lui gp,0x2
0x0000555555554b3c <+24>: daddiu gp,gp,-32340
0x0000555555554b40 <+28>: daddu gp,gp,t9
=> 0x0000555555554b44 <+32>: ld v0,-32680(gp)
0x0000555555554b48 <+36>: move t9,v0
0x0000555555554b4c <+40>: bal 0x555555554af0 <foo> /// caller_pc - 8
0x0000555555554b50 <+44>: nop /// caller_pc - 4
0x0000555555554b54 <+48>: move v0,zero /// caller_pc
0x0000555555554b58 <+52>: move sp,s8
...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120362/new/
https://reviews.llvm.org/D120362
More information about the llvm-commits
mailing list