From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by sourceware.org (Postfix) with ESMTPS id 0AF783864862 for ; Fri, 29 Jul 2022 22:30:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0AF783864862 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f45.google.com with SMTP id va17so10873247ejb.0 for ; Fri, 29 Jul 2022 15:30:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=M+3wY8TIZWk+K5TxeZ3krneDJoPhI8nURhhU8EXQpGs=; b=8OOOdg6Uk/sbngrZX9oWajozELIzWgiTYmC8DUCpYEID9R9+3c7DWMLDWLKkbKLGCL KeiF4cmjMJUTX8n54WyAC9u1ev3zqnzrUIZgcQr/M9ZBmrZH2oIFadBZ5yEODJl6LJLV sEDr75gT6Zk71SRIPCw+IawSCPPSvtF5kKeFNYk9RI5vPjEj4GJDNEC2DpXAojihsgau gcvTdopAXYcgvQFX7DQbWmJXCK2QoDB0O0l65drhP5DWY+XtZ5ykhCVc35HzEy/md+Or BdXANS6DHEigJtFebU1CReLC07jAxs+c/8+OaqZPwOkYDOmo0pypW45TEtQXALSnpkzs uniA== X-Gm-Message-State: AJIora/oLPE1H8eChylOJJOLTM6td73ljRxd0GrL2+fvkzksOPk2TnTY z8PFnmmQ9GYgbSTWDI0Fwmlef0+7y5ezbQ== X-Google-Smtp-Source: AGRyM1sXCTWDBxf0/d3W5MZEN4AyNLkKmKb0BY8dtF3p4lG9OkWkImU3eUlr97Mb5hxdJwc5hzM32Q== X-Received: by 2002:a17:906:ef8c:b0:72e:dd32:4163 with SMTP id ze12-20020a170906ef8c00b0072edd324163mr4428541ejb.430.1659133855278; Fri, 29 Jul 2022 15:30:55 -0700 (PDT) Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com. [209.85.218.45]) by smtp.gmail.com with ESMTPSA id v9-20020a170906292900b0071cbc7487e1sm2183808ejd.69.2022.07.29.15.30.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jul 2022 15:30:55 -0700 (PDT) Received: by mail-ej1-f45.google.com with SMTP id os14so10785250ejb.4 for ; Fri, 29 Jul 2022 15:30:54 -0700 (PDT) X-Received: by 2002:a17:907:7637:b0:72b:3a3b:7d68 with SMTP id jy23-20020a170907763700b0072b3a3b7d68mr4325639ejc.566.1659133854549; Fri, 29 Jul 2022 15:30:54 -0700 (PDT) MIME-Version: 1.0 References: <20220726192216.1751042-1-luca.boccassi@gmail.com> In-Reply-To: From: Luca Boccassi Date: Fri, 29 Jul 2022 23:30:43 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] gold: add --package-metadata To: Cary Coutant Cc: Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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: , X-List-Received-Date: Fri, 29 Jul 2022 22:30:59 -0000 On Fri, 29 Jul 2022 at 20:41, Cary Coutant wrote: > > > Following the same format as the implementation in ld: > > 9e2bb0cb5e74aed4158f08495534922d7108f928 > > > > Generate a .note.package FDO package metadata ELF note, following > > the spec: https://systemd.io/ELF_PACKAGE_METADATA/ > > > > If the jansson library is available at build time (and it is explicitly > > enabled), link ld to it, and use it to validate that the input is > > correct JSON, to avoid writing garbage to the file. The > > configure option --enable-jansson has to be used to explicitly enable > > it (error out when not found). This allows bootstrappers (or others who > > are not interested) to seamlessly skip it without issues. > > I reviewed the earlier discussion and I had some of the same questions > and concerns as others did there, so they've all been answered. I'd > have preferred an option syntax that would let you build up the > metadata info one key/value pair at a time. Given that it has already > been accepted for ld, however, I'll OK it for gold as well, with the > following fixes... > > + json_t *json = json_loads (desc, 0, &json_error); > > C++ coding conventions here: no space before the paren in a function call. > > + if (!json) > + gold_fatal(_("error: --package-metadata=%s does not contain valid " > + "JSON: %s\n"), > + desc, json_error.text); > + else > + json_decref (json); > > Put the shorter, non-error path first (i.e., make it "if > (json)...else..."), and use { } for the longer error path (even though > it's only one statement, I think braces around a multi-line statement > help readability). Also, no space before the paren. > > + if (trailing_padding != 0) > + { > + posd = new Output_data_zero_fill(trailing_padding, 0); > + os->add_output_section_data(posd); > + } > > The braces and what's inside them need an extra two spaces of indent. > > -cary Thank you for the review, sent v2 with the requested changes. Kind regards, Luca Boccassi