Hi guys,
Im having some trouble with loading a Relocatable ELF64...
At the moment GRUB loads my ELF64 Loader and the 64 bit ELF kernel as a module.
The ELF64 Loader then proceeds to locate the kernel_main symbol whils also going through any RELA section and applying any relocations.
I know my Kernel shouldnt need anything from the ELF64 Loader, but I have put in some undefined functions to test the loader.
However, all of my undefined symbols have a type of 0x4 (R_X86_64_PLT32).
I cannot find any info on how to handle a symbol of this type and my kernel has no .*.plt.
Im just wandering if anyone has any information that may help me.
EDIT: It seems a few more minutes spent googling and I found the answer, however Id still like any info regarding to the above
The fix was to compile the kernel with '-mcmodel=kernel'
ELF64 RELA with type R_X86_64_PLT32
Re: ELF64 RELA with type R_X86_64_PLT32
There is a small amount of info in http://www.x86-64.org/documentation/abi.pdf. I guess you have this though.
If a trainstation is where trains stop, what is a workstation ?
Re: ELF64 RELA with type R_X86_64_PLT32
I very recently found out you may have parts of your plt (what's usually in the plt) inlined into the code if it's used only once. So you don't have a .plt section but there may still be a little bit of plt...
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: ELF64 RELA with type R_X86_64_PLT32
A very useful source of information about relocations is the Sun Linker and Libraries Guide. In chapter 7 you find a lot of information about the ELF format, both 32 and 64 bit, and some tables containing relocation types. Table 7-16 should contain the information you are looking for (x86_64 relocation types).
Just out of curiosity: What is your kernel's base address? Mine is located at 0xffffc00000000000 (= the topmost quarter of virtual memory) and uses -mcmodel=huge in order to avoid confusion with 32 bit relocations.
Just out of curiosity: What is your kernel's base address? Mine is located at 0xffffc00000000000 (= the topmost quarter of virtual memory) and uses -mcmodel=huge in order to avoid confusion with 32 bit relocations.
Re: ELF64 RELA with type R_X86_64_PLT32
@Candy - OK, I see.. But then how does one do a plt based relocation without the plt, not that I know how to do a plt relocation.
@XenOS - Thanks for the pointer, I shall take a look at it. Im currently compiling with the GCC '-r' oprion and '-mc-model=kernel', Ill try '-mc-model=huge' and see if it still results in non-plt relocations.
NOTE: Oops no '-mc-model=huge' in 64 Bit
I'm going to simplify the 2nd Stage ELF64 Loader and work on expanding it for Kernel use because, as I stated before my kernel will not need linking to the loader. But, I'm still wandering if I should build with '-r' or specify a base...
I assume that just using a relocatable code or maybe position independant code would be the best way forward.
@XenOS - Thanks for the pointer, I shall take a look at it. Im currently compiling with the GCC '-r' oprion and '-mc-model=kernel', Ill try '-mc-model=huge' and see if it still results in non-plt relocations.
NOTE: Oops no '-mc-model=huge' in 64 Bit
I'm going to simplify the 2nd Stage ELF64 Loader and work on expanding it for Kernel use because, as I stated before my kernel will not need linking to the loader. But, I'm still wandering if I should build with '-r' or specify a base...
I assume that just using a relocatable code or maybe position independant code would be the best way forward.