I am trying to use a grsecurity gcc plugin that I found on their unofficial linux kernel source tree (the respectre_plugin/ one).
My GCC version is 4.7, I modified scripts/gcc-plugins/Makefile to make it compile the plugin, and I built it with the root Makefile using make gcc-plugins, that shows no error.
Then, when I try to compile a C file that has a Spectre-like flaw, I got the following build error:
file.c:36:31: error: array_index_mask_nospec is not defined
This function is defined in respectre_plugin/respectre_plugin.c, and I have no idea why I've got this strange build error, if anyone knows about it...
My build invocation is the following:
gcc -Wall -Wextra -std=c99 -fplugin=/path/to/respectre_plugin.so -c file.c -o file.o
Thanks for any help !
Related
I'm running a Debian (Buster) container and my goal is to compile a small program I wrote which relies on libgit2. First, I was installing libgit2 via the libgit2-dev package and my Makefile had the following:
gcc -O2 -fpic -shared -I /usr/local/include -lgit2 -o output.so my_app.c
However, I'd rather have a "cleaner" environment and install libgit2 via the libgit-27 which, AFAIK, only installs the shared object binary instead of also including the development files like libgit2-dev does.
Using find I can find where the .so file is installed into:
$ find / -name "*git2*" -print 2>/dev/null
/usr/lib/x86_64-linux-gnu/libgit2.so.0.27.7
/usr/lib/x86_64-linux-gnu/libgit2.so.27
/usr/share/doc/libgit2-27
/var/lib/dpkg/info/libgit2-27:amd64.list
/var/lib/dpkg/info/libgit2-27:amd64.symbols
/var/lib/dpkg/info/libgit2-27:amd64.md5sums
/var/lib/dpkg/info/libgit2-27:amd64.shlibs
/var/lib/dpkg/info/libgit2-27:amd64.triggers
and I've been trying several combinations of linking this .so with gcc like:
gcc -O2 -fpic -shared -L /usr/lib/x86_64-linux-gnu/ -libgit2.so.27 -o output.so my_app.c
but so far I always get the following error:
my_app.c:1:10: fatal error: git2.h: No such file or directory
#include <git2.h>
^~~~~~~~
compilation terminated.
I understand this is a glaring lack of knowledge on how C compilation works. My two questions are:
Is it possible to compile my program by just relying on the libgit2-27 Debian Buster package instead of libgit2-dev? If not, why?
If yes, an example and explanation would be appreciated!
I'm running on OSX and trying to compile following c code to webAssembly:
void test(){
//do stuff
}
I've looked at this example and tried running the following commands:
clang -emit-llvm --target=wasm32 -Oz test.c -c -o test.bc
llc -asm-verbose=false -o test.s test.bc
First command works fine and clang generates the .bc file, but when I try to run the second command I get:llc: : error: unable to get target for 'wasm32', see --version and --triple.
Any help would be appreciated.
It looks like your version of llvm was not compiled with support for the WebAssembly backend. This backend is still experimental so you need to enable it at cmake time with:
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly
I am trying to recompile binutils and GCC as a cross-compiler for m68k architecture. I am following these instructions:
http://darkdust.net/writings/megadrive/crosscompiler
However, the process keeps failing on one part or another. I have tried with binutils 2.16.1 and gcc 3.4.6, binutils 2.15 and gcc 3.4.2 and binutils 2.15 and gcc 3.4.6.
This last attempt fails when running "make" on gcc, after making and installing binutils. It gives the following error:
gcc -g -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-
prototypes -Wmissing-prototypes -pedantic -Wno-long-long -DHAVE_CONFIG_H
-I. -I. -I../../gcc-3.4.2/gcc -I../../gcc-3.4.2/gcc/. -I../../gcc-
3.4.2/gcc/../include \
-DTARGET_MACHINE=\"m68k-coff\" \
-c ../../gcc-3.4.2/gcc/collect2.c -o collect2.o
In file included from /usr/include/fcntl.h:289:0,
from ../../gcc-3.4.2/gcc/system.h:214,
from ../../gcc-3.4.2/gcc/collect2.c:30:
In function ‘open’,
inlined from ‘collect_execute’ at ../../gcc-3.4.2/gcc/collect2.c:1535:20:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to
‘__open_missing_mode’ declared with attribute error: open with O_CREAT or
O_TMPFILE in second argument needs 3 arguments
__open_missing_mode ();
^
Makefile:1364: recipe for target 'collect2.o' failed
make[1]: *** [collect2.o] Error 1
make[1]: Leaving directory '/home/gabriel/src/gcc-build/gcc'
Makefile:23339: recipe for target 'all-gcc' failed
make: *** [all-gcc] Error 2
I don't expect to fix this error, but does anyone know of a combination of binutils and gcc release that work? Should I be using a certain version of gcc to recompile gcc successfuly?
Thanks for any insight you may have on this!
EDIT:
My linux has GCC 5.4.0 so I just downloaded the 5.4.0 source to try and rebuild that for m68k cross-compiling. I now get the following error when running "make" on the gcc source:
*** Configuration m68k-unkown-coff not supported
What could be the cause of this? Is it because I need an older version of GCC? (the binutils version i'm using definately supports the m68k target). The tutorial I'm using always defines "--target=m68k-coff", should that instead be "--target=m68k-unkown-coff"?
EDIT 2:
So I tried compiling for m68k-elf but now I get this error:
checking for m68k-elf-gcc... /home/gabriel/src/gcc-build/./gcc/xgcc -B/home/gabriel/src/gcc-build/./gcc/ -B/opt/m68k/m68k-elf/bin/ -B/opt/m68k/m68k-elf/lib/ -isystem /opt/m68k/m68k-elf/include -isystem /opt/m68k/m68k-elf/sys-include
checking for suffix of object files... configure: error: in `/home/gabriel/src/gcc-build/m68k-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile
I ran download_prerequisites before building so it should not be a problem with the MPC library. Any idea how to move on? I need assembler only so I don't mind what the format of the object files is. Thanks!
I used to do pretty much what you are doing right now.
My advice is to use crosstool-ng (http://crosstool-ng.github.io), as it does pretty much everything in an automated manner.
If you are studying m68k assembly, I used to host a modified version of gcc-explorer by Matt Godbolt (https://godbolt.org/). You can find a runnable docker image here (https://hub.docker.com/r/esantoro/acso-explorer/) and some more details here (https://znpy.wordpress.com/2017/05/08/decommisioning-acso-explorer-santoro-tk/)
Hope it helps,
znpy
you can build most versions with a current Linux. To install the prerequisites have a look at https://github.com/bebbo/amiga-gcc
unpack the gcc archive, e.g. to /opt/cross/gcc-6.5.0
create a separate build folder, e.g. /opt/cross/xcc-6.5.0 - never build inside gcc's source folder!
create the prefix folder, that's where binaries are installed to, e.g. /opt/cross/gcc65
ensure that these folders exist and are writable, then
configure from within that build folder using an absolute path for configure
cd /opt/cross/xcc-6.5.0/
/opt/cross/gcc-6.5.0/configure --target=m68k-elf --program-prefix=m68k-elf- --enable-languages=c,c++ --prefix=/opt/cross/gcc65 --disable-libssp --disable-nls --disable-multilib
make all-gcc
make install-gcc
I'm also running the compiler explorer for 68k gccs at https://franke.ms/cex/
I would like to be able to use the sqlite3 functionality with C, I recently downloaded the sqlite3 amalgamation from the SQLite website and compiled this to get sqlite3.so and hence included this in my project. I have included what I believe to be the necessary libraries to compile the code however I always get the same error. The linker appears to be looking in the wrong folder for -lsqlite3 and I cant find this specified path anywhere in any of the project properties and it also does not appear to be a valid location on my PC!
Below is the output when I try to compile the code. If I am stupidly missing anything required for any help please let me know, bit of a beginner when using eclipse for C.
16:21:03 **** Build of configuration Debug for project SQLite ****
make all
Building file: ../main.c
Invoking: Cross GCC Compiler
arm-linux-gnueabihf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.c"
Finished building: ../main.c
Building target: SQLite
Invoking: Cross GCC Linker
arm-linux-gnueabihf-gcc -L/root/workspacecpp/SQLite/ -o "SQLite" ./main.o -lsqlite3.so
/home/development/raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lsqlite3.so
collect2: error: ld returned 1 exit status
make: *** [SQLite] Error 1
You are cross-compiling, so you need to place the ARM[*] version of libsqlite3.so in a place where the cross compiler will look for it. This is likely somewhere in or below /home/development/raspberrypi/tools/arm-bcm2708/. See your cross-compiler's documentation.
[*] Of course you used your cross-compiler to create an ARM version of libsqlite3.so :-)
I'm getting a weird error at C header files when linting with linter-gcc at atom. The error is this:
cc1: error: output filename specified twice
This error is generated by: gcc 5.2.1, ubuntu 15.10.
The same error is generated by gcc 5.3.0 at my linux arch system 4.5.0-1 ARCH.
When I checked with clang 3.7.1 all went fine.
Note that I can compile the program normally. The error is generated only inside atom editor or when I run this command at my terminal:
/usr/bin/gcc -Wall -fsyntax-only -c -fmax-errors=0 /path/to/headerfile.h
But when I run:
clang -Wall -fsyntax-only -c /path/to/headerfile.h
Nothing was printed.
EDIT: It seems that it's not linter-gcc's bug as I contacted the package's creator via his github account.
So my question is: What's is the source of this error? Is there a way to solve it? What's causing it?