public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: luca.boccassi@gmail.com, binutils@sourceware.org
Subject: Re: [PATCH] ld: add --package-metadata
Date: Tue, 24 May 2022 17:23:36 +0100	[thread overview]
Message-ID: <7cd459a6-ac46-e9c2-14d1-16d78118bb92@redhat.com> (raw)
In-Reply-To: <20220515191846.114257-1-luca.boccassi@gmail.com>

Hi Luca,

   First of all a couple of questions about the need for the patch itself.

   Firstly - why modify the linker itself ?  Couldn't the same effect be
   achieved by using the assembler to create an object file and then
   including that in the link along with the other objects ?

   Secondly - why build json verification into the linker ?  It does not
   feel like a linkery kind of thing to do, and because the verification
   is dependent upon the linker being configured and built with the feature
   enabled, it means that programmers cannot rely upon their packaging
   notes always being checked.  To me, I think that it would be better to
   have a pre- or post- links stage where the note is checked by a separate
   tool.

   Lastly, since this option is being used to create a note section, maybe
   we ought to consider the need for a generic mechanism for the linker to
   create sections - other than using linker scripts.  For example, suppose
   that instead of --package-metadata=<JSON> there was an option:
   --add-note=<SEC-NAME>,<NOTE-NAME>,<CONTENTS>,[<VERIFIER>]
   which would basically do the same thing, but in a more generic fashion.

   Some thoughts on the patch itself:

> +  if (t->o->build_id.after_write_object_contents != NULL && !(*t->o->build_id.after_write_object_contents) (abfd))
> +    return false;

Line length - the if-statement should be over two lines.

> +  if (t->o->package_metadata.after_write_object_contents != NULL)
> +    return (*t->o->package_metadata.after_write_object_contents) (abfd);

For consistency sake, it would be nice if these two lines
were turned into a two predicate if-statement like the ones
above.  That way if other after_write_xxx functions are added
in the future, then this if-statement will not need to be
modified.

> +@kindex --package-metadata=@var{JSON}
> +@item --package-metadata=@var{JSON}
> +Request the creation of a @code{.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/COREDUMP_PACKAGE_METADATA/

You should mention that 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.

You should also add an entry to the ld/NEWS file about this new feature.

It might also be worth mentioning that the contents of the JSON text
will be checked for conformance to the standard, if the linker has been
configured and built that way.

Also - can the JSON data be read from a file ?  I can easily see problems
being encountered with the length of the linker command line if the JSON
data can only be specified as text.  (Possibly this can be avoided by using
the @file syntax already supported by the linker).

> -  if (ldelf_emit_note_gnu_build_id != NULL)
> +  if (ldelf_emit_note_gnu_build_id != NULL ||
> +      ldelf_emit_note_fdo_package_metadata != NULL)

Formatting - the || should be at the start of the next line.

> +  if (!ldelf_emit_note_fdo_package_metadata || strlen(ldelf_emit_note_fdo_package_metadata) == 0)
> +    return false;

Formatting - a space between strlen and the opening parenthesis please.

> +  json_t *json = json_loads(ldelf_emit_note_fdo_package_metadata, 0, &json_error);
> +    json_decref(json);

Likewise for these two function calls.


> +if { [istarget frv-*-*] || [istarget lm32-*-*] } {
> +    return
> +}

Why are these architectures being skipped ?

Cheers
   Nick



  parent reply	other threads:[~2022-05-24 16:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-15 19:18 luca.boccassi
2022-05-16 16:40 ` Fangrui Song
2022-05-17  6:03   ` Florian Weimer
2022-05-17 14:44     ` Luca Boccassi
2022-05-25  6:56       ` Fangrui Song
2022-05-25  7:53         ` Florian Weimer
2022-05-23 11:26 ` Luca Boccassi
2022-05-24  9:34   ` Jose E. Marchesi
2022-05-24 11:26     ` Luca Boccassi
2022-05-24 16:23 ` Nick Clifton [this message]
2022-05-24 18:38   ` Luca Boccassi
2022-05-25  8:45     ` Florian Weimer
2022-05-25 13:53       ` Luca Boccassi
2022-05-30 14:08         ` Florian Weimer
2022-05-24 16:28 ` Nick Clifton
2022-05-24 21:15 ` [PATCH v2] " luca.boccassi
2022-05-25  4:30   ` Alan Modra
2022-05-25  6:02     ` Alan Modra
2022-05-25 13:42       ` Luca Boccassi
2022-05-25 13:41 ` [PATCH v3] " luca.boccassi
2022-05-26  3:55   ` Alan Modra
2022-05-26 10:46     ` Luca Boccassi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7cd459a6-ac46-e9c2-14d1-16d78118bb92@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=luca.boccassi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).