Skip to content

Commit

Permalink
Add test for fixupSharedReturnJumpToRelocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Crabtux committed Mar 15, 2024
1 parent 5a009fb commit 0177794
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
5 changes: 4 additions & 1 deletion test/bins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ all:

.PHONY: clean
clean:
rm -fv dectest32 dectest64 rec
rm -fv dectest32 dectest64 rec sharedReturn.o

dectest32: dectest.c types.h
gcc -m32 -fno-pic -no-pie -fno-omit-frame-pointer -o dectest32 -O0 dectest.c
Expand All @@ -22,3 +22,6 @@ rec: rec.c types_rec.h

strings: strings.c
gcc -m64 -fno-pic -no-pie -fno-omit-frame-pointer -o strings -O0 strings.c

sharedReturn.o: sharedReturn.c
gcc -m64 -fno-pic -no-pie -fno-omit-frame-pointer -fno-inline -o sharedReturn.o -O2 -c sharedReturn.c
13 changes: 13 additions & 0 deletions test/bins/sharedReturn.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <stdio.h>

int getNum(void);
int calc(int a, int b);

int main(void){
int c = getNum();

if (c > 2)
return calc(c, 2);
else
return 0;
}
Binary file added test/bins/sharedReturn.o
Binary file not shown.
26 changes: 24 additions & 2 deletions test/db/extras/ghidra
Original file line number Diff line number Diff line change
Expand Up @@ -3119,8 +3119,6 @@ EXPECT=<<EOF

void sym.imp.exit noreturn (void)
{
// WARNING: Could not recover jumptable at 0x080483e8. Too many branches
// WARNING: Treating indirect jump as call
(*_reloc.exit)();
return;
}
Expand Down Expand Up @@ -3364,3 +3362,27 @@ undefined8 main(void)
}
EOF
RUN

NAME=fixup shared return call to relocs
FILE=bins/sharedReturn.o
CMDS=<<EOF
aaa
pdg @ sym.main
EOF
EXPECT=<<EOF

undefined8 sym.main(void)
{
int32_t iVar1;
undefined8 uVar2;

// [04] -r-x section size 31 named .text.startup
iVar1 = getNum();
if (iVar1 < 3) {
return 0;
}
uVar2 = calc(iVar1, 2);
return uVar2;
}
EOF
RUN

0 comments on commit 0177794

Please sign in to comment.