summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2022-06-01 13:14:27 +0200
committerMark Wielaard <[email protected]>2022-06-06 13:33:32 +0200
commit1daec75e0ff5313eec93b60f54fcb5ddc9d2ad28 (patch)
treec1c5e1eecc56c164179f00cf5c8876c68ea3561f /backends
parentc1e2bff661d7b31ca507e5a69d7dd877e9f47c7f (diff)
Arm Ehdr flag printing
Arm needs to decode flags and I modeled it after the binutils code. The same messages are printed. Given the requirement of the interface and the ABIs the current version of the callback function isn't sufficient unless one wants to create a stateful interface. The problem is that most flags need to be interpreted in the context of the ABI version. So I changed the API to also pass the original flag value. This shouldn't be a problem because there are no users yet. There is also a bug in ebl_machine_flag_name. When copying the string provided by the callback cp is moved past the NUL byte. It should move to the NUL byte. Otherwise one cannot anything but the first added flag description. Finally some cosmetic changes (space after each comma in the output). Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'backends')
-rw-r--r--backends/ChangeLog6
-rw-r--r--backends/Makefile.am3
-rw-r--r--backends/arm_init.c1
-rw-r--r--backends/arm_machineflagname.c156
4 files changed, 165 insertions, 1 deletions
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 51959259..495cdde4 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2022-06-01 Ulrich Drepper <[email protected]>
+
+ * Makefile.am (arm_SRCS): Add arm_machineflagname.c.
+ * arm_init.c (arm_init): Hook in arm_machine_flag_name.
+ * arm_machineflagname.c: New file.
+
2022-02-16 Mark Wielaard <[email protected]>
* ppc_initreg.c (ppc_set_initial_registers_tid): Define struct
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 62916c9c..9566377f 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -56,7 +56,8 @@ alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c alpha_regs.c \
alpha_corenote.c alpha_auxv.c
arm_SRCS = arm_init.c arm_symbol.c arm_regs.c arm_corenote.c \
- arm_auxv.c arm_attrs.c arm_retval.c arm_cfi.c arm_initreg.c
+ arm_auxv.c arm_attrs.c arm_retval.c arm_cfi.c arm_initreg.c \
+ arm_machineflagname.c
aarch64_SRCS = aarch64_init.c aarch64_regs.c aarch64_symbol.c \
aarch64_corenote.c aarch64_retval.c aarch64_cfi.c \
diff --git a/backends/arm_init.c b/backends/arm_init.c
index edd53b75..70b75942 100644
--- a/backends/arm_init.c
+++ b/backends/arm_init.c
@@ -59,6 +59,7 @@ arm_init (Elf *elf __attribute__ ((unused)),
HOOK (eh, check_reloc_target_type);
HOOK (eh, symbol_type_name);
HOOK (eh, data_marker_symbol);
+ HOOK (eh, machine_flag_name);
/* We only unwind the core integer registers. */
eh->frame_nregs = 16;
diff --git a/backends/arm_machineflagname.c b/backends/arm_machineflagname.c
new file mode 100644
index 00000000..e93092ae
--- /dev/null
+++ b/backends/arm_machineflagname.c
@@ -0,0 +1,156 @@
+/* Arm-specific ELF flag names.
+ Copyright (C) 2022 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define BACKEND arm_
+#include "libebl_CPU.h"
+
+const char *
+arm_machine_flag_name (Elf64_Word orig, Elf64_Word *flagref)
+{
+ unsigned version = EF_ARM_EABI_VERSION (*flagref) >> 24;
+ if (version != 0)
+ {
+ static const char vername[5][14] =
+ {
+ "Version1 EABI",
+ "Version2 EABI",
+ "Version3 EABI",
+ "Version4 EABI",
+ "Version5 EABI",
+ };
+ *flagref &= ~((Elf64_Word) EF_ARM_EABIMASK);
+ return vername[version - 1];
+ }
+ switch (EF_ARM_EABI_VERSION (orig))
+ {
+ case EF_ARM_EABI_VER2:
+ if ((*flagref & EF_ARM_DYNSYMSUSESEGIDX) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_DYNSYMSUSESEGIDX);
+ return "dynamic symbols use segment index";
+ }
+ if ((*flagref & EF_ARM_MAPSYMSFIRST) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_MAPSYMSFIRST);
+ return "mapping symbols precede others";
+ }
+ FALLTHROUGH;
+ case EF_ARM_EABI_VER1:
+ if ((*flagref & EF_ARM_SYMSARESORTED) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_SYMSARESORTED);
+ return "sorted symbol tables";
+ }
+ break;
+ case EF_ARM_EABI_VER3:
+ break;
+ case EF_ARM_EABI_VER5:
+ if ((*flagref & EF_ARM_SOFT_FLOAT) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_SOFT_FLOAT);
+ return "soft-float ABI";
+ }
+ if ((*flagref & EF_ARM_VFP_FLOAT) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_VFP_FLOAT);
+ return "hard-float ABI";
+ }
+ FALLTHROUGH;
+ case EF_ARM_EABI_VER4:
+ if ((*flagref & EF_ARM_BE8) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_BE8);
+ return "BE8";
+ }
+ if ((*flagref & EF_ARM_LE8) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_LE8);
+ return "LE8";
+ }
+ break;
+ case EF_ARM_EABI_UNKNOWN:
+ if ((*flagref & EF_ARM_INTERWORK) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_INTERWORK);
+ return "interworking enabled";
+ }
+ if ((*flagref & EF_ARM_APCS_26) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_APCS_26);
+ return "uses APCS/26";
+ }
+ if ((*flagref & EF_ARM_APCS_FLOAT) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_APCS_FLOAT);
+ return "uses APCS/float";
+ }
+ if ((*flagref & EF_ARM_PIC) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_PIC);
+ return "position independent";
+ }
+ if ((*flagref & EF_ARM_ALIGN8) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_ALIGN8);
+ return "8 bit structure alignment";
+ }
+ if ((*flagref & EF_ARM_NEW_ABI) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_NEW_ABI);
+ return "uses new ABI";
+ }
+ if ((*flagref & EF_ARM_OLD_ABI) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_OLD_ABI);
+ return "uses old ABI";
+ }
+ if ((*flagref & EF_ARM_SOFT_FLOAT) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_SOFT_FLOAT);
+ return "software FP";
+ }
+ if ((*flagref & EF_ARM_VFP_FLOAT) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_VFP_FLOAT);
+ return "VFP";
+ }
+ if ((*flagref & EF_ARM_MAVERICK_FLOAT) != 0)
+ {
+ *flagref &= ~((Elf64_Word) EF_ARM_MAVERICK_FLOAT);
+ return "Maverick FP";
+ }
+ break;
+ default:
+ break;
+ }
+ return NULL;
+}