Welcome! Log In Create A New Profile

Advanced

Kernel modules and -fno-pic

Posted by renojim 
Kernel modules and -fno-pic
October 25, 2021 07:10PM
Has anyone that builds loadable kernel modules run into the requirement for a -fno-pic compiler flag? I have a couple of lkms I created a few years ago and when I went to modify one I suddenly get "wx_lkm: Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)" when I make and insmod it. I don't believe I've changed anything and I never needed the flag before, but searching for the error led me to -fno-pic. My Makefile was very simple:
obj-m+=wx_lkm.o

all:
        make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean
I had to change it to:
obj-m+=wx_lkm.o

all:
        make -C /lib/modules/$(shell uname -r)/build/ EXTRA_CFLAGS=-fno-pic M=$(PWD) modules
clean:
        make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean

It bugs me more than anything since it works with the compiler flag. I'm just wondering what I might have screwed up to make it suddenly require the flag. I've been using the same kernel that's long overdue for an update since I started developing the lkms.
Re: Kernel modules and -fno-pic
October 25, 2021 07:39PM
renojim,

> It bugs me more than anything since it works with
> the compiler flag. I'm just wondering what I
> might have screwed up to make it suddenly require
> the flag. I've been using the same kernel that's
> long overdue for an update since I started
> developing the lkms.

Is it with the latest kernel? there might have been changes in the way the kernel exported symbols to modules, that could have affected it.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Re: Kernel modules and -fno-pic
October 25, 2021 07:52PM
No, that's the thing. As I said, I'm long overdue for an update on my Dockstar (still playing with the M300) and I'm on 4.8.3-kirkwood-tld-1. It's weird since I don't think I've changed anything as far as the kernel is concerned. It just bugs me that it's suddenly necessary. I should just go ahead and get this thing up to date, but I haven't fully recovered from my hard drive crash. That may or may not have something to do with this. Maybe I installed something to the hard drive that I haven't recovered that's involved with building kernel modules? It doesn't seem likely since I don't use the hard drive for system files.
Re: Kernel modules and -fno-pic
October 26, 2021 03:14PM
I may have figured out what changed. My original lkm was built with gcc v4.9.2 and the one that requires the flag uses gcc v6.3.0. I don't know if that points to something wrong with my gcc install or if some defaults changed, but at least I know how to get around the error.
Re: Kernel modules and -fno-pic
October 26, 2021 04:35PM
renojim,

> I may have figured out what changed. My original
> lkm was built with gcc v4.9.2 and the one that
> requires the flag uses gcc v6.3.0. I don't know
> if that points to something wrong with my gcc
> install or if some defaults changed, but at least
> I know how to get around the error.


Sounds like your Debian version was updated from wheezy to stretch. IIRC, ggc was 4.9.x in wheezy, and 6.3x in stretch.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: