0

I have built a custom kernel and I am able to do my system call,but now I want to change the logic in the .o file reference in the Makefile

obj-y += sys_calls_test.o

the sys_calls_test.o has

#include<linux/linkage.h>
asmlinakge long sys_hello(void)
{
printk("hello");
}

I modified it to

#include<linux/linkage.h>
asmlinakge long sys_hello(void)
{
printk("Testing this block");
}

When I try to recompile my sys_calls_test.c file the changes are not showing up

I used

gcc file_name.c -o testing_comp
./testing_comp

My sys_calls_test.c file that I have referenced in the kernel's makefile.

#include <stdio.h>
#include <linux/unistd.h>
#include <sys/syscall.h>

#define sys_hello 349

int main(void)
{
    int c = syscall(sys_hello, a, b);
    printf("System call returned %d\n", c);
    return 0;
}

I am still seeing "Hello there" and not "Testing this block"

Can someone point me if I have to recompile the linux source and why my changes are not showing up. Should I need to use the make command and rebuild the entire kernel source to show this change since I have changed the .o reference in the Kernel's Makefile

Thanks a lot

1 Answer 1

1

.o files are compiled directly into the output executable, so if you want your changes to appear you will have to recompile the kernel that depends on it.

You are thinking of dynamically linked/shared-object files, which in linux are generally saved out as .so files.

Please refer to this stackoverflow question for more details:

https://stackoverflow.com/questions/9688200/difference-between-shared-objects-so-static-libraries-a-and-dlls-so

1
  • So is this the reason people prefer modular programming against system programming ?
    – rao
    Oct 25, 2013 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .