Detect the presence of R_AARCH64_{ABS64, PREL32} macros
authorDodji Seketeli <dodji@redhat.com>
Wed, 18 Sep 2019 07:16:27 +0000 (09:16 +0200)
committerDodji Seketeli <dodji@redhat.com>
Wed, 18 Sep 2019 07:16:27 +0000 (09:16 +0200)
The patch:

 "e687032 Support pre and post v4.19 ksymtabs for Linux kernel modules"

introduces the use of the R_AARCH64_{ABS64, PREL32} macros.  However,
some older "elf.h" don't define these.  When compiling on these older
platforms, we thus need to avoid using these new macros.

With this patch, the configure system detects the presence of these
macros and defines the HAVE_R_AARCH64_{ABS64, PREL32}_MACRO macros
accordingly.

Note that just to comply with what's in there in the code already, we
don't directly do "#ifdef R_AARCH64_ABS64", but rather "#ifdef
HAVE_R_AARCH64_ABS64_MACRO", to allow cases where we want to
artificially disable the "feature" at configure time, in the future.

* configure.ac: Define macros HAVE_R_AARCH64_{ABS64, PREL32}_MACRO
if the macros R_AARCH64_{ABS64, PREL32} are present.
* src/abg-dwarf-reader.cc
(read_context::get_ksymtab_format_module): Conditionalize the use
of R_AARCH64_{ABS64, PREL32} using HAVE_R_AARCH64_{ABS64, PREL32}_MACRO.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
configure.ac
src/abg-dwarf-reader.cc

index 44e951f..842dcfc 100644 (file)
@@ -646,6 +646,30 @@ if test x$HAS_EM_TILEGX = xyes; then
             [Defined to 1 if elf.h has EM_TILEGX macro defined])
 fi
 
+HAS_R_AARCH64_ABS64=no
+AC_CHECK_DECL([R_AARCH64_ABS64],
+             [HAS_R_AARCH64_ABS64=yes],
+             [HAS_R_AARCH64_ABS64=no],
+             [[#include <elf.h>]])
+
+if test x$HAS_R_AARCH64_ABS64 = xyes; then
+   AC_DEFINE([HAVE_R_AARCH64_ABS64_MACRO],
+            1,
+            [Defined to 1 if elf.h has R_AARCH64_ABS64 macro defined])
+fi
+
+HAS_R_AARCH64_PREL32=no
+AC_CHECK_DECL([R_AARCH64_PREL32],
+             [HAS_R_AARCH64_PREL32=yes],
+             [HAS_R_AARCH64_PREL32=no],
+             [[#include <elf.h>]])
+
+if test x$HAS_R_AARCH64_PREL32 = xyes; then
+   AC_DEFINE([HAVE_R_AARCH64_PREL32_MACRO],
+            1,
+            [Defined to 1 if elf.h has R_AARCH64_PREL32 macro defined])
+fi
+
 HAS_DW_LANG_UPC=no
 AC_CHECK_DECL([DW_LANG_UPC],
              [HAS_DW_LANG_UPC=yes],
index 0349eee..6af5fbc 100644 (file)
@@ -7646,11 +7646,15 @@ public:
     switch (type)
       {
       case R_X86_64_64: // Same as R_386_32, fallthrough
+#ifdef HAVE_R_AARCH64_ABS64_MACRO
       case R_AARCH64_ABS64:
+#endif
        format = PRE_V4_19_KSYMTAB_FORMAT;
        break;
       case R_X86_64_PC32: // Same as R_386_PC32, fallthrough
+#ifdef HAVE_R_AARCH64_PREL32_MACRO
       case R_AARCH64_PREL32:
+#endif
        format = V4_19_KSYMTAB_FORMAT;
        break;
       default: