Dumping symbolic table of kernel image itself

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Dumping symbolic table of kernel image itself

Post by bluemoon »

I'm currently working on loading elf modules and I want to let the modules to access function within kernel binary.
However, I figured out that kernel.bss is overlapping with the elf section & headers, which contain the symbolic table, got wiped out upon initializations.

My current workaround is to force the bss to shift behind the headers:

Code: Select all

    .data ALIGN(4096) : {
        *(.data*)
        *(.gnu.linkonce.d*)
        data_end = .;
    }
    .= data_end + 10240;
    .bss ALIGN(4096) : {
        sbss = .;
        *(COMMON*)
        *(.bss*)
        *(.gnu.linkonce.b*)
        ebss = .;
    }
My question, is there any better way instead of putting the ugly 10240 constant there? Can I tell the linker to put bss after the (address start + file_length)?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Dumping symbolic table of kernel image itself

Post by bluemoon »

I have no trouble to load module to random address and do relocation,

My next step is to export kernel symbols to module, to resolve symbols I need to access the symbolic table of the kernel,
which otherwise wiped out due to overlapping with kernel.bss.

Using linker script to manually push back the bss worked, but IMO ugly and I wonder how everyone solve this.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: Dumping symbolic table of kernel image itself

Post by Owen »

The .symtab section is a discardable section; it is not designed to facilitate runtime linking. You want the shared library symbol hash table.
Post Reply