failed to retarget asm to x86-64
- Dominant language
- C++
- Stars
- 8.6k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
Hi, guys. Sorry for bothering you.
I wrote a c program that just prints "Hello world" and used **arm-linux-gnueabihf** to compile it into **arm**.
Then, I used retdec-decompiler to decompile it.
I failed to recompile the result.
I used clang to compile .bc file.
I guess "first defined here" can be bypassed with "--allow-multiple-definition".
But, could you tell me how to fix the error **undefined reference to `__asm_adr'** ?
Thank you very much.
Here is the code.
>#include
int main()
{
printf("Hello world\n");
}
info of target.
> hello: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=9207f3df03ef3fc0edeba44efd0ed893beff3fe2, not stripped
log of retdec decompiler
> Running phase: Unpacking ( 0.01s )
No matching plugins found for 'GCC 7.5.0'
No matching plugins found for 'GCC 4.4.3'
Running phase: Initialization ( 0.02s )
Running phase: Providers initialization ( 0.02s )
Running phase: Input binary to LLVM IR decoding ( 0.04s )
Running phase: LLVM ( 0.04s )
Running phase: x86 address spaces optimization ( 0.04s )
Running phase: x87 fpu register analysis ( 0.04s )
Running phase: Main function identification optimization ( 0.04s )
Running phase: Libgcc idioms optimization ( 0.04s )
Running phase: LLVM instruction optimization ( 0.04s )
Running phase: Conditional branch optimization ( 0.04s )
Running phase: Syscalls optimization ( 0.04s )
Running phase: Stack optimization ( 0.04s )
Running phase: Constants optimization ( 0.04s )
Running phase: Function parameters and returns optimization ( 0.04s )
Running phase: LLVM instruction optimization using RDA ( 0.04s )
Running phase: LLVM instruction optimization ( 0.04s )
Running phase: Simple types recovery optimization ( 0.04s )
Running phase: Disassembly generation ( 0.04s )
Running phase: Assembly mapping instruction removal ( 0.04s )
Running phase: C++ class hierarchy optimization ( 0.04s )
Running phase: Selected functions optimization ( 0.04s )
Running phase: Unreachable functions optimization ( 0.04s )
Running phase: LLVM instruction optimization ( 0.04s )
Running phase: Make all registers local ( 0.04s )
Running phase: Value protection optimization ( 0.04s )
Running phase: LLVM ( 0.04s )
Running phase: LLVM instruction optimization ( 0.06s )
Running phase: Simple types recovery optimization ( 0.06s )
Running phase: Stack pointer operations optimization ( 0.06s )
Running phase: Instruction idioms optimization ( 0.06s )
Running phase: LLVM ( 0.06s )
Running phase: LLVM instruction optimization ( 0.06s )
Running phase: Instruction idioms optimization ( 0.06s )
Running phase: Phi removal ( 0.06s )
Running phase: LLVM ( 0.06s )
Running phase: Value protection optimization ( 0.06s )
Running phase: Generate the current LLVM IR ( 0.06s )
Running phase: Generate the current bitcode ( 0.06s )
Running phase: LLVM IR -> HLL ( 0.06s )
Running phase: initialization ( 0.06s )
-> loading the input config ( 0.06s )
-> creating the used HLL writer [c] ( 0.06s )
-> creating the used alias analysis [simple] ( 0.06s )
-> creating the used call info obtainer [optim] ( 0.06s )
-> creating the used evaluator of arithmetical expressions [c] ( 0.06s )
-> creating the used variable names generator [fruit] ( 0.06s )
-> creating the used variable renamer [readable] ( 0.06s )
-> creating the used semantics [libc,gcc-general,win-api] ( 0.06s )
Running phase: conversion of LLVM IR into BIR ( 0.06s )
-> converting global variables ( 0.06s )
-> converting function _init ( 0.06s )
-> converting function $a ( 0.06s )
-> converting function function_3cc ( 0.06s )
-> converting function function_3d8 ( 0.06s )
-> converting function function_3e4 ( 0.06s )
-> converting function function_3f0 ( 0.06s )
-> converting function _start ( 0.06s )
-> converting function call_weak_fn ( 0.06s )
-> converting function deregister_tm_clones ( 0.06s )
-> converting function register_tm_clones ( 0.06s )
-> converting function __do_global_dtors_aux ( 0.06s )
-> converting function frame_dummy ( 0.06s )
-> converting function main ( 0.06s )
-> converting function __libc_csu_init ( 0.06s )
-> converting function __libc_csu_fini ( 0.06s )
-> converting function _fini ( 0.06s )
Running phase: removing functions from standard libraries ( 0.06s )
Running phase: removing code that is not reachable in a CFG ( 0.06s )
Running phase: signed/unsigned types fixing ( 0.06s )
Running phase: converting LLVM intrinsic functions to standard functions ( 0.06s )
Running phase: obtaining debug information ( 0.06s )
Running phase: alias analysis [simple] ( 0.06s )
Running phase: optimizations [normal] ( 0.06s )
-> running GotoStmtOptimizer ( 0.06s )
-> running RemoveUselessCastsOptimizer ( 0.06s )
-> running UnusedGlobalVarOptimizer ( 0.06s )
-> running DeadLocalAssignOptimizer ( 0.06s )
-> running SimpleCopyPropagationOptimizer ( 0.06s )
-> running CopyPropagationOptimizer ( 0.06s )
-> running SimplifyArithmExprOptimizer ( 0.06s )
-> running IfStructureOptimizer ( 0.06s )
-> running LoopLastContinueOptimizer ( 0.06s )
-> running PreWhileTrueLoopConvOptimizer ( 0.06s )
-> running WhileTrueToForLoopOptimizer ( 0.06s )
-> running WhileTrueToWhileCondOptimizer ( 0.06s )
-> running IfBeforeLoopOptimizer ( 0.06s )
-> running LLVMIntrinsicsOptimizer ( 0.06s )
-> running VoidReturnOptimizer ( 0.06s )
-> running BreakContinueReturnOptimizer ( 0.06s )
-> running BitShiftOptimizer ( 0.06s )
-> running DerefAddressOptimizer ( 0.06s )
-> running EmptyArrayToStringOptimizer ( 0.06s )
-> running BitOpToLogOpOptimizer ( 0.06s )
-> running SimplifyArithmExprOptimizer ( 0.06s )
-> running UnusedGlobalVarOptimizer ( 0.06s )
-> running DeadLocalAssignOptimizer ( 0.06s )
-> running SimpleCopyPropagationOptimizer ( 0.06s )
-> running CopyPropagationOptimizer ( 0.06s )
-> running SelfAssignOptimizer ( 0.06s )
-> running VarDefForLoopOptimizer ( 0.06s )
-> running VarDefStmtOptimizer ( 0.06s )
-> running EmptyStmtOptimizer ( 0.06s )
-> running GotoStmtOptimizer ( 0.06s )
-> running SimplifyArithmExprOptimizer ( 0.06s )
-> running DeadCodeOptimizer ( 0.06s )
-> running DerefToArrayIndexOptimizer ( 0.06s )
-> running IfToSwitchOptimizer ( 0.06s )
-> running CCastOptimizer ( 0.06s )
-> running CArrayArgOptimizer ( 0.06s )
Running phase: variable renaming [readable] ( 0.06s )
Running phase: converting constants to symbolic names ( 0.06s )
Running phase: module validation ( 0.06s )
-> running BreakOutsideLoopValidator ( 0.06s )
-> running NoGlobalVarDefValidator ( 0.06s )
-> running ReturnValidator ( 0.06s )
Running phase: emission of the target code [c] ( 0.06s )
Running phase: finalization ( 0.06s )
Running phase: cleanup ( 0.06s )
Here is the error message
> warning: overriding the module target triple with x86_64-pc-linux-gnu [-Woverride-module]
1 warning generated.
/tmp/retdec_arm_hello-7c2541.o: In function `_fini':
test:(.text+0x190): multiple definition of `_fini'
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
/tmp/retdec_arm_hello-7c2541.o: In function `_init':
test:(.text+0x0): multiple definition of `_init'
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
/tmp/retdec_arm_hello-7c2541.o: In function `_start':
test:(.text+0x60): multiple definition of `_start'
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here
/tmp/retdec_arm_hello-7c2541.o: In function `_start':
test:(.text+0x6f): undefined reference to `__asm_adr'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the reported failure by compiling the generated .bc with clang and review the target-triple warning, duplicate _init/_fini/_start definitions, and unresolved __asm_adr symbol. The issue provides no repository file or test entry point; done would require determining whether cross-target recompilation is supported and documenting or fixing the resulting linker errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, linux
- Domain
- compilers, reverse-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100