OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Aug 03, 2020 9:30 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: GCC insert custom section data into ELF binary
PostPosted: Wed May 13, 2020 12:17 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2073
Location: USA (and Australia)
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.

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: GCC insert custom section data into ELF binary
PostPosted: Wed May 13, 2020 12:35 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 542
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?

__attribute__((section("foo")))

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.

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.

_________________
Life is beautiful. Nobody said easy.


Top
 Profile  
 
 Post subject: Re: GCC insert custom section data into ELF binary
PostPosted: Wed May 13, 2020 1:55 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2073
Location: USA (and Australia)
Thanks! It seems easy enough to tag a struct and even initialize it with a constexpr.

AndrewAPrice wrote:
But why would you not just run the binary and have it register such a list with your kernel?


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".

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: GCC insert custom section data into ELF binary
PostPosted: Wed May 13, 2020 3:12 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2073
Location: USA (and Australia)
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.

_________________
My OS is Perception.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group