xoreaxeaxeax / sandsifter

The x86 processor fuzzer
BSD 3-Clause "New" or "Revised" License
4.91k stars 350 forks source link

make fail - injector #38

Open ds2k5 opened 7 years ago

ds2k5 commented 7 years ago

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

martin3000 commented 7 years ago

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

greg5678 commented 6 years ago

@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.

genewitch commented 6 years ago

Literally the only thing you are adding is

-no-pie

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

greg5678 commented 6 years ago

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'
mynamewastaken commented 6 years ago

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

pdelteil commented 6 years ago

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

Zibri commented 5 years ago

just do: make CFLAGS=-no-pie