Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aborted for linux x64 binary (hello, world) #2

Closed
steward-fu opened this issue Oct 15, 2018 · 2 comments
Closed

aborted for linux x64 binary (hello, world) #2

steward-fu opened this issue Oct 15, 2018 · 2 comments

Comments

@steward-fu
Copy link

firstly thanks for your efforts !
but aborted when translating linux x64 program (hello)

hello.c
#include <stdio.h>
int main(int argc, char** argv)
{
printf("is me !\n");
}

build:
gcc -o main main.c

aborted log:
./llvm-mctoll -d -print-after-all ~/Downloads/main

; /home/steward/Downloads/main: file format ELF64-x86-64

Disassembling section .text

Function main:
Running buildCFG

Machine code for function main: TracksLiveness

bb.0:
PUSH64r $rbp, <0x56348d44d4f8>, implicit-def $rsp, implicit $rsp
$rbp = MOV64rr $rsp, <0x56348d45c428>
$rsp = SUB64ri8 $rsp(tied-def 0), 16, <0x56348d45c528>, implicit-def $eflags
MOV32mr $rbp, 1, $noreg, -4, $noreg, $edi, <0x56348d45c648>
MOV64mr $rbp, 1, $noreg, -16, $noreg, $rsi, <0x56348d45c768>
$rdi = LEA64r $rip, 1, $noreg, 158, $noreg, <0x56348d45c888>
CALL64pcrel32 -363, <0x56348d45c9a8>, implicit $rsp, implicit $ssp
$eax = MOV32ri 0, <0x56348d45cac8>
LEAVE64 <0x56348d45cbe8>, implicit-def $rbp, implicit-def $rsp, implicit $rbp, implicit $rsp
RETQ <0x56348d45cd08>
NOOPW $rax, 1, $rax, 0, $cs, <0x56348d45de38>
NOOPL $rax, 1, $noreg, 0, $noreg, <0x56348d45df58>

End machine code for function main.

llvm-mctoll: /home/steward/Downloads/src/llvm/tools/llvm-mctoll/X86/X86MachineInstructionRaiser.cpp:1291: llvm::Value* X86MachineInstructionRaiser::getMemoryAddressExprValue(const llvm::MachineInstr&, llvm::BasicBlock*): Assertion `((BaseReg == X86::NoRegister) && (IndexReg == X86::NoRegister) && (ScaleAmt == 1)) && "Unhandled addressing mode in memory addr expression calculation"' failed.
./llvm-mctoll(+0x2f952ca)[0x5634896562ca]
./llvm-mctoll(+0x2f9535d)[0x56348965635d]
./llvm-mctoll(+0x2f93349)[0x563489654349]
./llvm-mctoll(+0x2f94d68)[0x563489655d68]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7f6202e2f0c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7f62019c4fff]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f62019c642a]
/lib/x86_64-linux-gnu/libc.so.6(+0x2be67)[0x7f62019bde67]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bf12)[0x7f62019bdf12]
./llvm-mctoll(+0x15d81db)[0x563487c991db]
./llvm-mctoll(+0x15daba5)[0x563487c9bba5]
./llvm-mctoll(+0x15e0e9f)[0x563487ca1e9f]
./llvm-mctoll(+0x15e22b7)[0x563487ca32b7]
./llvm-mctoll(+0x15e2779)[0x563487ca3779]
./llvm-mctoll(+0x15e27ee)[0x563487ca37ee]
./llvm-mctoll(+0x46b010)[0x563486b2c010]
./llvm-mctoll(+0x46b759)[0x563486b2c759]
./llvm-mctoll(+0x3e15b5)[0x563486aa25b5]
./llvm-mctoll(+0x3e38a6)[0x563486aa48a6]
./llvm-mctoll(+0x3e4053)[0x563486aa5053]
./llvm-mctoll(+0x3f844e)[0x563486ab944e]
./llvm-mctoll(+0x3e48a4)[0x563486aa58a4]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f62019b22e1]
./llvm-mctoll(+0x3d999a)[0x563486a9a99a]
Stack dump:
0. Program arguments: ./llvm-mctoll -d -print-after-all /home/steward/Downloads/main
Aborted

Question 1: how to fix this issue ?
Question 2: is it possible to support Win32 x86 ?

Thanks

@bharadwajy
Copy link
Contributor

Thanks for trying the tool out and reporting the failure.

Sorry that your initial attempt did not result in success. I was able to reproduce the failure.

Ans 1: As of now, I have been working with x64 ELF binaries generated by clang - that too the latest one built as part of llvm-mctoll build. Given the potential codegen differences from compiler to compiler, I would not be surprised with such failures while raising gcc generated binaries - particularly at this early stage. I'll look into a fix for this issue.

Ans 2: I think it should be possible to support Win32 - but that will need some additional implementation help with cracking the PE binary.

@bharadwajy
Copy link
Contributor

Fix pushed. Thanks again for reporting this failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants