* RFC: Add ELF note for description with JSON data
@ 2023-03-29 12:44 Sebastian Huber
2023-03-29 14:27 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Huber @ 2023-03-29 12:44 UTC (permalink / raw)
To: binutils
Hello,
I would like to add some metadata to executable ELF files for the RTEMS
real-time operating system. It seems that ELF notes are a good way to do
this. Would it be possible to add a standard or GNU-specific note type
for descriptions which contain data in JSON format? This would help to
use standard tools such as readelf to get the descriptions of such
notes. For example:
diff --git a/include/elf/common.h b/include/elf/common.h
index 6f64f05890c..95d6068178f 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -824,6 +824,7 @@
#define NT_GNU_BUILD_ID 3 /* Generated by ld
--build-id. */
#define NT_GNU_GOLD_VERSION 4 /* Generated by gold. */
#define NT_GNU_PROPERTY_TYPE_0 5 /* Generated by gcc. */
+#define NT_GNU_JSON 6 /* Contains arbitrary JSON data. */
#define NT_GNU_BUILD_ATTRIBUTE_OPEN 0x100
#define NT_GNU_BUILD_ATTRIBUTE_FUNC 0x101
$ readelf -n --format=json file.elf
{"note-sections": [
{"section": ".note.gnu.json", "notes": [
{"name": "GNU",
"type": 6,
"type-info": "NT_GNU_JSON",
"description": {"key": "value"}}]}
The note was produced by:
.pushsection .note.gnu.json , "", %note
.balign 4
.long 2f - 1f
.long 4f - 3f
.long 6
1: .asciz "GNU"
2: .balign 4
3: .asciz "{\"key\": \"value\"}"
4: .balign 4
.popsection
A basic support would require the allocation of a node type number and a
new type-specific output.
Optionally, we could add JSON output to readelf. One option would be to
do this using libxo:
https://juniper.github.io/libxo/libxo-manual.html
Would such a feature acceptable in general?
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: Add ELF note for description with JSON data
2023-03-29 12:44 RFC: Add ELF note for description with JSON data Sebastian Huber
@ 2023-03-29 14:27 ` Nick Clifton
2023-03-29 15:04 ` Sebastian Huber
0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2023-03-29 14:27 UTC (permalink / raw)
To: Sebastian Huber, binutils
Hi Sebastian,
> I would like to add some metadata to executable ELF files for the RTEMS real-time operating system.
Have you considered using the --package-data linker option ?
'--package-metadata=JSON'
Request the creation of a '.note.package' ELF note section. The
contents of the note are in JSON format, as per the package
metadata specification. For more information see:
https://systemd.io/ELF_PACKAGE_METADATA/ If the JSON argument is
missing/empty then this will disable the creation of the metadata
note, if one had been enabled by an earlier occurrence of the
-package-metdata option. If the linker has been built with
libjansson, then the JSON string will be validated.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: Add ELF note for description with JSON data
2023-03-29 14:27 ` Nick Clifton
@ 2023-03-29 15:04 ` Sebastian Huber
2023-03-29 16:46 ` Nick Clifton
0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Huber @ 2023-03-29 15:04 UTC (permalink / raw)
To: Nick Clifton, binutils
Hello Nick,
On 29.03.23 16:27, Nick Clifton wrote:
> Hi Sebastian,
>
>> I would like to add some metadata to executable ELF files for the
>> RTEMS real-time operating system.
>
> Have you considered using the --package-data linker option ?
>
> '--package-metadata=JSON'
> Request the creation of a '.note.package' ELF note section. The
> contents of the note are in JSON format, as per the package
> metadata specification. For more information see:
> https://systemd.io/ELF_PACKAGE_METADATA/ If the JSON argument is
> missing/empty then this will disable the creation of the metadata
> note, if one had been enabled by an earlier occurrence of the
> -package-metdata option. If the linker has been built with
> libjansson, then the JSON string will be validated.
thanks, this looks like the thing we need.
Independent of this, selecting the output format of readelf (and other
tools) would be nice.
--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax: +49-89-18 94 741 - 08
Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: RFC: Add ELF note for description with JSON data
2023-03-29 15:04 ` Sebastian Huber
@ 2023-03-29 16:46 ` Nick Clifton
0 siblings, 0 replies; 4+ messages in thread
From: Nick Clifton @ 2023-03-29 16:46 UTC (permalink / raw)
To: Sebastian Huber, binutils
Hi Sebastian,
> Independent of this, selecting the output format of readelf (and other tools) would be nice.
Yes, sorry. I did not read your original email properly.
> +#define NT_GNU_JSON 6 /* Contains arbitrary JSON data. */
I would have no objection to adding this particular note type.
It would be best if if this was agreed upon by the ELF ABI folks though.
> Optionally, we could add JSON output to readelf. One option would be to do this using libxo:
Personally I would prefer not to complicate readelf by adding another
dependency. Are there tools that can read JSON output from a pipe ?
I was thinking that it might be reasonable to add an option to readelf
along the lines of --note-body-parser=<program> and have it pass the
contents of any note it is displaying to <program>. This would allow
for any kind of formatting inside notes, and would not add any dependencies
to readelf.
Cheers
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-29 16:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 12:44 RFC: Add ELF note for description with JSON data Sebastian Huber
2023-03-29 14:27 ` Nick Clifton
2023-03-29 15:04 ` Sebastian Huber
2023-03-29 16:46 ` Nick Clifton
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).