ikwzm / FPGA-SoC-Linux

FPGA+SoC+Linux+Device Tree Overlay+FPGA Manager U-Boot&Linux Kernel&Debian11 Images (for Xilinx:Zynq-Zybo:PYNQ-Z1 Altera:de0-nano-soc:de10-nano)
158 stars 57 forks source link

Unknown symbol _GLOBAL_OFFSET_TABLE_ #1

Closed FPtje closed 7 years ago

FPtje commented 7 years ago

On the following Linux distribution:

Linux de0-nano-soc 4.8.10 #1-NixOS SMP Mon Nov 21 09:11:59 UTC 2016 armv7l GNU/Linux

I'm trying to manually compile the kernel modules using the following script:

cd drivers

for dir in dtbocfg fpgacfg fclkcfg udmabuf zptty fpga-bridge; do
  cd $dir
  make CFLAGS_MODULE=-fno-pic KERNEL_SRC_DIR=${kernel.dev}/lib/modules/${kernel.version}/build all
  cd ..
done

The reason for not using drivers/Makefile is because it hard codes KERNEL_SRC_DIR.

The modules compile, but as soon as I try to modprobe them, the following error shows up in dmesg:

udmabuf: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)

The above error is for udmabuf, but it happens to every single module. I've Googled the issue and found about a dozen different websites saying that one should set CFLAGS_MODULE=-fno-pic in the Makefile or make command. I've done that (see the compile script posted above), but it has no effect. The error still happens.

I'm not well versed in compiling kernel modules, so I'm stuck here. Any idea what I could be doing wrong?

FPtje commented 7 years ago

Ah, turns out it's NixOS forcibly ignoring CFLAGS_MODULE=-fno-pic because of kernel hardening. Setting the following in the derivation (= definition of the package) resolved this issue:

hardeningDisable = [ "pic" ];