microsoft / llvm-mctoll

llvm-mctoll
Other
816 stars 125 forks source link

Missing segment register handling #148

Closed zijiancogito closed 2 years ago

zijiancogito commented 3 years ago

my command is "./llvm-mctoll -d --include-files="/usr/include/stdio.h" test0.o"

test0.o is compiled from source code with gcc -O0 option

include

int main() { int a; int b; scanf("%d %d", &a, &b); return a+b; }

zijiancogito commented 3 years ago

$ ls /usr/include/stdio.h /usr/include/stdio.h

bharadwajy commented 3 years ago

Thanks for your interest and bug report.

You can create a file (say, gnufuncs.h) with the following function declarations

int __isoc99_scanf (const char *__restrict __format, ...);
void __stack_chk_fail(void);

and invoke

./llvm-mctoll -d --include-files="/usr/include/stdio.h,/full/path/to/gnufuncs.h" test0.o

However, it appears that the binary generated uses the segment register FS for memory accesses. llvm-mctoll does not yet support abstraction of x86 segment registers.

So, even after you provide the external function prototypes, raising the binary would fail.