Page 1 of 1

Dumping symbolic table of kernel image itself

Posted: Fri Jun 24, 2011 3:18 pm
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)?

Re: Dumping symbolic table of kernel image itself

Posted: Fri Jun 24, 2011 3:43 pm
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.

Re: Dumping symbolic table of kernel image itself

Posted: Fri Jun 24, 2011 5:18 pm
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.