Is it possible to make ELF binaries work without paging?
- abcdef4bfd
- Member
- Posts: 492
- Joined: Fri Apr 03, 2015 9:41 am
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?
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

Re: Is it possible to make ELF binaries work without paging?
You already answered your questionalexfru 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)

- abcdef4bfd
- Member
- Posts: 492
- Joined: Fri Apr 03, 2015 9:41 am
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.