public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: binutils@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 5/7] binutils/readelf: handle NT_AMDGPU_METADATA note name
Date: Tue, 15 Mar 2022 15:43:01 -0400	[thread overview]
Message-ID: <20220315194303.3716792-6-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220315194303.3716792-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

Handle the NT_AMDGPU_METADATA note, which is described here:

  https://llvm.org/docs/AMDGPUUsage.html#code-object-v3-note-records

As of this patch, just print out the name, not the contents, which is in
the msgpack format.

binutils/ChangeLog:

	* readelf.c (get_amdgpu_elf_note_type): New.
	(process_note): Handle "AMDGPU" notes.

include/ChangeLog:

	* elf/amdgcn.h (NT_AMDGPU_METADATA): New.

Change-Id: Id2dba2e2aeaa55ef7464fb35aee9c7d5f96ddb23
---
 binutils/readelf.c   | 20 ++++++++++++++++++++
 include/elf/amdgpu.h |  4 ++++
 2 files changed, 24 insertions(+)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 00b5e546c1e7..91515bdf0faa 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -19724,6 +19724,22 @@ decode_x86_compat_2_isa (unsigned int bitmask)
     }
 }
 
+static const char *
+get_amdgpu_elf_note_type (unsigned int e_type)
+{
+  switch (e_type)
+    {
+    case NT_AMDGPU_METADATA:
+      return _("NT_AMDGPU_METADATA (code object metadata)");
+    default:
+      {
+	static char buf[64];
+	snprintf (buf, sizeof (buf), _("Unknown note type: (0x%08x)"), e_type);
+	return buf;
+      }
+    }
+}
+
 static void
 decode_x86_isa (unsigned int bitmask)
 {
@@ -21313,6 +21329,10 @@ process_note (Elf_Internal_Note *  pnote,
     /* GNU-specific object file notes.  */
     nt = get_gnu_elf_note_type (pnote->type);
 
+  else if (startswith (pnote->namedata, "AMDGPU"))
+    /* AMDGPU-specific object file notes.  */
+    nt = get_amdgpu_elf_note_type (pnote->type);
+
   else if (startswith (pnote->namedata, "FreeBSD"))
     /* FreeBSD-specific core file notes.  */
     nt = get_freebsd_elfcore_note_type (filedata, pnote->type);
diff --git a/include/elf/amdgpu.h b/include/elf/amdgpu.h
index 005064fc264e..e3c90dc74e85 100644
--- a/include/elf/amdgpu.h
+++ b/include/elf/amdgpu.h
@@ -87,4 +87,8 @@
 #define EF_AMDGPU_FEATURE_SRAMECC_OFF_V4         0x800
 #define EF_AMDGPU_FEATURE_SRAMECC_ON_V4          0xc00
 
+/* Notes. */
+
+#define NT_AMDGPU_METADATA                32
+
 #endif /* _ELF_AMDGPU_H */
-- 
2.35.1


  parent reply	other threads:[~2022-03-15 19:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 19:42 [PATCH 0/7] Add AMDGCN support to readelf Simon Marchi
2022-03-15 19:42 ` [PATCH 1/7] bfd: add AMDGCN architecture Simon Marchi
2022-03-15 19:42 ` [PATCH 2/7] opcodes: handle bfd_amdgcn_arch in configure script Simon Marchi
2022-03-15 19:42 ` [PATCH 3/7] binutils/readelf: handle AMDGPU OS ABIs Simon Marchi
2022-03-15 19:43 ` [PATCH 4/7] binutils/readelf: decode AMDGPU-specific e_flags Simon Marchi
2022-03-15 19:43 ` Simon Marchi [this message]
2022-03-15 19:43 ` [PATCH 6/7] binutils/readelf: build against msgpack, dump NT_AMDGPU_METADATA note contents Simon Marchi
2022-03-15 19:43 ` [PATCH 7/7] binutils/readelf: handle AMDGPU relocation types Simon Marchi
2022-03-16  0:08 ` [PATCH 0/7] Add AMDGCN support to readelf Alan Modra
2022-03-16 13:02   ` Simon Marchi

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=20220315194303.3716792-6-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=binutils@sourceware.org \
    --cc=simon.marchi@efficios.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).