Include ELF symtab section in PT_LOAD segment?
Include ELF symtab section in PT_LOAD segment?
Is it possible to include an ELF symtab section in a PT_LOAD segment? Would be convenient for module loading.
Marionette the flexible kernel
-
- Member
- Posts: 524
- Joined: Sun Nov 09, 2008 2:55 am
- Location: Pennsylvania, USA
Re: Include ELF symtab section in PT_LOAD segment?
Take a look at the PHDR command (for linker scripts) so you can write your own program headers.
Re: Include ELF symtab section in PT_LOAD segment?
linker.ld
foo.c
gcc -nostdlib -Wl,-T,linker.ld -o foo foo.c
All I get in the (only) segment is .text.
Code: Select all
ENTRY(_start)
OUTPUT_FORMAT(elf32-i386)
PHDRS {
loadable PT_LOAD FLAGS(7) ;
}
SECTIONS {
.text : {
*(.text*)
} :loadable
.symtab : {
*(.symtab)
} :loadable
}
Code: Select all
void foo(void){}
void _start(void)
{
for (;;);
}
All I get in the (only) segment is .text.
Marionette the flexible kernel
Re: Include ELF symtab section in PT_LOAD segment?
Hi,
If you're loading a kernel module, you're acting as the static linker, not the dynamic linker. (I.e. you're acting as 'ld' on the command line, not ld.so). That means you look at section information, rather than segment information.
Sections are for linking, segments are for loading.
Cheers,
James
If you're loading a kernel module, you're acting as the static linker, not the dynamic linker. (I.e. you're acting as 'ld' on the command line, not ld.so). That means you look at section information, rather than segment information.
Sections are for linking, segments are for loading.
Cheers,
James
Re: Include ELF symtab section in PT_LOAD segment?
Yes, JamesM, I am fully aware of that. I can read the section headers of the ELF module - that's fine, since GRUB loads the entire ELF module file, headers and all.
The problem I'm having is getting the addresses of the *kernel's* symbols, to resolve the ELF module's symbols. Hence, I need the kernel's symbol table.
Therefore, if there's a way of including the *kernel's* symbol table in a PT_LOAD segment of the *kernel*, then it would be really convenient.
Sorry for the misunderstanding
The problem I'm having is getting the addresses of the *kernel's* symbols, to resolve the ELF module's symbols. Hence, I need the kernel's symbol table.
Therefore, if there's a way of including the *kernel's* symbol table in a PT_LOAD segment of the *kernel*, then it would be really convenient.
Sorry for the misunderstanding
Marionette the flexible kernel
Re: Include ELF symtab section in PT_LOAD segment?
Grub loads your kernel's symbol table. Look at the multiboot information - you'll get a full list of section headers. (as long as you don't use the AOUT_KLUDGE).