[PATCH v5] ld: Add --encoded-package-metadata

Jan Beulich jbeulich@suse.com
Wed Jul 24 05:48:27 GMT 2024


On 24.07.2024 01:28, Benjamin Drung wrote:
> Specifying the compiler flag `-Wl,--package-metadata=<JSON>` will not
> work in case the JSON contains a comma, because compiler drivers eat
> commas. Example:
> 
> ```
> $ echo "void main() { }" > test.c
> $ gcc '-Wl,--package-metadata={"type":"deb","os":"ubuntu"}' test.c
> /usr/bin/ld: cannot find "os":"ubuntu"}: No such file or directory
> collect2: error: ld returned 1 exit status
> ```
> 
> The quotation marks in the JSON value do not work well with shell nor
> make. Specifying the `--package-metadata` linker flag in a `LDFLAGS`
> environment variable might loose its quotation marks when it hits the
> final compiler call.
> 
> So introduce a `--encoded-package-metadata` linker flag that takes a
> percent-encoded JSON. Percent-encoding is used because it is a
> standard, simple to implement, and does take too many additional
> characters.
> 
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32003
> Bug-Ubutru: https://bugs.launchpad.net/bugs/2071468
> Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
> ---
>  ld/NEWS                              |  5 +++
>  ld/emultempl/elf.em                  | 19 +++++++++++
>  ld/ld.texi                           | 15 ++++++++-
>  ld/ldlex.h                           |  1 +
>  ld/ldmisc.c                          | 49 ++++++++++++++++++++++++++++
>  ld/ldmisc.h                          |  1 +
>  ld/lexsup.c                          |  2 ++
>  ld/testsuite/ld-elf/package-note.exp | 18 ++++++++++
>  ld/testsuite/ld-elf/package-note2.rd |  6 ++++
>  9 files changed, 115 insertions(+), 1 deletion(-)
>  create mode 100644 ld/testsuite/ld-elf/package-note2.rd

And what exactly has changed in v5? There's no revlog anywhere here,
afaics.

Jan


More information about the Binutils mailing list