xoreaxeaxeax / sandsifter

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

Doesn't compile on Solus OS #40

Open JPenuchot opened 7 years ago

JPenuchot commented 7 years ago

Installed capstone from the Git repo, tried to run make in the sandsifter folder and got these error messages :

cc -g2 -O3 -pipe -fPIC -Wformat -Wformat-security -fno-omit-frame-pointer -fexceptions -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -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’)
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’
injector.c: In function ‘main’:
injector.c:1508:5: warning: ‘pid’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (pid!=0) {
     ^
injector.c:1503:3: warning: ‘null_p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   munmap(null_p, PAGE_SIZE);
   ^~~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:38: injector.o] Error 1

Running make version 4.2.1 and CC version 6.4.0

JPenuchot commented 7 years ago

Doesn't compile on my Ubuntu Azure instance too

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

Running cc version 5.4.0

doug65536 commented 7 years ago

Doesn't compile on Ubuntu 17.04.

At first, make fails with:

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
Makefile:35: recipe for target 'injector' failed
make: *** [injector] Error 1

...so I did make CFLAGS=-fPIC and got the same output as JPenuchot's report.

gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2)

doug65536 commented 7 years ago

As a workaround, you can use this command to compile it with clang instead, worked on my Ubuntu 17.04:

make CC=clang

JPenuchot commented 7 years ago

Tried with make CC=clang, got this error (On Solus with clang 4.0.1)

clang -g2 -O3 -pipe -fPIC -Wformat -Wformat-security -fno-omit-frame-pointer -fexceptions -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -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: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:778:24: error: invalid operand for inline asm constraint 'i'
        __asm__ __volatile__ ("\
                              ^
2 warnings and 1 error generated.
make: *** [Makefile:38: injector.o] Error 1
lanodan commented 7 years ago

I think, it’s something in your CLFAGS.

$ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ CC=clang make
clang  -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: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},
                                                                                                 ^~~~
2 warnings generated.
clang  injector.o -O3 -Wall -l:libcapstone.a -o injector -pthread
$ make clean
rm *.o injector
$ CLFAGS="-g2 -O3 -pipe -fPIC -Wformat -Wformat-security -fno-omit-frame-pointer -fexceptions -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT" CC="clang" make
clang -g2 -O3 -pipe -fPIC -Wformat -Wformat-security -fno-omit-frame-pointer -fexceptions -D_FORTIFY_SOURCE=2 -fstack-protector --param ssp-buffer-size=32 -fasynchronous-unwind-tables -ftree-vectorize -feliminate-unused-debug-types -Wall -Wno-error -Wp,-D_REENTRANT -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: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:778:24: error: invalid operand for inline asm constraint 'i'
        __asm__ __volatile__ ("\
                              ^
2 warnings and 1 error generated.
make: *** [Makefile:38: injector.o] Error 1

I tried removing one option each time to see from which it could come from but I didn’t find it so it’s probably an error that comes with multiple options.

fuel-pcbox commented 7 years ago

Doesn't compile on latest Arch Linux either.


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
jotebe commented 7 years ago

@MoochMcGee there is an AUR package for sandsifter. https://aur.archlinux.org/packages/sandsifter-git/

for those not on arch, it compiles with -no-pie as an option.

lanodan commented 7 years ago

Looks like -no-pie is unsupported here.

$ make CC=gcc CFLAGS='-no-pie'
gcc -no-pie -c injector.c -o injector.o -Wall
gcc: error: unrecognized command line option ‘-no-pie’
make: *** [Makefile:38: injector.o] Error 1
$ make CC=clang CFLAGS='-no-pie'
clang -no-pie -c injector.c -o injector.o -Wall
clang-4.0: error: unknown argument: '-no-pie'
make: *** [Makefile:38: injector.o] Error 1
$ gcc --version
gcc (Gentoo Hardened 5.4.0-r3 p1.3, pie-0.6.5) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ clang --version
clang version 4.0.1 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

(I’m installing the 5.x branch of Clang/LLVM to see if I’ll be fixed)