diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2022-03-16 09:01:36 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2022-03-16 09:01:43 -0400 |
commit | 2952f10cd79af4645222f124f28c7928287d8113 (patch) | |
tree | df776596c24ec839cad957eebb14c4bd1b2c3b8c /binutils/configure | |
parent | 28cdbb183bf80157a71d222b66abc38f32019f2d (diff) | |
download | gdb-2952f10cd79af4645222f124f28c7928287d8113.zip gdb-2952f10cd79af4645222f124f28c7928287d8113.tar.gz gdb-2952f10cd79af4645222f124f28c7928287d8113.tar.bz2 |
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/configure')
-rwxr-xr-x | binutils/configure | 137 |
1 files changed, 134 insertions, 3 deletions
diff --git a/binutils/configure b/binutils/configure index 19d82ba..f3ad831 100755 --- a/binutils/configure +++ b/binutils/configure @@ -648,6 +648,8 @@ BUILD_DLLTOOL BUILD_SRCONV LTLIBICONV LIBICONV +MSGPACK_LIBS +MSGPACK_CFLAGS zlibinc zlibdir DEMANGLER_NAME @@ -830,6 +832,7 @@ enable_build_warnings enable_nls enable_maintainer_mode with_system_zlib +with_msgpack enable_rpath with_libiconv_prefix with_libiconv_type @@ -849,7 +852,9 @@ PKG_CONFIG_LIBDIR DEBUGINFOD_CFLAGS DEBUGINFOD_LIBS YACC -YFLAGS' +YFLAGS +MSGPACK_CFLAGS +MSGPACK_LIBS' # Initialize some variables set by options. @@ -1512,6 +1517,7 @@ Optional Packages: --with-debuginfod Enable debuginfo lookups with debuginfod (auto/yes/no) --with-system-zlib use installed libz + --with-msgpack Enable msgpack support (auto/yes/no) --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir @@ -1541,6 +1547,10 @@ Some influential environment variables: YFLAGS The list of arguments that will be passed by default to $YACC. This script will default YFLAGS to the empty string to avoid a default value of `-d' given by some make applications. + MSGPACK_CFLAGS + C compiler flags for MSGPACK, overriding pkg-config + MSGPACK_LIBS + linker flags for MSGPACK, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -10971,7 +10981,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10974 "configure" +#line 10984 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11077,7 +11087,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11080 "configure" +#line 11090 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13723,6 +13733,127 @@ $as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h ;; esac +# Support for the msgpack C library. + +# Check whether --with-msgpack was given. +if test "${with_msgpack+set}" = set; then : + withval=$with_msgpack; +else + with_msgpack=auto +fi + + + +if test "$with_msgpack" != no; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for msgpack" >&5 +$as_echo_n "checking for msgpack... " >&6; } + +if test -n "$MSGPACK_CFLAGS"; then + pkg_cv_MSGPACK_CFLAGS="$MSGPACK_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"msgpack\""; } >&5 + ($PKG_CONFIG --exists --print-errors "msgpack") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_MSGPACK_CFLAGS=`$PKG_CONFIG --cflags "msgpack" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$MSGPACK_LIBS"; then + pkg_cv_MSGPACK_LIBS="$MSGPACK_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"msgpack\""; } >&5 + ($PKG_CONFIG --exists --print-errors "msgpack") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_MSGPACK_LIBS=`$PKG_CONFIG --libs "msgpack" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + +if test $pkg_failed = no; then + pkg_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $pkg_cv_MSGPACK_LIBS" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + +else + pkg_failed=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LDFLAGS=$pkg_save_LDFLAGS +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + MSGPACK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "msgpack" 2>&1` + else + MSGPACK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "msgpack" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$MSGPACK_PKG_ERRORS" >&5 + + + if test "$with_msgpack" = yes; then + as_fn_error $? "--with-msgpack was given, but msgpack is missing or unusable." "$LINENO" 5 + fi + +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + + if test "$with_msgpack" = yes; then + as_fn_error $? "--with-msgpack was given, but msgpack is missing or unusable." "$LINENO" 5 + fi + +else + MSGPACK_CFLAGS=$pkg_cv_MSGPACK_CFLAGS + MSGPACK_LIBS=$pkg_cv_MSGPACK_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + +$as_echo "#define HAVE_MSGPACK 1" >>confdefs.h + + +fi +fi + # target-specific stuff: # Canonicalize the secondary target names. |