diff options
author | 2022-03-16 09:01:36 -0400 | |
---|---|---|
committer | 2022-03-16 09:01:43 -0400 | |
commit | 2952f10cd79af4645222f124f28c7928287d8113 (patch) | |
tree | df776596c24ec839cad957eebb14c4bd1b2c3b8c /binutils/Makefile.in | |
parent | binutils/readelf: handle NT_AMDGPU_METADATA note name (diff) | |
download | binutils-gdb-2952f10cd79af4645222f124f28c7928287d8113.tar.gz binutils-gdb-2952f10cd79af4645222f124f28c7928287d8113.tar.bz2 binutils-gdb-2952f10cd79af4645222f124f28c7928287d8113.zip |
binutils/readelf: build against msgpack, dump NT_AMDGPU_METADATA note contents
The AMDGPU HSA OS ABI (code object v3 and above) defines the
NT_AMDGPU_METADATA ELF note [1]. The content is a msgpack object
describing, among other things, the kernels present in the code object
and how to call them.
I think it would be useful for readelf to be able to display the content
of those notes. msgpack is a structured format, a bit like JSON, except
not text-based. It is therefore possible to dump the contents in
human-readable form without knowledge of the specific layout of the
note.
Add configury to binutils to optionally check for the msgpack C library
[2]. Add There is a new --with{,out}-msgpack configure flag, and the actual
library lookup is done using pkg-config.
If msgpack support is enabled, dumping a NT_AMDGPU_METADATA note looks
like:
$ readelf --notes amdgpu-code-object
Displaying notes found in: .note
Owner Data size Description
AMDGPU 0x0000040d NT_AMDGPU_METADATA (code object metadata)
{
"amdhsa.kernels": [
{
".args": [
{
".address_space": "global",
".name": "out.coerce",
".offset": 0,
".size": 8,
".value_kind": "global_buffer",
},
<snip>
If msgpack support is disabled, dump the contents as hex, as is done
with notes that are not handled in a special way. This allows one to
decode the contents manually (maybe using a command-line msgpack
decoder) if really needed.
[1] https://llvm.org/docs/AMDGPUUsage.html#code-object-metadata
[2] https://github.com/msgpack/msgpack-c/tree/c_master
binutils/ChangeLog:
* Makefile.am (readelf_CFLAGS): New.
(readelf_LDADD): Add MSGPACK_LIBS.
* Makefile.in: Re-generate.
* config.in: Re-generate.
* configure: Re-generate.
* configure.ac: Add --with-msgpack flag and check for msgpack
using pkg-config.
* readelf.c: Include msgpack.h if HAVE_MSGPACK.
(print_note_contents_hex): New.
(print_indents): New.
(dump_msgpack_obj): New.
(dump_msgpack): New.
(print_amdgpu_note): New.
(process_note): Handle NT_AMDGPU_METADATA note contents.
Use print_note_contents_hex.
Change-Id: Ia60a654e620bc32dfdb1bccd845594e2af328b84
Diffstat (limited to 'binutils/Makefile.in')
-rw-r--r-- | binutils/Makefile.in | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/binutils/Makefile.in b/binutils/Makefile.in index 87f78628380..78d32b350e3 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -537,6 +537,8 @@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGMERGE = @MSGMERGE@ +MSGPACK_CFLAGS = @MSGPACK_CFLAGS@ +MSGPACK_LIBS = @MSGPACK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ NO_WERROR = @NO_WERROR@ @@ -785,7 +787,7 @@ size_SOURCES = size.c $(BULIBS) objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) strings_SOURCES = strings.c $(BULIBS) readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c demanguse.c $(ELFLIBS) -readelf_LDADD = $(LIBCTF_NOBFD) $(LIBINTL) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS) +readelf_LDADD = $(LIBCTF_NOBFD) $(LIBINTL) $(LIBIBERTY) $(ZLIB) $(DEBUGINFOD_LIBS) $(MSGPACK_LIBS) elfedit_SOURCES = elfedit.c version.c $(ELFLIBS) elfedit_LDADD = $(LIBINTL) $(LIBIBERTY) strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) @@ -1919,6 +1921,13 @@ dwarf.@OBJEXT@: dwarf.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC)$(COMPILE) $(DEBUGINFOD_CFLAGS) -c -o $@ $(srcdir)/dwarf.c +readelf.@OBJEXT@: readelf.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo $(MSGPACK_CFLAGS) -c -o $@ $(srcdir)/readelf.c +@am__fastdepCC_TRUE@ $(AM_V_at)mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='readelf.c' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC)$(COMPILE) $(MSGPACK_CFLAGS) -c -o $@ $(srcdir)/readelf.c + sysroff.@OBJEXT@: sysroff.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `test -f sysroff.c || echo $(srcdir)/`sysroff.c $(NO_WERROR) @am__fastdepCC_TRUE@ $(AM_V_at)mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |