2

Trying to build the EtherCAT master driver (realtime I/O driver) on a RT Linux (SL6.3) I keep bumping into a missing symbol issue when building the EtherCAT kernel modules:

# make modules
make -C "/usr/src/kernels/3.8.13-rt27.40.el6rt.x86_64" M="/root/etherlabmaster-code-08aa7305b9baba37bdd9eb4d8c2a8762aa56a7e2" modules
make[1]: Entering directory `/usr/src/kernels/3.8.13-rt27.40.el6rt.x86_64'
  Building modules, stage 2.
  MODPOST 4 modules
WARNING: "__fentry__" [/root/etherlabmaster-code-08aa7305b9baba37bdd9eb4d8c2a8762aa56a7e2/master/ec_master.ko] undefined!
WARNING: "__fentry__" [/root/etherlabmaster-code-08aa7305b9baba37bdd9eb4d8c2a8762aa56a7e2/examples/mini/ec_mini.ko] undefined!
WARNING: "__fentry__" [/root/etherlabmaster-code-08aa7305b9baba37bdd9eb4d8c2a8762aa56a7e2/devices/ec_generic.ko] undefined!
WARNING: "__fentry__" [/root/etherlabmaster-code-08aa7305b9baba37bdd9eb4d8c2a8762aa56a7e2/devices/e1000e/ec_e1000e.ko] undefined!
make[1]: Leaving directory `/usr/src/kernels/3.8.13-rt27.40.el6rt.x86_64'

# grep -Hin "fentry" /boot/config-`uname -r`
/boot/config-3.8.13-rt27.40.el6rt.x86_64:4797:CONFIG_HAVE_FENTRY=y

# strings /boot/System.map-3.8.13-rt27.40.el6rt.x86_64 | grep -i "fentry"
-- nothing --
#

I'm using GCC v 4.9.1, as you can see, the kernel config file does contain an entry related to 'fentry' and is enabled.

Weird thing is that I would expect the System.map to contain the __fentry__ symbol declared in there, but it isn't!?

I've tried building the EtherCAT driver against the kernel 3.10-rt & 3.14-rt, same issue, it's complaining about about the __fentry__ symbol missing.

If I go ahead and launch the EtherCAT service, I get the following:

# service ethercat start
Starting EtherCAT master 1.5.2 FATAL: Error inserting ec_master (/lib/modules/3.8.13-rt27.40.el6rt.x86_64/ethercat/master/ec_master.ko): Unknown symbol in module, or unknown parameter (see dmesg)
 failed

# dmesg | tail
...
ec_master: Unknown symbol __fentry__ (err 0)
fduff
  • 4,925
  • 4
  • 35
  • 39
  • be careful with using `strings` on binaries ... if the binary is a file type that it recognises (e.g. ELF) then it will only look in certain sections (to quote from my man page `only those sequences that are in loadable, initialized data sections`) ... use `strings --all file` to make sure you get them all, on any type of file (I use `strings - file` as that is what I grew up with :-) – Murray Jensen Feb 04 '16 at 00:26
  • @MurrayJensen, thanks for the info, using `strings --all` still results with the same output. – fduff Feb 04 '16 at 06:23
  • 1
    look in `arch/x86/kernel/entry_64.S` for some clues ... `__fentry__` is defined in that file, but only if `CC_USING_FENTRY` is defined ... this in turn is only defined if `CONFIG_FUNCTION_TRACER` and `CONFIG_HAVE_FENTRY` are defined. I'm guessing that somehow you've got a mismatch between the kernel config that is running and the config you are using to build the modules ... – Murray Jensen Feb 04 '16 at 12:06

1 Answers1

2

I got in touch with the CERN IT department regarding their pre-built kernel package and to confirm my suspicions, they've built the kernel-rt package (rpm) based on GCC 4.4.7-x.

As I find out, in GCC versions prior to 4.6, it uses the __mcount__ symbol for function tracing when required. This has been replaced with __fentry__ in GCC 4.6 and above.


Resolution: In order to fix the missing symbol I had, I had to recompile the Linux kernel from source using a more recent version of the compiler (4.9.1 in this case) and then I got to build and link the kernel module no problem using the same compiler.

fduff
  • 4,925
  • 4
  • 35
  • 39