LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   After adding a system call in the kernel, an error occured. (https://www.linuxquestions.org/questions/programming-9/after-adding-a-system-call-in-the-kernel-an-error-occured-747665/)

corone 08-14-2009 09:09 PM

After adding a system call in the kernel, an error occured.
 
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:47 AM

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

Thank you.


All times are GMT -5. The time now is 04:53 AM.