Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, I'm trying to compile several files to build a kernel module. Here is the code of the Makefile : obj-m := gntringevt.o gntringevt-y := gntring3.o evtchn_functions.o all : make ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2014
    Posts
    2

    Error while compiling a multiple files module : no symbol in a .o file


    Hello,

    I'm trying to compile several files to build a kernel module. Here is the code of the Makefile :

    obj-m := gntringevt.o
    gntringevt-y := gntring3.o evtchn_functions.o

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

    I already compiled single-file modules and it went ok, but here I get error messages such as :
    WARNING: "evtchn_unbind_from_user" [/home/fremals/xencomm/CommXen/gntringevt.ko] undefined!

    This undefined function is in evtchn_functions.c. I ran "nm" on the files gntring3.o and evtchn_functions.o. For gntring3.o, all function and variable symbols are there, but there are no symbols in evtchn_functions.c (that explains why the module can't find the functions used in gntring3.o).

    Here is the code of evtchn_unbind_from_user :
    Code:
    static void evtchn_unbind_from_user(struct per_user_data *u, int port, unsigned long *port_array)
    {
    	int irq = irq_from_evtchn(port);
    
    	unbind_from_irqhandler(irq, (void *)(unsigned long)port);
    
    	set_port_user(port, NULL, port_array);
    }
    Do you know where is my mistake ?

    Best regards

  2. #2
    Just Joined!
    Join Date
    Jan 2014
    Posts
    8
    The function is defined as static, therefore can't be used in other files

  3. #3
    Linux Guru
    Join Date
    Dec 2013
    Posts
    1,577
    More specifically, a statically declared function in C is only visible to it's translation unit - which is the object file it's compiled into. If you want to call it from another translation unit then don't declare it static.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Mar 2014
    Posts
    2
    Thank you for the informations, I removed the 'static' keyword and it worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •