LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-30-2014, 03:45 AM   #1
ramzi.kahil
LQ Newbie
 
Registered: Apr 2014
Posts: 28

Rep: Reputation: 1
exporting the kernels linked list


I want to make a proof of concept and for easier development I would like to export the linked list methods which are in "include/linux/list.h". But I get the error below if I remove the "static" from the functions declaration. Also the exported functions cannot be static. (I have for now tried to just export the "add_list" method.) So:

Why can the add_list method be non-static?
What can I do?

The error while compiling the kernel with a non-static "list_add" method:

Code:
init/do_mounts_initrd.o: In function `list_add':
/usr/src/linux-3.14.2/include/linux/list.h:63: multiple definitions of `list_add'
init/do_mounts.o:/usr/src/linux-3.14.2/include/linux/list.h:63: first defined here
make[1]: *** [init/mounts.o] Error 1
make: *** [init] Error 2

** My main goal is to export the symbols and then use kprobes to hook these functions via kernel modules, and develop my proof of concept without recompiling the kernel every time from scratch. Of curse after I am happy with what I did, I will recommend putting the code into the kernel and removing the export.
 
Old 06-01-2014, 03:12 AM   #2
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Quote:
/usr/src/linux-3.14.2/include/linux/list.h:63: multiple definitions of `list_add'
init/do_mounts.o:/usr/src/linux-3.14.2/include/linux/list.h:63: first defined here
init/do_mounts.o:/usr/src/linux-3.14.2/include/linux/list.h:63: first defined here
Well, I'm just a moron, but that seems to indicate your call to "list_add" didn't work because you have multiple definitions of the same class, which is fine if you're overloading a constructor, but apparently you went beyond what's wise.
If you want it to take a pointer, create a child class that takes pointers but give it another name.

Last edited by dijetlo; 06-01-2014 at 03:18 AM.
 
Old 06-01-2014, 03:52 AM   #3
ramzi.kahil
LQ Newbie
 
Registered: Apr 2014
Posts: 28

Original Poster
Rep: Reputation: 1
I think I may have not explained good enough what I did, because I didn't add any thing. The only thing I did was going to the file "include/linux/list.h" and remove the word "static" which appears in the definition of the function "add_list" and then re-compiled the kernel. The error above appeared.
 
Old 06-01-2014, 04:40 AM   #4
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
That's because if it isn't static, it's being redefined everywhere it appears in your code (not to mention in the header files)
It would seem a better option to create a child class for it, leave the original code alone, and work with that otherwise your looking at re-writing a significant portion of the linux kernel code.
 
Old 06-02-2014, 03:28 AM   #5
ramzi.kahil
LQ Newbie
 
Registered: Apr 2014
Posts: 28

Original Poster
Rep: Reputation: 1
OK, that helps a lot. But what do you mean by creating a child class? I don't know how this is done in C language.
 
Old 06-02-2014, 05:39 AM   #6
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
Quote:
But what do you mean by creating a child class?
Create a non-static variable that references the same structures as list add, though I'm not suggesting that will work. There is probably a reason it was designated a static variable to begin with, the most common being you can't manipulate it.
I'd start there.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked list C exvor Programming 14 06-22-2007 07:06 PM
Linked list manas_sem Programming 3 12-21-2006 02:53 AM
C linked list exvor Programming 4 04-28-2006 06:25 AM
linked list + c dilberim82 Programming 5 05-05-2005 12:48 AM
C++ linked list fun chens_83 Programming 2 08-04-2003 08:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 05:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration