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 3/7] binutils/readelf: handle AMDGPU OS ABIs
Date: Tue, 15 Mar 2022 15:42:59 -0400	[thread overview]
Message-ID: <20220315194303.3716792-4-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20220315194303.3716792-1-simon.marchi@polymtl.ca>

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

When the machine is EM_AMDGPU, handle the various OS ABIs described
here:

  https://llvm.org/docs/AMDGPUUsage.html#header

For a binary with the HSA OS ABI, the change looks like:

-  OS/ABI:                            <unknown: 40>
+  OS/ABI:                            AMD HSA

binutils/ChangeLog:

	* readelf.c (get_osabi_name): Handle EM_AMDGPU OS ABIs.

include/ChangeLog:

	* elf/common.h (ELFOSABI_AMDGPU_PAL, ELFOSABI_AMDGPU_MESA3D):
	New.

Change-Id: I383590c390f7dc2fe0f902f50038735626d71863
---
 binutils/readelf.c   | 11 +++++++++++
 include/elf/common.h |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 8b46052c7ded..e8974aacec5e 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -4284,6 +4284,17 @@ get_osabi_name (Filedata * filedata, unsigned int osabi)
       if (osabi >= 64)
 	switch (filedata->file_header.e_machine)
 	  {
+	  case EM_AMDGPU:
+	    switch (osabi)
+	      {
+	      case ELFOSABI_AMDGPU_HSA:    return "AMD HSA";
+	      case ELFOSABI_AMDGPU_PAL:    return "AMD PAL";
+	      case ELFOSABI_AMDGPU_MESA3D: return "AMD Mesa3D";
+	      default:
+		break;
+	      }
+	    break;
+
 	  case EM_ARM:
 	    switch (osabi)
 	      {
diff --git a/include/elf/common.h b/include/elf/common.h
index a1cace406a47..70d63e3299c0 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -79,7 +79,9 @@
 #define ELFOSABI_C6000_ELFABI 64 /* Bare-metal TMS320C6000 */
 #define ELFOSABI_AMDGPU_HSA  64 /* AMD HSA Runtime */
 #define ELFOSABI_C6000_LINUX 65 /* Linux TMS320C6000 */
+#define ELFOSABI_AMDGPU_PAL  65 /* AMD PAL Runtime */
 #define ELFOSABI_ARM_FDPIC   65 /* ARM FDPIC */
+#define ELFOSABI_AMDGPU_MESA3D 66 /* AMD Mesa3D Runtime */
 #define ELFOSABI_ARM	     97	/* ARM */
 #define ELFOSABI_STANDALONE 255	/* Standalone (embedded) application */
 
-- 
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 ` Simon Marchi [this message]
2022-03-15 19:43 ` [PATCH 4/7] binutils/readelf: decode AMDGPU-specific e_flags Simon Marchi
2022-03-15 19:43 ` [PATCH 5/7] binutils/readelf: handle NT_AMDGPU_METADATA note name Simon Marchi
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-4-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).