* Embedding stuff in ELF section of compiled module
@ 2024-11-09 15:15 Olivier Dion
2024-11-09 18:31 ` Matt Wette
2024-11-10 12:05 ` Maxime Devos via General Guile related discussions
0 siblings, 2 replies; 3+ messages in thread
From: Olivier Dion @ 2024-11-09 15:15 UTC (permalink / raw)
To: guile-user
Hi,
TLDR; Is there a way to embed a bytevector into a ELF section of a
compiled module (.go)?
I have a case where I want to generate bytevectors that follow an ABI
for event description of static tracepoints. I would like this
bytevector to be put into a know ELF section of the compiled module so
that external tools can reference it by parsing the ELF file,
i.e. without running Guile. I personnaly don't care about none-ELF
systems, so I'm fine if this solution is Linux only.
I guess this is similar to embedding something else like an audio/image
for a video game.
So, is there any way for adding section to the compiled ELF, something
along like:
(embed-bytevector ".my_section"
#vu8(bytes ...))
If not, I wonder if this is something that could be appreciated for
other users as well?
Thanks,
Olivier
--
Olivier Dion
EfficiOS Inc.
https://www.efficios.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Embedding stuff in ELF section of compiled module
2024-11-09 15:15 Embedding stuff in ELF section of compiled module Olivier Dion
@ 2024-11-09 18:31 ` Matt Wette
2024-11-10 12:05 ` Maxime Devos via General Guile related discussions
1 sibling, 0 replies; 3+ messages in thread
From: Matt Wette @ 2024-11-09 18:31 UTC (permalink / raw)
To: guile-user
On 11/9/24 7:15 AM, Olivier Dion wrote:
> Hi,
>
> TLDR; Is there a way to embed a bytevector into a ELF section of a
> compiled module (.go)?
>
> I have a case where I want to generate bytevectors that follow an ABI
> for event description of static tracepoints. I would like this
> bytevector to be put into a know ELF section of the compiled module so
> that external tools can reference it by parsing the ELF file,
> i.e. without running Guile. I personnaly don't care about none-ELF
> systems, so I'm fine if this solution is Linux only.
>
> I guess this is similar to embedding something else like an audio/image
> for a video game.
>
> So, is there any way for adding section to the compiled ELF, something
> along like:
>
> (embed-bytevector ".my_section"
> #vu8(bytes ...))
>
> If not, I wonder if this is something that could be appreciated for
> other users as well?
>
> Thanks,
> Olivier
>
You could look at `objcopy' to add a section to the .go file (outside of
Guile).
Otherwise, dig into the code in share/guile/3.0/system/vm/elf.scm.
Matt
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: Embedding stuff in ELF section of compiled module
2024-11-09 15:15 Embedding stuff in ELF section of compiled module Olivier Dion
2024-11-09 18:31 ` Matt Wette
@ 2024-11-10 12:05 ` Maxime Devos via General Guile related discussions
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Devos via General Guile related discussions @ 2024-11-10 12:05 UTC (permalink / raw)
To: Olivier Dion, guile-user@gnu.org
>TLDR; Is there a way to embed a bytevector into a ELF section of a
compiled module (.go)?
Yes, all (referenced) bytevectors end up somewhere. But going by the rest, it needs to be in some section in particular.
>So, is there any way for adding section to the compiled ELF, something
along like:
> (embed-bytevector ".my_section"
#vu8(bytes ...))
Except perhaps for external tools (like 'objcopy’ mentioned elsewhere), not yet. At least, I think I would remember reading about such a mechanism.
So, answer is yes: the way to do this is too add support to Guile for this.
That said, are you sure it’s a separate section you want? Perhaps an entry in the (ELF) symbol table would do as well (and these are already populated, though I don’t recall to what extent).
Best regards,
Maxime Devos
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-10 12:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-09 15:15 Embedding stuff in ELF section of compiled module Olivier Dion
2024-11-09 18:31 ` Matt Wette
2024-11-10 12:05 ` Maxime Devos via General Guile related discussions
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).