Project

General

Profile

Bug #304

gcc6: "error: code model kernel does not support PIC mode"

Added by Linus Lüssing over 3 years ago. Updated over 3 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
10/31/2016
Due date:
% Done:

0%

Estimated time:

Description

On a Debian Sid compiling for a 4.9-rc3 kernel with gcc 6.2.0-10, I curently get the following error:

root@Linus-Debian:/mnt/batman-adv-t_x# make
/mnt/batman-adv-t_x/gen-compat-autoconf.sh /mnt/batman-adv-t_x/compat-autoconf.h
mkdir -p /mnt/batman-adv-t_x/build/net/batman-adv/
compat-patches/replacements.sh
touch /mnt/batman-adv-t_x/build/net/batman-adv/.compat-prepared
make -C /lib/modules/4.9.0-rc3+/build M=/mnt/batman-adv-t_x PWD=/mnt/batman-adv-t_x REVISION=2016.4 CONFIG_BATMAN_ADV=m CONFIG_BATMAN_ADV_DEBUG=n CONFIG_BATMAN_ADV_DEBUGFS=y CONFIG_BATMAN_ADV_BLA=y CONFIG_BATMAN_ADV_DAT=y CONFIG_BATMAN_ADV_NC=n CONFIG_BATMAN_ADV_MCAST=y CONFIG_BATMAN_ADV_BATMAN_V=n INSTALL_MOD_DIR=updates/    modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.0-rc3+'
cat: -: No such file or directory
  CC [M]  /mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o
/mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.c:1:0: error: code model kernel does not support PIC mode
 /*

scripts/Makefile.build:290: recipe for target '/mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o' failed
make[3]: *** [/mnt/batman-adv-t_x/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o] Error 1
scripts/Makefile.build:475: recipe for target '/mnt/batman-adv-t_x/build/net/batman-adv' failed
make[2]: *** [/mnt/batman-adv-t_x/build/net/batman-adv] Error 2
Makefile:1482: recipe for target '_module_/mnt/batman-adv-t_x' failed
make[1]: *** [_module_/mnt/batman-adv-t_x] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-rc3+'
Makefile:89: recipe for target 'all' failed
make: *** [all] Error 2

It seems to have something to do with PIE hardening which got enabled by default in gcc6 last week in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=835148

Compiling with '$ make EXTRA_CFLAGS="-fno-pie"' helps.

So my question is, whether this flag should be added to the batman-adv out-of-tree Makefile.

Some comments seem to suggest, that PIE does not work for kernels / kernel modules by design. (I have not looked at what PIE hardening actually is, so I have no clue yet whether disabling is the right choice)

History

#1

Updated by Linus Lüssing over 3 years ago

  • Description updated (diff)
#2

Updated by Sven Eckelmann over 3 years ago

  • Status changed from New to Rejected
#3

Updated by Sven Eckelmann over 3 years ago

Seems that Ben gave up and included following patch in his kernel tree: https://anonscm.debian.org/cgit/kernel/linux.git/tree/debian/patches/bugfix/all/kbuild-add-fno-pie.patch?id=25e532ff97db2fb2990e8b6e0fb74a9313255656

But it seems not to be enough. At least when I read following correctly: https://www.spinics.net/lists/linux-kbuild/msg13620.html

So I would still say that it is not a flag we should include but which should be included in the kernel. And hopefully in a way which doesn't break older GCC versions (which simply including this flag by us will do).

Also available in: Atom PDF