sandsifter icon indicating copy to clipboard operation
sandsifter copied to clipboard

make fail - injector

Open ds2k5 opened this issue 7 years ago • 7 comments

Hi, using Manjaro Linux but the build fail.

python-capstone python2-capstone Python 2.7.13 Python 3.6.2

What did i wrong ?

$ make cc -c injector.c -o injector.o -Wall 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') cc injector.o -O3 -Wall -l:libcapstone.a -o injector -pthread /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 make: *** [Makefile:35: injector] Error 1

ds2k5 avatar Aug 27 '17 05:08 ds2k5

Change the Makefile to:

all: injector

injector: injector.o $(CC) $(CFLAGS) $< -O3 -Wall -no-pie -l:libcapstone.a -o $@ -pthread

%.o: %.c $(CC) $(CFLAGS) -c $< -o $@ -Wall

clean: rm *.o injector

martin3000 avatar Aug 31 '17 13:08 martin3000

@martin3000 I edited the Makefile to state:

all: injector


injector: injector.o
$(CC) $(CFLAGS) $< -O3 -Wall -no-pie -l:libcapstone.a -o $@ -pthread


%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@ -Wall


clean:
rm *.o injector

but it gave me this error: Makefile:40: *** missing separator. Stop.

greg5678 avatar Nov 05 '17 17:11 greg5678

Literally the only thing you are adding is

-no-pie

in the injector: injector.o section. Worked for me, thanks very much, @martin3000 !

genewitch avatar Dec 01 '17 04:12 genewitch

OK. I added -no-pie to the injector.o section in the make file but it said that -no-pie wasn't an command line option.

make -j8
cc  -c injector.c -o injector.o -Wall
injector.c:321:2: warning: excess elements in array initializer [enabled by default]
  .start={.bytes={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, .len=0},
  ^
injector.c:321:2: warning: (near initialization for 'total_range.start.bytes') [enabled by default]
injector.c:322:2: warning: excess elements in array initializer [enabled by default]
  .end={.bytes={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, .len=0},
  ^
injector.c:322:2: warning: (near initialization for 'total_range.end.bytes') [enabled by default]
cc  injector.o -O3 -Wall -no-pie -l:libcapstone.a -o injector -pthread
cc: error: unrecognized command line option '-no-pie'

greg5678 avatar Jan 04 '18 17:01 greg5678

On Fedora 27 I installed capstone and capstone-devel and had to add -L/usr/lib64 to the Makefile to get it to compile.

mynamewastaken avatar Jan 24 '18 05:01 mynamewastaken

Same error. Solved using the 'no-pie' flag.

pdelteil avatar Apr 14 '18 04:04 pdelteil

just do: make CFLAGS=-no-pie

Zibri avatar Feb 05 '19 17:02 Zibri