1

I am using buildroot to build tun.c kernel module (tun/tap kernel module) for Linux kernel 2.6.33. I customised the buildroot for the appropriate architecture and ELF flags. When I compile user mode program like:

int main()
{
     printf("hello world\n");
     return 0;
}

by issuing the command:

make ARCH=mips CROSS_COMPILE=my_cross_compiler_path

One of the readelf output of the binary is flags 0x50001007, noreorder, pic, cpic,o32, mips32

I did the same for cross compiling tun.c and I got tun.ko. This time I got different ELF flags - I got 0x50001001, noreorder, o32, mips32

How do I cross compile tun.c with the suit ELF flags?

ssdfdsfsd
  • 21
  • 3
  • User program and kernel module needn't to have same ELF flags - they don't directly call functions from each other. – Tsyvarev Sep 29 '16 at 20:25
  • 2
    I have the feeling you ought to back up and tell us what you're actually trying to achieve. Why is it important that your kernel module and your userspace programs have the same flags? – David Sep 29 '16 at 20:34
  • @David Because the differential ELF flags are affected the running of the executable. When I compiled the userspace binary I got ELF flags of 0x50001007 noreorder, pic, cpic, o32,mips32 and it runned without a problem. When I compiled the kernelspace binary I got ELF flags of noreorder,o32,mips32 (without the PIC) and it doesnt able to get loaded into the OS. – ssdfdsfsd Oct 05 '16 at 07:28
  • There are various reasons why a kernel module won't load into the OS, and I doubt that the proper ELF headers are a part of your problem. (Since kernel modules are compiled against a specific source tree by the source tree makefile, they're probably being compiled correctly.) Try re-asking your question more generally. (E.g. Why won't my kernel module load?) – David Oct 05 '16 at 17:33

0 Answers0