Is it possible to make ELF binaries work without paging?
Is it possible to make ELF binaries work without paging?
I've decided to get minimal ELF support in my OS. However I will make paging later, not today. I want to know can ELFs work without paging at all. Do you know that?
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing
OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing
OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
Re: Is it possible to make ELF binaries work without paging?
Sure, why not. But you may need to support some form of relocation, either the standard relocations in the executable or segments with nonzero bases.
Re: Is it possible to make ELF binaries work without paging?
Maybe, you can start by generating executable as PIC. So, you can place it anywhere.
Re: Is it possible to make ELF binaries work without paging?
Yes, you can. ELF are designed to store code and data for many systems; among them are ones without paging.
Make sure you use a proper address in your linker script (the one where you're going to load the ELF) and you won't need any position independent code at all.
Make sure you use a proper address in your linker script (the one where you're going to load the ELF) and you won't need any position independent code at all.
Re: Is it possible to make ELF binaries work without paging?
How would you run two instances of a program? Or two different programs compiled with the same linker script?bzt wrote:Make sure you use a proper address in your linker script (the one where you're going to load the ELF) and you won't need any position independent code at all.
Your options really are:
- PIC
- relocations (a bit complicated in ELF's compared with PE's or a.out's)
- separate address spaces (the OP doesn't have that yet)
- segmentation (will complicate things)
- swapping out the entire program in order to run another (inefficient, can't swap out until/unless all program's system calls completed or their results are buffered)
Re: Is it possible to make ELF binaries work without paging?
PIC or relocating will work just fine.
I had both in my OS and relocating is worth implementing anyways for the sake of ASLR
I had both in my OS and relocating is worth implementing anyways for the sake of ASLR
Re: Is it possible to make ELF binaries work without paging?
Well, maybe it's just me, but I think PIC in protected mode (at least the code gcc generates) is suboptimal. On the other hand in long mode is better, but there relocation has a significant overhead compared to protmode.Ch4ozz wrote:PIC or relocating will work just fine.
I had both in my OS and relocating is worth implementing anyways for the sake of ASLR
The second part, PIC worth it I couldn't agree more. But not only for the sake of ASLR (Btw it's quite easy to bypass it, you'll only need one reference to a library from your code, and there you go (I mean you target a library which has a sechole but you don't know it's address. So you dynamically link your exploit with that library, and the run time linker will kindly put the randomized address in GOT for you. You read it, subtract it's relative position and you got the load address of the target library whatever that address is). I think the benefit that ASLR gives you does not compare to the effort and the overhead, you should protect your libraries a different way. But if you already have it, good for you!)
Re: Is it possible to make ELF binaries work without paging?
You already answered your question My point is, he can use ELF binaries without paging and PIC as a start. When it's working properly, he can go further (either with segmentation or paging or relocation or whatever he chooses).alexfru wrote:How would you run two instances of a program? Or two different programs compiled with the same linker script?
Your options really are:
- PIC
- relocations (a bit complicated in ELF's compared with PE's or a.out's)
- separate address spaces (the OP doesn't have that yet)
- segmentation (will complicate things)
- swapping out the entire program in order to run another (inefficient, can't swap out until/unless all program's system calls completed or their results are buffered)
Re: Is it possible to make ELF binaries work without paging?
I want to just properly run ELFs first.alexfru wrote:How would you run two instances of a program?[/list]bzt wrote:Make sure you use a proper address in your linker script (the one where you're going to load the ELF) and you won't need any position independent code at all.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing
OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing
OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.