public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note
@ 2024-05-10 21:58 luca.boccassi
  2024-05-14 21:18 ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: luca.boccassi @ 2024-05-10 21:58 UTC (permalink / raw)
  To: elfutils-devel

From: Luca Boccassi <bluca@debian.org>

Note that the webpage in the comment is not published yet,
it will be next week when the next systemd RC is tagged.
The document can be viewed right now on github at:
https://github.com/systemd/systemd/blob/main/docs/ELF_DLOPEN_METADATA.md

But the node ID and the string format are now fixed, even
if the content of the string might change, it will still be
a string.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
 libebl/eblobjnote.c         | 9 +++++++--
 libebl/eblobjnotetypename.c | 3 +++
 libelf/elf.h                | 4 ++++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index 1ba5d8b3..ad3f49de 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -288,9 +288,14 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type,
       if (descsz == 0 && type == NT_VERSION)
 	return;
 
-      if (strcmp ("FDO", name) == 0 && type == NT_FDO_PACKAGING_METADATA
+      if (strcmp ("FDO", name) == 0
 	  && descsz > 0 && desc[descsz - 1] == '\0')
-	printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
+	{
+	  if (type == NT_FDO_PACKAGING_METADATA)
+	    printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
+	  else if (type == NT_FDO_DLOPEN_METADATA)
+	    printf("    Dlopen  Metadata: %.*s\n", (int) descsz, desc);
+	}
 
       /* Everything else should have the "GNU" owner name.  */
       if (strcmp ("GNU", name) != 0)
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 473a1f2f..79ff010a 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -104,6 +104,9 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
       if (strcmp (name, "FDO") == 0 && type == NT_FDO_PACKAGING_METADATA)
 	return "FDO_PACKAGING_METADATA";
 
+      if (strcmp (name, "FDO") == 0 && type == NT_FDO_DLOPEN_METADATA)
+	return "FDO_DLOPEN_METADATA";
+
       if (strcmp (name, "GNU") != 0)
 	{
 	  /* NT_VERSION is special, all data is in the name.  */
diff --git a/libelf/elf.h b/libelf/elf.h
index f2206e5c..bbf4565c 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -1336,6 +1336,10 @@ typedef struct
    https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
 #define NT_FDO_PACKAGING_METADATA 0xcafe1a7e
 
+/* dlopen metadata as defined on
+   https://systemd.io/ELF_DLOPEN_METADATA/ */
+#define NT_FDO_DLOPEN_METADATA 0x407c0c0a
+
 /* Note section name of program property.   */
 #define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
 
-- 
2.39.2


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note
  2024-05-10 21:58 [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note luca.boccassi
@ 2024-05-14 21:18 ` Mark Wielaard
  2024-05-30 10:45   ` Luca Boccassi
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Wielaard @ 2024-05-14 21:18 UTC (permalink / raw)
  To: luca.boccassi; +Cc: elfutils-devel

Hi Luca,

On Fri, May 10, 2024 at 10:58:02PM +0100, luca.boccassi@gmail.com wrote:
> Note that the webpage in the comment is not published yet,
> it will be next week when the next systemd RC is tagged.
> The document can be viewed right now on github at:
> https://github.com/systemd/systemd/blob/main/docs/ELF_DLOPEN_METADATA.md
> 
> But the node ID and the string format are now fixed, even
> if the content of the string might change, it will still be
> a string.

Not a fan of json, feels very un-ELF. But it is what it is. The patch
looks OK. Could you let us know when the elf.h change is accepted in
glibc, then we'll sync and integrate this.

Thanks,

Mark

> 
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
>  libebl/eblobjnote.c         | 9 +++++++--
>  libebl/eblobjnotetypename.c | 3 +++
>  libelf/elf.h                | 4 ++++
>  3 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
> index 1ba5d8b3..ad3f49de 100644
> --- a/libebl/eblobjnote.c
> +++ b/libebl/eblobjnote.c
> @@ -288,9 +288,14 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type,
>        if (descsz == 0 && type == NT_VERSION)
>  	return;
>  
> -      if (strcmp ("FDO", name) == 0 && type == NT_FDO_PACKAGING_METADATA
> +      if (strcmp ("FDO", name) == 0
>  	  && descsz > 0 && desc[descsz - 1] == '\0')
> -	printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
> +	{
> +	  if (type == NT_FDO_PACKAGING_METADATA)
> +	    printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
> +	  else if (type == NT_FDO_DLOPEN_METADATA)
> +	    printf("    Dlopen  Metadata: %.*s\n", (int) descsz, desc);
> +	}
>  
>        /* Everything else should have the "GNU" owner name.  */
>        if (strcmp ("GNU", name) != 0)
> diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
> index 473a1f2f..79ff010a 100644
> --- a/libebl/eblobjnotetypename.c
> +++ b/libebl/eblobjnotetypename.c
> @@ -104,6 +104,9 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
>        if (strcmp (name, "FDO") == 0 && type == NT_FDO_PACKAGING_METADATA)
>  	return "FDO_PACKAGING_METADATA";
>  
> +      if (strcmp (name, "FDO") == 0 && type == NT_FDO_DLOPEN_METADATA)
> +	return "FDO_DLOPEN_METADATA";
> +
>        if (strcmp (name, "GNU") != 0)
>  	{
>  	  /* NT_VERSION is special, all data is in the name.  */
> diff --git a/libelf/elf.h b/libelf/elf.h
> index f2206e5c..bbf4565c 100644
> --- a/libelf/elf.h
> +++ b/libelf/elf.h
> @@ -1336,6 +1336,10 @@ typedef struct
>     https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
>  #define NT_FDO_PACKAGING_METADATA 0xcafe1a7e
>  
> +/* dlopen metadata as defined on
> +   https://systemd.io/ELF_DLOPEN_METADATA/ */
> +#define NT_FDO_DLOPEN_METADATA 0x407c0c0a
> +
>  /* Note section name of program property.   */
>  #define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
>  
> -- 
> 2.39.2
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note
  2024-05-14 21:18 ` Mark Wielaard
@ 2024-05-30 10:45   ` Luca Boccassi
  2024-05-31 12:36     ` Mark Wielaard
  0 siblings, 1 reply; 7+ messages in thread
From: Luca Boccassi @ 2024-05-30 10:45 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Tue, 14 May 2024 at 22:18, Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Luca,
>
> On Fri, May 10, 2024 at 10:58:02PM +0100, luca.boccassi@gmail.com wrote:
> > Note that the webpage in the comment is not published yet,
> > it will be next week when the next systemd RC is tagged.
> > The document can be viewed right now on github at:
> > https://github.com/systemd/systemd/blob/main/docs/ELF_DLOPEN_METADATA.md
> >
> > But the node ID and the string format are now fixed, even
> > if the content of the string might change, it will still be
> > a string.
>
> Not a fan of json, feels very un-ELF. But it is what it is. The patch
> looks OK. Could you let us know when the elf.h change is accepted in
> glibc, then we'll sync and integrate this.

Hi,

It is now merged in glibc in git:

https://sourceware.org/git/?p=glibc.git;a=commit;h=53f9d74322c831c76bc6cf6ed8941267e8749604

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note
  2024-05-30 10:45   ` Luca Boccassi
@ 2024-05-31 12:36     ` Mark Wielaard
  2024-05-31 12:36       ` [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
                         ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mark Wielaard @ 2024-05-31 12:36 UTC (permalink / raw)
  To: luca.boccassi; +Cc: elfutils-devel

Hi Luca,

On Thu, 2024-05-30 at 11:45 +0100, Luca Boccassi wrote:
> On Tue, 14 May 2024 at 22:18, Mark Wielaard <mark@klomp.org> wrote:
> > Not a fan of json, feels very un-ELF. But it is what it is. The patch
> > looks OK. Could you let us know when the elf.h change is accepted in
> > glibc, then we'll sync and integrate this.
>
> It is now merged in glibc in git:
> 
> https://sourceware.org/git/?p=glibc.git;a=commit;h=53f9d74322c831c76bc6cf6ed8941267e8749604

Thanks, I split your original patch in two, and reworded your commit
message now that the constant and URL are published and official.

 [PATCH 1/2] libelf: Sync elf.h from glibc
 [PATCH 2/2] readelf: add pretty printing for FDO Dlopen Metadata note

Thanks,

Mark

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] libelf: Sync elf.h from glibc
  2024-05-31 12:36     ` Mark Wielaard
@ 2024-05-31 12:36       ` Mark Wielaard
  2024-05-31 12:36       ` [PATCH 2/2] readelf: add pretty printing for FDO Dlopen Metadata note Mark Wielaard
  2024-05-31 12:43       ` [PATCH] " Luca Boccassi
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2024-05-31 12:36 UTC (permalink / raw)
  To: luca.boccassi; +Cc: elfutils-devel, Mark Wielaard

	* libelf/elf.h: Adds AT_HWCAP{3,4}, NT_FDO_DLOPEN_METADATA
	and R_LARCH_TLS_DESC{32,64}.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libelf/elf.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libelf/elf.h b/libelf/elf.h
index f2206e5c065d..081742a9c38c 100644
--- a/libelf/elf.h
+++ b/libelf/elf.h
@@ -1234,6 +1234,10 @@ typedef struct
 #define AT_RSEQ_FEATURE_SIZE	27	/* rseq supported feature size.  */
 #define AT_RSEQ_ALIGN	28		/* rseq allocation alignment.  */
 
+/* More machine-dependent hints about processor capabilities.  */
+#define AT_HWCAP3	29		/* extension of AT_HWCAP.  */
+#define AT_HWCAP4	30		/* extension of AT_HWCAP.  */
+
 #define AT_EXECFN	31		/* Filename of executable.  */
 
 /* Pointer to the global system page used for system calls and other
@@ -1333,9 +1337,13 @@ typedef struct
 #define NT_GNU_PROPERTY_TYPE_0 5
 
 /* Packaging metadata as defined on
-   https://systemd.io/COREDUMP_PACKAGE_METADATA/ */
+   https://systemd.io/ELF_PACKAGE_METADATA/ */
 #define NT_FDO_PACKAGING_METADATA 0xcafe1a7e
 
+/* dlopen metadata as defined on
+   https://systemd.io/ELF_DLOPEN_METADATA/ */
+#define NT_FDO_DLOPEN_METADATA 0x407c0c0a
+
 /* Note section name of program property.   */
 #define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property"
 
@@ -4237,6 +4245,8 @@ enum
 #define R_LARCH_TLS_TPREL32	10
 #define R_LARCH_TLS_TPREL64	11
 #define R_LARCH_IRELATIVE	12
+#define R_LARCH_TLS_DESC32	13
+#define R_LARCH_TLS_DESC64	14
 
 /* Reserved for future relocs that the dynamic linker must understand.  */
 
-- 
2.45.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/2] readelf: add pretty printing for FDO Dlopen Metadata note
  2024-05-31 12:36     ` Mark Wielaard
  2024-05-31 12:36       ` [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
@ 2024-05-31 12:36       ` Mark Wielaard
  2024-05-31 12:43       ` [PATCH] " Luca Boccassi
  2 siblings, 0 replies; 7+ messages in thread
From: Mark Wielaard @ 2024-05-31 12:36 UTC (permalink / raw)
  To: luca.boccassi; +Cc: elfutils-devel, Luca Boccassi

From: Luca Boccassi <bluca@debian.org>

The node ID and the string format are now fixed, even if the content
of the string might change, it will still be a string.

     * libebl/eblobjnote.c (ebl_object_note): Handle both type
     being NT_FDO_PACKAGING_METADATA or NT_FDO_DLOPEN_METADATA when
     name is "FDO".
     * libebl/eblobjnotetypename.c (ebl_object_note_type_name): Handle
     "FDO" name and type NT_FDO_DLOPEN_METADATA.

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
 libebl/eblobjnote.c         | 9 +++++++--
 libebl/eblobjnotetypename.c | 3 +++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index 1ba5d8b32354..ad3f49de3456 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -288,9 +288,14 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type,
       if (descsz == 0 && type == NT_VERSION)
 	return;
 
-      if (strcmp ("FDO", name) == 0 && type == NT_FDO_PACKAGING_METADATA
+      if (strcmp ("FDO", name) == 0
 	  && descsz > 0 && desc[descsz - 1] == '\0')
-	printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
+	{
+	  if (type == NT_FDO_PACKAGING_METADATA)
+	    printf("    Packaging Metadata: %.*s\n", (int) descsz, desc);
+	  else if (type == NT_FDO_DLOPEN_METADATA)
+	    printf("    Dlopen  Metadata: %.*s\n", (int) descsz, desc);
+	}
 
       /* Everything else should have the "GNU" owner name.  */
       if (strcmp ("GNU", name) != 0)
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 473a1f2f2fd4..79ff010a37d8 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -104,6 +104,9 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
       if (strcmp (name, "FDO") == 0 && type == NT_FDO_PACKAGING_METADATA)
 	return "FDO_PACKAGING_METADATA";
 
+      if (strcmp (name, "FDO") == 0 && type == NT_FDO_DLOPEN_METADATA)
+	return "FDO_DLOPEN_METADATA";
+
       if (strcmp (name, "GNU") != 0)
 	{
 	  /* NT_VERSION is special, all data is in the name.  */
-- 
2.45.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note
  2024-05-31 12:36     ` Mark Wielaard
  2024-05-31 12:36       ` [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
  2024-05-31 12:36       ` [PATCH 2/2] readelf: add pretty printing for FDO Dlopen Metadata note Mark Wielaard
@ 2024-05-31 12:43       ` Luca Boccassi
  2 siblings, 0 replies; 7+ messages in thread
From: Luca Boccassi @ 2024-05-31 12:43 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Fri, 31 May 2024 at 13:39, Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Luca,
>
> On Thu, 2024-05-30 at 11:45 +0100, Luca Boccassi wrote:
> > On Tue, 14 May 2024 at 22:18, Mark Wielaard <mark@klomp.org> wrote:
> > > Not a fan of json, feels very un-ELF. But it is what it is. The patch
> > > looks OK. Could you let us know when the elf.h change is accepted in
> > > glibc, then we'll sync and integrate this.
> >
> > It is now merged in glibc in git:
> >
> > https://sourceware.org/git/?p=glibc.git;a=commit;h=53f9d74322c831c76bc6cf6ed8941267e8749604
>
> Thanks, I split your original patch in two, and reworded your commit
> message now that the constant and URL are published and official.
>
>  [PATCH 1/2] libelf: Sync elf.h from glibc
>  [PATCH 2/2] readelf: add pretty printing for FDO Dlopen Metadata note

Thank you!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-05-31 12:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 21:58 [PATCH] readelf: add pretty printing for FDO Dlopen Metadata note luca.boccassi
2024-05-14 21:18 ` Mark Wielaard
2024-05-30 10:45   ` Luca Boccassi
2024-05-31 12:36     ` Mark Wielaard
2024-05-31 12:36       ` [PATCH 1/2] libelf: Sync elf.h from glibc Mark Wielaard
2024-05-31 12:36       ` [PATCH 2/2] readelf: add pretty printing for FDO Dlopen Metadata note Mark Wielaard
2024-05-31 12:43       ` [PATCH] " Luca Boccassi

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).