LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 08-17-2009, 05:45 AM   #1
corone
Member
 
Registered: Jul 2009
Posts: 46

Rep: Reputation: 1
I added a new system call in the kernel, but a problem about _syscallN() macros


Hi,

I added a temporary system call in the kernel for a test,
But when a program calls the system call, an error occurs.

When I compiled the following program, an error occured.
# vi testcall_test.c
Code:
#include <linux/unistd.h>

_syscall0(int,testcall);

int main(void)
{
testcall();
return 0;
}
The error messages are...
# gcc -I /usr/src/linux-2.6.14.6/include testcall_test.c -o testcall_test
Code:
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/ccCGdJnX.o
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
But when the program calls the system call as the number,
it works properly.
WHAT IS WRONG WITH THE ABOVE?
And how can I solve the problem?
Please, help me.
# vi testcall_test.c
Code:
#include <linux/unistd.h>

// _syscall0(int,testcall);

int main(void)
{
// testcall();

syscall(294);


return 0;
}
(or)
# vi testcall_test.c
Code:
#include <linux/unistd.h>

// _syscall0(int,testcall);

int main(void)
{
// testcall();

syscall(__NR_testcall);


return 0;
}
# gcc -I /usr/src/linux-2.6.14.6/include testcall_test.c -o testcall_test
#

# ls
testcall_test testcall_test.c
# ./testcall_test
testcall success!
#

I heard that the _syscallN() macros are gone in 2.6.20 and later.
But the current kernel version is 2.6.14.6

Last edited by corone; 08-26-2009 at 03:46 AM.
 
Old 08-26-2009, 04:42 AM   #2
corone
Member
 
Registered: Jul 2009
Posts: 46

Original Poster
Rep: Reputation: 1
I should have added "#include <error.h>"

Thank you.

Last edited by corone; 04-09-2012 at 01:32 AM.
 
Old 08-26-2009, 05:22 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,457
Blog Entries: 54

Rep: Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897Reputation: 2897
Well done fixing it & updating your own question with the fix!
 
  


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
After adding a system call in the kernel, an error occured. corone Programming 1 08-26-2009 04:47 AM
Try to add a system call but compilation error occured ahm_irf Linux - Newbie 0 04-28-2007 01:27 AM


All times are GMT -5. The time now is 07:00 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration