LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   I added a system call in the Linux kernel, but a problem occured. (https://www.linuxquestions.org/questions/linux-kernel-70/i-added-a-system-call-in-the-linux-kernel-but-a-problem-occured-748081/)

corone 08-17-2009 05:45 AM

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

corone 08-26-2009 04:42 AM

I should have added "#include <error.h>"

Thank you.

unSpawn 08-26-2009 05:22 AM

Well done fixing it & updating your own question with the fix!


All times are GMT -5. The time now is 09:02 PM.