how to identify "Unknown Symbol"

This is a discussion on how to identify "Unknown Symbol" within the Linux Programming forums, part of the Platform Specific Boards category; I may come to regret my choice to write a webcam driver Anyway, now I am having this problem: insmod: ...

  1. #1
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300

    how to identify "Unknown Symbol"

    I may come to regret my choice to write a webcam driver

    Anyway, now I am having this problem:
    insmod: error inserting './usbgetinfo.ko': -1 Unknown symbol in module

    I understand that
    Quote Originally Posted by http://www.linuxchix.org/content/courses/kernel_hacking/lesson8
    What this is saying is that the kernel is not allowing modules to see that variable. When the module loads, it has to resolve all it's external references, like function names or variable names. If it can't find all of it's unresolved names in the list of symbols that the kernel exports, then the module can't write to that variable or call that function. The variable my_variable has space allocated for it somewhere in the kernel, but the module can't figure out where.

    To fix this, we're going to add my_variable to the list of symbols that the kernel exports...
    However, what if I don't know which variable is causing the problem (the code is simple and straightforward, <70 lines, etc)...is there a way to identify the offending symbol?? From the sound of it, this could almost be just a missing header...
    Last edited by MK27; 05-08-2009 at 10:07 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    Try 'objdump -T mymodule.ko' to see all the symbols it's trying to bring in... Process of elimination?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by brewbuck View Post
    Try 'objdump -T mymodule.ko' to see all the symbols it's trying to bring in... Process of elimination?
    Not familiar with objdump but I would guess you meant -t, not -T. Is it safe to assume that I should confine my search to *UND* symbols?

    Also, this does not list all the variables referenced, which in that quote from the OP, the error is produced by inserting a variable into the printk source, recompiling the kernel, and trying to reference it in the module code. In which case I imagine "printk" would be in the symbol list, but nothing about the variable. So this list doesn't seem any better than just looking at the code itself...
    Last edited by MK27; 05-08-2009 at 10:33 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,235
    Quote Originally Posted by MK27 View Post
    Not familiar with objdump but I would guess you meant -t, not -T. Is it safe to assume that I should confine my search to *UND* symbols?
    It was a typo, I actually meant "-tT" to get both (is a ".ko" like a shared library or like an object file? I can't remember -- "-T" doesn't apply to object files).

    Yes, you're concerned with the symbols marked *UND*. The symbol sections might be informative too. I have not looked at a kernel module in a while.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by brewbuck View Post
    Yes, you're concerned with the symbols marked *UND*. The symbol sections might be informative too. I have not looked at a kernel module in a while.
    No it's "not a dynamic object".

    Not sure if this will help other than to round out my knowledge of what a symbol is. Which is helpful.

    Problem is, this is already barebones. There's not much extraneous stuff I can take out one piece at a time and still expect it to compile or load. Sigh.

    So what do you mean by "symbol sections" (--full-contents?)?
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    tjb
    tjb is offline
    Registered User
    Join Date
    Jan 2009
    Posts
    31
    You can find currently defined symbols in the kernel by reading /proc/kallsyms. You might be able to match up the two (the contents of the objdump output) with a little perl or the shell.

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by tjb View Post
    You can find currently defined symbols in the kernel by reading /proc/kallsyms. You might be able to match up the two (the contents of the objdump output) with a little perl or the shell.
    Tee hee. The problem turned out to be that I forgot to include
    Code:
    MODULE_LICENSE("GPL");
    which meant the kernel was not willing to export anything at all...

    But thanks for this tip, it may eventually come in handy.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help!!!! How to Identify Image block or image separator in GIF 89a
    By kapil1089thekin in forum C Programming
    Replies: 1
    Last Post: 05-06-2008, 10:53 AM
  2. How to identify that user has terminated the program
    By abhijitbanerjee in forum C Programming
    Replies: 2
    Last Post: 07-11-2007, 04:43 PM
  3. Replies: 6
    Last Post: 06-27-2006, 08:35 AM
  4. how to identify which button is pushed
    By gaurav07 in forum Windows Programming
    Replies: 1
    Last Post: 06-23-2005, 10:44 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21