Omnimaga > Ndless

ELF Loader for Ndless - (now ready for non-dev use)

(1/7) > >>

tangrs:
The ELF loader has reached a stage where most people can use it to load basic stuff.

When you run the program, it installs a hook. After that, you can load ELF files as if you'd load a normal Ndless binary.

More instructions on how to compile the loader and how to develop applications that take advantage of it are described in the README.

You can get the source code on Github.

Happy deving!

I'd also like to thank everyone who contributed to Ndless. I did borrow some of Ndless's code for use in this loader.

Original post:

I'm not sure if it's relevant here, but I'm developing an opensource ELF loader for Ndless.

I'm writing this because the current Ndless way of loading binaries doesn't work for code that relies on static initialization of pointers.

I.e. code like this doesn't work:


--- Code: ---void foo() {
  //blah
}

int main() {
  static void (*var)() = foo; //Since it's static, the address will be inserted at link time (which is 0x8000+offset on my machine)
  var(); //The GOT based relocation code in Ndless currently does not update the static variable function pointer.
  return 0; //Crash
}
--- End code ---

Unfortunately, there's no way to fix this because Ndless binaries are converted into a memory image before running. That means the relocation code doesn't know what to update in the .data section of the memory because it doesn't know what symbols exist and need updating and where they're located.

Loading from an ELF file works because the symbol definitions are there and the relocation code knows where to find the bits that need patching. That's why I wrote this ELF loader.

Anyway, the core code is there, just needs a lot of polishing up.

If anyone wants to help, the source code is available on Github https://github.com/tangrs/ndless-elfloader
I'm hoping eventually, it will be integrated into the program loader on Ndless.

Thanks for your time,
Apologies if this is the wrong forum to post.

Jim Bauwens:
Interesting :)

I don't however know much about this subject to give a good response :P
But thanks for sharing :)

(on a side note, did you get my pm of a few day's ago?)

tangrs:

--- Quote from: jimbauwens on December 15, 2011, 05:09:01 am ---Interesting :)

I don't however know much about this subject to give a good response :P
But thanks for sharing :)

(on a side note, did you get my pm of a few day's ago?)

--- End quote ---

Yeah, I did. I couldn't respond because I'm a new user and can't send messages yet or something.

Lionel Debroux:
Interesting indeed :)

The flip side of the coin of the power of ELF is its complexity, and the weight of a full-featured launcher. In the past, there were discussions about using BFLT, which is a much simpler format, easily derived from ELF, and fulfills the purpose you're describing.

tangrs:
BFLT does look interesting. I'll look into it.

Out of curiosity, why was BFLT never used?

Edit: You're right. ELF is pretty complex. Out of the week I spent on the project, 4-5 days were spent just reading and re-reading manuals and example code XD

Navigation

[0] Message Index

[#] Next page

Go to full version