Open LeoAdamek opened 7 years ago
Same on Alpine 3.5. If recompiled with -fPIC build fails with following error:
cc -c injector.c -o injector.o -Wall -fPIC
injector.c:321:93: warning: excess elements in array initializer
.start={.bytes={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, .len=0},
^~~~
injector.c:321:93: note: (near initialization for 'total_range.start.bytes')
injector.c:322:91: warning: excess elements in array initializer
.end={.bytes={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, .len=0},
^~~~
injector.c:322:91: note: (near initialization for 'total_range.end.bytes')
injector.c: In function 'inject':
injector.c:778:2: warning: asm operand 15 probably doesn't match constraints
__asm__ __volatile__ ("\
^~~~~~~
injector.c:778:2: error: impossible constraint in 'asm'
make: *** [Makefile:38: injector.o] Error 1
I haven't looked into the changes required for newer GCC versions, but the workaround for this is to compile with GCC 4.x. You should be able to use some equivalent of running sudo apt install -y gcc-4.7
and adding CC=gcc-4.7
to the top of the Makefile to get it built.
I come across similar issue when building other software in Arch Linux
, and hope my post can help you.
Thanks @NanXiao , that does indeed solve the issue. Do you know if this would have any adverse effects for older versions of GCC, or could it be added to master?
There is no gcc version that old available on Alpine - even on ancient debian/devuan oldstable the oldest Version is 4.8
However, adding the no-pie
flag to the Makefile like suggested by @NanXiao did the trick. Thanks!
Does this option break linking with earlier gcc versions? If not i'd suggest adding it to master.
@LeoAdamek @rostwald I am not the gcc expert, but from my humble opinion, I don't think it can bring some negative effects. According to manual:
-no-pie Don’t produce a position independent executable.
This option just take effect in link stage, and cause executable position independent. Personally, I think there is no other side-effect.
-no-pie
on gcc 6 worked for me as well. gcc 4.7 didn't build with -no-pie
:
gcc-4.7 injector.o -O3 -Wall -no-pie -l:libcapstone.a -o injector -pthread gcc-4.7: error: unrecognized command line option ‘-no-pie’
I simply compiled the injector as static which solved the problem of
/usr/bin/ld: injector.o: relocation R_X86_64_32S against undefined symbol `dummy_stack' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
cc injector.o -O3 -Wall -l:libcapstone.a -o injector -pthread -static
however --no-pie
also works on gcc7
@rupran's fork for the compiling error worked for me when using -no-pie in the Makefile.
I had to change python to python2 in sifter.py as referenced in #29, Arch uses python3 as python by default, but sandsifter appears to run in python2.
I'm getting a linker error when running
make
(Additionally I've tried adding-fPIC
to the compilation options however this hasn't solved the issue.)See below command output and versions. From commit dff63246fed84d90118441b8ba5b5d3bdd094427
make
output:cc --version
: cc (GCC) 7.1.1 20170630ld --version
: GNU ld (GNU Binutils) 2.28.0.20170506