dynamic symbol table in kernel
Posted: Tue May 14, 2013 2:09 pm
I'm attempting to build my kernel with the dynamic symbol table and hash table so that I can load modules efficiently into the kernel's address space. This is briefly explained at the bottom of this wiki page: http://wiki.osdev.org/LD
The idea is to build the kernel as a shared library, and resolve all symbols within the kernel. This will still leave the dynamic symbol table around. I've run into a problem for which I've created a minimal test case which fails:
tmp.c:
I build this using gcc -c (I've tried with both my cross compiler and the native toolchain). The relocatable object file has the following (from objdump -dr):
I try to link it :
And the linker complains:
Why can't it relocate against the rodata section which should be in the resulting binary? Thanks
The idea is to build the kernel as a shared library, and resolve all symbols within the kernel. This will still leave the dynamic symbol table around. I've run into a problem for which I've created a minimal test case which fails:
tmp.c:
Code: Select all
int foo(const char* s)
{
return 0;
}
int main()
{
return foo("bar");
}
Code: Select all
000000000000000f <main>:
f: 55 push %rbp
10: 48 89 e5 mov %rsp,%rbp
13: bf 00 00 00 00 mov $0x0,%edi
14: R_X86_64_32 .rodata
18: e8 00 00 00 00 callq 1d <main+0xe>
19: R_X86_64_PC32 foo-0x4
1d: 5d pop %rbp
1e: c3 retq
Code: Select all
CC -Wl,-Bsymbolic -Wl,-z,defs -Wl,-shared test.o
Code: Select all
relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC