Comments (3)
ping
from mcsema.
It looks like a 64-bit pointer is truncated to 32-bit. I made a very crude change s/i32/i64/
in test_opt.ll
which made it possible to compile an x86_64 binary using clang.
Including the (probably incorrect) LLVM IR after the search and replace:
; ModuleID = 'test.bc'
%struct.rlimit = type { i64, i64 }
define i64 @main() {
driverBlock:
%rl = alloca %struct.rlimit, align 8
%0 = bitcast %struct.rlimit* %rl to i64*
store i64 0, i64* %0, align 8
%1 = ptrtoint %struct.rlimit* %rl to i64
%2 = call i64 @getrlimit(i64 3, i64 %1)
%3 = getelementptr %struct.rlimit* %rl, i32 0, i32 0
%4 = load i64* %3, align 8
%5 = call i64 @mmap(i64 0, i64 %4, i64 3, i64 131106, i64 -1, i64 0)
%6 = add i64 %4, -60
%7 = add i64 %6, %5
%8 = inttoptr i64 %7 to i64*
store i64 0, i64* %8, align 4
%rl1 = alloca %struct.rlimit, align 8
%9 = bitcast %struct.rlimit* %rl1 to i64*
store i64 0, i64* %9, align 8
%10 = ptrtoint %struct.rlimit* %rl1 to i64
%11 = call i64 @getrlimit(i64 3, i64 %10)
%12 = getelementptr %struct.rlimit* %rl1, i32 0, i32 0
%13 = load i64* %12, align 8
%14 = tail call i64 @munmap(i64 %5, i64 %13)
ret i64 -5
}
declare i64 @getrlimit(i64, i64)
declare i64 @mmap(i64, i64, i64, i64, i64, i64)
declare i64 @munmap(i64, i64)
!llvm.module.flags = !{!0, !1}
!0 = !{i64 1, !"Debug Info Version", i64 1}
!1 = !{i64 1, !"Dwarf Version", i64 3}
from mcsema.
So the problem is that automatic driver generation assumes you are translating to the same architecture you started with, since it calls APIs with architecture specific arguments (e.g. mmap on Linux).
If you want to cross architectures, you should define a raw
driver and feed it with a struct RegState
to match initial register state of the original architecture. See demo_driver1.c in the demos.
If your program calls any external functions, you'll also need to define stubs for them somewhere, unless the new architecture can exactly match the function prototypes.
from mcsema.
Related Issues (20)
- Docker build error HOT 1
- dyninst frontend is not gettting built on Linux HOT 4
- Segfault while running lifted binary HOT 1
- How not to be explicit about "runtime's memory" HOT 4
- Decompiling Windows binaries (32bit and 64bit) does not work at all HOT 3
- Building mcsema with clang12 error HOT 10
- Official support for running mcsema with rizin/cutter HOT 2
- build error on ubuntu 20.04
- Dockerfile is not up-to-date with remill dependency HOT 2
- Feature request: Improve installation process with precompiled binaries HOT 1
- to see details in the generated 'xxx.cfg'
- fatal error: 'anvill/Program.h' file not found HOT 1
- Can you walk through the example on docs/McSemaWalkthrough.md and check if it still works?
- Unable to build the docker image
- error while translating function with function pointer as parameter HOT 5
- wsl-1.0 ubuntu20+win ida7.5 counter a error of
- Converting 64 bit program to 32 bit HOT 2
- Use mcsema with IDA Home
- Issue in disassembling binaries
- how to make llvm ir "store" volatile? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mcsema.