mcsema using error,has someone use mcsema successful - linker

I flow the Official website to build mcsema using native build approach.Everything seems OK.Since my ida is on Windows,so I use the command of
%IDA_ROOT%\ida64.exe -S"C:\Users\dkl\Desktop\source\mcsema\tools\mcsema_disass\ida7\get_cfg.py --output
C:\Users\dkl\Desktop\output.cfg --arch amd64 --os linux" C:\Users\dkl\Desktop\work\t2\a.out
to generate output.cfg ,that is OK
then
mcsema-lift-11.0 --arch amd64 --os linux --cfg ./output.cfg --output ./output.bc
that is OK,then
remill-clang-11 -o ./output ./output.bc -lpthread -lm -ldl -llzma -Wl,--section-start=.section_1ff00000=0x1ff00000
COUNTER A ERROR
root#DESKTOP-CS6BMJI:/mnt/c/Users/dkl/Desktop# mcsema-lift-11.0 --arch amd64 --os linux --cfg ./output.cfg --output ./output.bc
root#DESKTOP-CS6BMJI:/mnt/c/Users/dkl/Desktop# remill-clang-11 -o ./output ./output.bc -lpthread -lm -ldl -llzma -Wl,--section-start=.section_1ff00000=0x1ff00000
warning: overriding the module target triple with x86_64-unknown-linux-gnu [-Woverride-module]
1 warning generated.
/usr/bin/ld: /tmp/output-3e1099.o: in function sub_401020': llvm-link:(.text+0x152): undefined reference to __remill_jump'
/usr/bin/ld: /tmp/output-3e1099.o: in function sub_401040__start': llvm-link:(.text+0x2cb): undefined reference to __remill_function_call'
/usr/bin/ld: /tmp/output-3e1099.o: in function sub_401160___libc_csu_init': llvm-link:(.text+0x939): undefined reference to __remill_function_call'
/usr/bin/ld: /tmp/output-3e1099.o: in function sub_401000__init_proc': llvm-link:(.text+0xe2d): undefined reference to __remill_function_call'
/usr/bin/ld: /tmp/output-3e1099.o: in function ext_404040_printf': llvm-link:(.text+0x10da): undefined reference to __remill_function_call'
/usr/bin/ld: /tmp/output-3e1099.o:(.rodata+0x2138): undefined reference to `__mcsema_attach_call'
remill-clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
root#DESKTOP-CS6BMJI:/mnt/c/Users/dkl/Desktop#

Related

How do I properly link math.h library in makefiles?

I need to plot a function with gnuplot. This function requires the math.h library. Now I want to run it with a makefile.
When I run the makefile I get this output/error:
gcc -I./inc -o./build/result -lm ./src/main.c ./src/gnuplot.c
/usr/bin/ld: /tmp/ccwsiOjK.o: in function `plot_y':
main.c:(.text+0x64): undefined reference to `exp'
/usr/bin/ld: main.c:(.text+0xbc): undefined reference to `pow'
/usr/bin/ld: main.c:(.text+0x121): undefined reference to `exp'
collect2: error: ld returned 1 exit status
make: *** [makefile:5: all] Fehler 1
I think I didn't link the math.h library properly.
The makefile:
run: all
./build/result
all: build
gcc -I./inc -o./build/result -lm ./src/main.c ./src/gnuplot.c
#-I./inc damit der compiler nicht nur im src Ordner sucht
build:
mkdir build
clean:
rm -f -r build
The order matters. First list the .c or .o files, then the external libraries.
gcc -I./inc -o./build/result ./src/main.c ./src/gnuplot.c -lm

Undefined reference. But can't find the specific library name

I'm going to assemble a program. But errors followed.
gcc -no-pie final.s -ldl -lm -lz -lrt -lpthread -lcrypt -lgmp -m64
/usr/bin/ld: error in /tmp/ccjXcZiN.o(.eh_frame); no .eh_frame_hdr table will be created.
/tmp/ccjXcZiN.o: In function `S_0x404C5A':
(.text+0x775): undefined reference to `have_libloaded'
/tmp/ccjXcZiN.o: In function `BB_73':
(.text+0x78f): undefined reference to `libhandle'
/tmp/ccjXcZiN.o: In function `BB_74':
(.text+0x79c): undefined reference to `load_library_errmsg'
/tmp/ccjXcZiN.o: In function `S_0x404CA0':
(.text+0x7bf): undefined reference to `have_libloaded'
collect2: error: ld returned 1 exit status
I know that there're some other libraries needed on the machine. But i can't search for the specific library name.

libmodbus: how to compile application including libmodbus library?

I have a problem with compilation of my application, which is based on libmodbus library:
https://github.com/stephane/libmodbus
I have tried to compile it using this command:
cc pkg-config --cflags --libs libmodbus modbus.c -o modbus
But I get the following errors:
/usr/bin/ld: /tmp/cckdtbWy.o: in function `main':
modbus.c:(.text+0x1b): undefined reference to `modbus_new_tcp_pi'
/usr/bin/ld: modbus.c:(.text+0x5c): undefined reference to `modbus_connect'
/usr/bin/ld: modbus.c:(.text+0x8d): undefined reference to `modbus_free'
/usr/bin/ld: modbus.c:(.text+0xa3): undefined reference to `modbus_connect'
/usr/bin/ld: modbus.c:(.text+0xde): undefined reference to `modbus_read_bits'
/usr/bin/ld: modbus.c:(.text+0x11e): undefined reference to `modbus_close'
/usr/bin/ld: modbus.c:(.text+0x12a): undefined reference to `modbus_free'
collect2: error: ld returned 1 exit status
I would appreciate any help!
Best regards!
I have worked through this problem and my solution is that:
1. Create modbus.conf file in /etc/ld.so.conf.d/.
2. Run sudo ldconfig.
3. Compile your application/program with the following command:
gcc <name>.c -o <name> -I/usr/local/include/modbus/ -lmodbus
It has worked for me, but I am not sure whether the first step is necessary.
Did you install the libmodbus-dev? You should try this: sudo apt-get install -y libmodbus-dev.
See v3.1.6 and v3.0.8: libmodbus docs

MonetDB test client application not linking

I tried to compile test application for MonetDB under Ubuntu 14.04 LTS Trusty Tahr. I followed the download instructions from official site, installation was successful, then I installed a bunch of other packages in order to copmpile it. Now when I try to compile and link test application I get the following errors:
libtool: compile: gcc -c -I/usr/include/monetdb test.c -fPIC -DPIC -o .libs/test.o
libtool: compile: gcc -c -I/usr/include/monetdb test.c -o test.o >/dev/null 2>&1
libtool: link: gcc -o test test.o -lmapi -lstream -lssl -lcrypto -lcurl -lz
test.o: In function `die':
test.c:(.text+0x1c): undefined reference to `mapi_explain_query'
test.c:(.text+0x27): undefined reference to `mapi_result_error'
test.c:(.text+0x3f): undefined reference to `mapi_explain_result'
test.c:(.text+0x4a): undefined reference to `mapi_next_result'
test.c:(.text+0x5a): undefined reference to `mapi_close_handle'
test.c:(.text+0x65): undefined reference to `mapi_destroy'
test.c:(.text+0x81): undefined reference to `mapi_explain'
test.c:(.text+0x8c): undefined reference to `mapi_destroy'
test.o: In function `query':
test.c:(.text+0xde): undefined reference to `mapi_query'
test.c:(.text+0xf2): undefined reference to `mapi_error'
test.o: In function `update':
test.c:(.text+0x133): undefined reference to `mapi_close_handle'
test.o: In function `main':
test.c:(.text+0x190): undefined reference to `mapi_connect'
test.c:(.text+0x1a0): undefined reference to `mapi_error'
test.c:(.text+0x222): undefined reference to `mapi_fetch_field'
test.c:(.text+0x23a): undefined reference to `mapi_fetch_field'
test.c:(.text+0x266): undefined reference to `mapi_fetch_row'
test.c:(.text+0x276): undefined reference to `mapi_close_handle'
test.c:(.text+0x282): undefined reference to `mapi_destroy'
collect2: error: ld returned 1 exit status
./t.sh: 11: ./t.sh: ./test: not found
What I'm doing wrong? What should I additionally install or change in compilation options for successful linking of test example?
I was able to compile the example on Ubuntu 14.04 with MonetDB installed from the Ubuntu binary packages after installing the (additional) package libmonetdb-client-dev with the following command:
gcc test.c -I /usr/include/monetdb -lmapi
Did you compile and install MonetDB from source? In this case, which prefix was used?
Here how it worked using ubuntu 18.04
gcc main.c -I /usr/include/monetdb -lmapi -lssl -lcrypto -lstream -lcurl -llzma -lbz2

What causes this link failure (undefined reference)?

I just switched my dev machine from Gentoo to Arch Linux and, when I try to compile a fresh build of my project, linking fails:
clang -O0 -g -pipe -Wall -DDEBUG -o slug announce.o bitfield.o main.o metadata.o network.o parser.o peer.o piece.o scheduler.o torrent.o url.o util.o -I. -lssl -lm -lcurl -levent
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:186: error: undefined reference to 'SHA1_Init'
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:187: error: undefined reference to 'SHA1_Update'
/usr/bin/ld.gold: metadata.o: in function get_info_hash:metadata.c:188: error: undefined reference to 'SHA1_Final'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:40: error: undefined reference to 'SHA1_Init'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:41: error: undefined reference to 'SHA1_Update'
/usr/bin/ld.gold: piece.o: in function verify_piece:piece.c:42: error: undefined reference to 'SHA1_Final'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [slug] Error 1
The entire source is on GitHub: https://github.com/robertseaton/slug.
Looks like you're missing -lcrypto
From my experience, the location of -lssl or -lcrypto may be the source of the problem. Try to push -lcrypto option to the end of the gcc options, or before input object files.

Resources