summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--libebl/ChangeLog10
-rw-r--r--libebl/ebl-hooks.h2
-rw-r--r--libebl/eblmachineflagname.c11
-rw-r--r--libebl/eblopenbackend.c5
-rw-r--r--tests/ChangeLog7
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/run-readelf-arm-flags.sh30
-rwxr-xr-xtests/testfile-arm-flags.bz2bin0 -> 2593 bytes
12 files changed, 225 insertions, 8 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 <drepper@redhat.com>
+
+ * 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 <mark@klomp.org>
* 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;
+}
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 2e31e75d..52b9c609 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,13 @@
+2022-06-01 Ulrich Drepper <drepper@redhat.com>
+
+ * eblopenbackend.c (default_machine_flag_name): Add original flag
+ as first parameter.
+ * ebl-hooks.h (machine_flag_name): Ditto.
+ * eblmachineflagname.c (ebl_machine_flag_name): Modernize, use bool
+ for first. Pass original flag value to machine_flag_name
+ callback as well. Add space after comma in printed list.
+ Fix appending strings provided by callback.
+
2021-12-21 Luca Boccassi <bluca@debian.org>
* eblobjnote.c (ebl_object_note): Handle NT_FDO_PACKAGING_METADATA.
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index 1214bb84..d6437e53 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -51,7 +51,7 @@ const char *EBLHOOK(section_type_name) (int, char *, size_t);
const char *EBLHOOK(section_name) (int, int, char *, size_t);
/* Return next machine flag name. */
-const char *EBLHOOK(machine_flag_name) (GElf_Word *);
+const char *EBLHOOK(machine_flag_name) (GElf_Word, GElf_Word *);
/* Check whether machine flags are valid. */
bool EBLHOOK(machine_flag_check) (GElf_Word);
diff --git a/libebl/eblmachineflagname.c b/libebl/eblmachineflagname.c
index 5f440776..02e11c65 100644
--- a/libebl/eblmachineflagname.c
+++ b/libebl/eblmachineflagname.c
@@ -46,8 +46,9 @@ ebl_machine_flag_name (Ebl *ebl, Elf64_Word flags, char *buf, size_t len)
res = "";
else
{
+ Elf64_Word orig_flags = flags;
char *cp = buf;
- int first = 1;
+ bool first = true;
const char *machstr;
size_t machstrlen;
@@ -55,12 +56,13 @@ ebl_machine_flag_name (Ebl *ebl, Elf64_Word flags, char *buf, size_t len)
{
if (! first)
{
- if (cp + 1 >= buf + len)
+ if (cp + 2 >= buf + len)
break;
*cp++ = ',';
+ *cp++ = ' ';
}
- machstr = ebl != NULL ? ebl->machine_flag_name (&flags) : NULL;
+ machstr = ebl != NULL ? ebl->machine_flag_name (orig_flags, &flags) : NULL;
if (machstr == NULL)
{
/* No more known flag. */
@@ -76,8 +78,9 @@ ebl_machine_flag_name (Ebl *ebl, Elf64_Word flags, char *buf, size_t len)
}
cp = mempcpy (cp, machstr, machstrlen);
+ --cp;
- first = 0;
+ first = false;
}
while (flags != 0);
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 0c07296c..c6657252 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -169,7 +169,7 @@ static const char *default_section_type_name (int ignore, char *buf,
size_t len);
static const char *default_section_name (int ignore, int ignore2, char *buf,
size_t len);
-static const char *default_machine_flag_name (Elf64_Word *ignore);
+static const char *default_machine_flag_name (Elf64_Word orig, Elf64_Word *ignore);
static bool default_machine_flag_check (Elf64_Word flags);
static bool default_machine_section_flag_check (GElf_Xword flags);
static const char *default_symbol_type_name (int ignore, char *buf,
@@ -450,7 +450,8 @@ default_section_name (int ignore __attribute__ ((unused)),
}
static const char *
-default_machine_flag_name (Elf64_Word *ignore __attribute__ ((unused)))
+default_machine_flag_name (Elf64_Word orig __attribute__ ((unused)),
+ Elf64_Word *ignore __attribute__ ((unused)))
{
return NULL;
}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 6ea8e792..e65ea09b 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,10 @@
+2022-06-01 Mark Wielaard <mark@klomp.org>
+
+ * testfile-arm-flags.bz2: New test file.
+ * run-readelf-arm-flags.sh: New test.
+ * Makefile.am (TESTS): Add run-readelf-arm-flags.sh.
+ (EXTRA_DIST): Add readelf-arm-flags.sh and testfile-arm-flags.bz2
+
2022-05-13 Noah Sanci <nsanci@redhat.com>
* run-debuginfod-fd-prefetch-caches.sh: Rewritten.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d30b07c4..07851594 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -164,6 +164,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \
run-backtrace-core-aarch64.sh run-backtrace-core-sparc.sh \
run-backtrace-demangle.sh run-stack-d-test.sh run-stack-i-test.sh \
run-stack-demangled-test.sh run-readelf-zx.sh run-readelf-zp.sh \
+ run-readelf-arm-flags.sh \
run-readelf-addr.sh run-readelf-str.sh \
run-readelf-multi-noline.sh \
run-readelf-types.sh \
@@ -347,6 +348,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \
run-readelf-dwz-multi.sh libtestfile_multi_shared.so.bz2 \
testfile_multi.dwz.bz2 testfile_multi_main.bz2 \
testfile-dwzstr.bz2 testfile-dwzstr.multi.bz2 \
+ run-readelf-arm-flags.sh testfile-arm-flags.bz2 \
run-readelf-addr.sh run-readelf-str.sh \
run-readelf-multi-noline.sh testfile_multi_noline.bz2 \
run-readelf-types.sh \
diff --git a/tests/run-readelf-arm-flags.sh b/tests/run-readelf-arm-flags.sh
new file mode 100755
index 00000000..25c5477d
--- /dev/null
+++ b/tests/run-readelf-arm-flags.sh
@@ -0,0 +1,30 @@
+#! /bin/sh
+
+. $srcdir/test-subr.sh
+
+# echo "int main () {}" | gcc -xc -o testfile-arm-flags -
+testfiles testfile-arm-flags
+
+testrun_compare ${abs_top_builddir}/src/readelf -h testfile-arm-flags <<\EOF
+ELF Header:
+ Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
+ Class: ELF32
+ Data: 2's complement, little endian
+ Ident Version: 1 (current)
+ OS/ABI: UNIX - System V
+ ABI Version: 0
+ Type: DYN (Shared object file)
+ Machine: ARM
+ Version: 1 (current)
+ Entry point address: 0x3d1
+ Start of program headers: 52 (bytes into file)
+ Start of section headers: 6920 (bytes into file)
+ Flags: Version5 EABI, hard-float ABI
+ Size of this header: 52 (bytes)
+ Size of program header entries: 32 (bytes)
+ Number of program headers entries: 9
+ Size of section header entries: 40 (bytes)
+ Number of section headers entries: 29
+ Section header string table index: 28
+
+EOF
diff --git a/tests/testfile-arm-flags.bz2 b/tests/testfile-arm-flags.bz2
new file mode 100755
index 00000000..d1b018ad
--- /dev/null
+++ b/tests/testfile-arm-flags.bz2
Binary files differ