Is it possible, someway in C/C++ code in GCC, to define data that can be put into custom sections in an ELF binary?
I was wondering if it was possible for userland services in my OS to expose a list of RPC entry points, even if the process isn't yet loaded and running in memory.
GCC insert custom section data into ELF binary
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: GCC insert custom section data into ELF binary
__attribute__((section("foo")))AndrewAPrice wrote:Is it possible, someway in C/C++ code in GCC, to define data that can be put into custom sections in an ELF binary?
Sections are not necessarily a feature of executables. There might be a special segment, but then you're going into special linker script territory. But why would you not just run the binary and have it register such a list with your kernel? Seems simpler to me.AndrewAPrice wrote:I was wondering if it was possible for userland services in my OS to expose a list of RPC entry points, even if the process isn't yet loaded and running in memory.
Carpe diem!
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: GCC insert custom section data into ELF binary
Thanks! It seems easy enough to tag a struct and even initialize it with a constexpr.
It's just one of many possibilities I'm evaluating for working around the race condition of a service starting (e.g. the VFS), and then, say an essential driver that's part of the initialization process (such as the video card) that wants to call "VFS.ReadFile" to read some configuration file, if the main thread of the VFS was preempted before getting around to register "VFS.ReadFile".AndrewAPrice wrote:But why would you not just run the binary and have it register such a list with your kernel?
My OS is Perception.
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: GCC insert custom section data into ELF binary
I think it would be best if I solved this problem another way - registering RPCs with the kernel but sending an "initialized" message when the process is ready to receive calls. Then drivers can say "get Device Manager and wait for it to be initialized, timeout after 5s".
Then I can start my system with a "Process Soup" - a bunch of multiboot modules essential services and drivers, and they can sleep until their dependencies are initialized.
The custom ELF sections would still let us do interesting stuff such as examine what RPCs a process would expose without launching it.
Then I can start my system with a "Process Soup" - a bunch of multiboot modules essential services and drivers, and they can sleep until their dependencies are initialized.
The custom ELF sections would still let us do interesting stuff such as examine what RPCs a process would expose without launching it.
My OS is Perception.