summaryrefslogtreecommitdiff
path: root/libebl
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2022-06-01 13:14:27 +0200
committerMark Wielaard <mark@klomp.org>2022-06-06 13:33:32 +0200
commit1daec75e0ff5313eec93b60f54fcb5ddc9d2ad28 (patch)
treec1c5e1eecc56c164179f00cf5c8876c68ea3561f /libebl
parentc1e2bff661d7b31ca507e5a69d7dd877e9f47c7f (diff)
downloadelfutils-1daec75e0ff5313eec93b60f54fcb5ddc9d2ad28.tar.gz
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 <mark@klomp.org>
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog10
-rw-r--r--libebl/ebl-hooks.h2
-rw-r--r--libebl/eblmachineflagname.c11
-rw-r--r--libebl/eblopenbackend.c5
4 files changed, 21 insertions, 7 deletions
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;
}