Parse 64-bit ELF kernel in a 32-bit loader

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
Cyxo
Posts: 6
Joined: Sun Apr 29, 2018 9:45 am
Libera.chat IRC: Cyxo

Parse 64-bit ELF kernel in a 32-bit loader

Post by Cyxo »

Hello,

I'm following this Wiki article: Creating_a_64-bit_kernel_using_a_separate_loader

And in the Loader section, it uses an elf64.h file (and the related elf64.c file). Unfortunately the links to these files are not there:
a helper function and a header I wrote following the ELF64 specification (Available [|here]) and function declarations (Available [|here])
So I was wondering: does anyone have this library somewhere?

I found GeekOS' elf64 library which has a Parse_ELF_Executable function, but it doesn't seem to be exactly the same, and I've not looked how I could use it for this purpose.

Otherwise, is there another way I should run my 64-bit ELF kernel? (I know I can write my own ELF parser but that's also a lot of work)
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Parse 64-bit ELF kernel in a 32-bit loader

Post by nexos »

Actually, writing your own ELF parser is quite easy! Take a look here. Still, you should understand the ELF file format first.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
User avatar
Cyxo
Posts: 6
Joined: Sun Apr 29, 2018 9:45 am
Libera.chat IRC: Cyxo

Re: Parse 64-bit ELF kernel in a 32-bit loader

Post by Cyxo »

Indeed this is pretty short!

Actually I was just kind of lazy to define the structs and types that make it easy to use like in the wiki article or like you did in your file :roll:
That's why I asked if there was some public library for this in the first place.

But thanks for your example, if I end up writing my own parser, I'll probably get some inspiration from yours as well!
nexos
Member
Member
Posts: 1081
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Parse 64-bit ELF kernel in a 32-bit loader

Post by nexos »

I copied the structs from glibc. Don't worry about copyright problems, those structs aren't quite IP of GNU :) .
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
Post Reply