From patchwork Wed Mar 29 12:44:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Huber X-Patchwork-Id: 76561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp383045vqo; Wed, 29 Mar 2023 05:45:02 -0700 (PDT) X-Google-Smtp-Source: AKy350Y39twjbidToYtMrThIC/R8/HjnYfwi54Wk28QoPhMMoLiHBevxVVCnCT+BBxWcozL5mB4d X-Received: by 2002:a17:907:20ee:b0:930:6e31:3c11 with SMTP id rh14-20020a17090720ee00b009306e313c11mr20493384ejb.70.1680093901990; Wed, 29 Mar 2023 05:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680093901; cv=none; d=google.com; s=arc-20160816; b=HChvEb10GAgKePE6fmIMVXr4Y1eGLXm5vWJ6Fr7Cki/OR5a0ZQZx02bycs/SsHFmCi r9jyZ+yqhhXHCErgUbjPPzqSyn6uLNk66BlB5Pc+W/g/5X5I0zziBA1D9cwYF1mGw79k mX09einAsnEsFHhsi2c1rWukhRP/KZbUbQPiQSlsNIwR3kL7zRm3TK9wyZV/UhiaMy/s e+XWObZSCwcFtb9hY6DvS6sEgjOSdrM2akcno1zVAdT+wj++e22wEABpWgBqTvdLDfgg D5OdlWwFBYVKSLPTuf9w/7I54HG3OHyeGAKqIYqPgbWjAm+dMYu+XIDrRlVXAcKUoaar dhIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :subject:from:to:content-language:user-agent:mime-version:date :message-id:dmarc-filter:delivered-to; bh=pA/nudv1u++ORtZ5Zbq0S3ruh16EeD+WAxOgg54ukF4=; b=GcifoglIHsARTx9M2TniWzoCqpLEHGx36LP4yQWxHZyDv004B/+lXhLB8MmDSVCSS5 hKlPgERbuWHHKKQ12d2KdT26vT0StiTLej+MHdza90U0/2m609r42jvSDNkhkef3NlC8 4QeeF55TaI9A9iNadbVbnS7+8t/Yqg+gx/PjFNj3caw4vtAMWxgtcmDs4a2tPcveF+h4 86eR58wYxUgbJ6raR02JA2+MtC5hisUS7xcFxbN+kkwOuygDzMCuJk6jhVHj5F+GmKVV momQGPGeuPnv3sJR0Wy6m8hmDEkQPk6sdaIV1VGCF3LDm+FsLSw7YjRTgz3U6WccxNZR IACw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id sb11-20020a1709076d8b00b00935ebcc14b3si26681033ejc.251.2023.03.29.05.45.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 05:45:01 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 20C0F3858434 for ; Wed, 29 Mar 2023 12:45:00 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from dedi548.your-server.de (dedi548.your-server.de [85.10.215.148]) by sourceware.org (Postfix) with ESMTPS id 98D4F3858D1E for ; Wed, 29 Mar 2023 12:44:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 98D4F3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embedded-brains.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embedded-brains.de Received: from sslproxy04.your-server.de ([78.46.152.42]) by dedi548.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1phVAZ-0007jj-Hp for binutils@sourceware.org; Wed, 29 Mar 2023 14:44:51 +0200 Received: from [82.100.198.138] (helo=mail.embedded-brains.de) by sslproxy04.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1phVAZ-000RBw-EG for binutils@sourceware.org; Wed, 29 Mar 2023 14:44:51 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id 1CDBF480178 for ; Wed, 29 Mar 2023 14:44:51 +0200 (CEST) Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id LYWIiBS-a4jJ for ; Wed, 29 Mar 2023 14:44:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail.embedded-brains.de (Postfix) with ESMTP id B9036480199 for ; Wed, 29 Mar 2023 14:44:50 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.eb.localhost Received: from mail.embedded-brains.de ([127.0.0.1]) by localhost (zimbra.eb.localhost [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 5_AsAxEbKdlr for ; Wed, 29 Mar 2023 14:44:50 +0200 (CEST) Received: from [10.10.171.6] (unknown [10.10.171.6]) by mail.embedded-brains.de (Postfix) with ESMTPSA id 882BA480178 for ; Wed, 29 Mar 2023 14:44:50 +0200 (CEST) Message-ID: <2a19f48f-2230-70c2-a6eb-de224028e8ae@embedded-brains.de> Date: Wed, 29 Mar 2023 14:44:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: binutils@sourceware.org From: Sebastian Huber Subject: RFC: Add ELF note for description with JSON data X-Authenticated-Sender: smtp-embedded@poldi-networks.de X-Virus-Scanned: Clear (ClamAV 0.103.8/26858/Wed Mar 29 09:28:45 2023) X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761706143317165163?= X-GMAIL-MSGID: =?utf-8?q?1761706143317165163?= 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: $ 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? 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