RFC: Add ELF note for description with JSON data
Sebastian Huber
sebastian.huber@embedded-brains.de
Wed Mar 29 12:44:50 GMT 2023
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/
More information about the Binutils
mailing list