summaryrefslogtreecommitdiff
path: root/libebl
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-11-11 23:50:41 +0100
committerMark Wielaard <mark@klomp.org>2018-11-13 13:40:00 +0100
commit7a3f6fe60b8519b5372f5a5521ccbac59411f33f (patch)
tree48f21c4114d440e49483699a2dda27198b2f76d4 /libebl
parentcff53f1784c9a4344604bedf41b7d499b3eb30d5 (diff)
downloadelfutils-7a3f6fe60b8519b5372f5a5521ccbac59411f33f.tar.gz
Recognize NT_VERSION notes.
NT_VERSION notes are emitted by the gas .version directive. They have an empty description and (ab)use the owner name to store the version data string. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog9
-rw-r--r--libebl/eblobjnote.c10
-rw-r--r--libebl/eblobjnotetypename.c8
-rw-r--r--libebl/libebl.h4
4 files changed, 27 insertions, 4 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 120c84c0..076596f0 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,12 @@
+2018-11-11 Mark Wielaard <mark@klomp.org>
+
+ * eblobjnote.c (ebl_object_note): Recognize NT_VERSION with zero
+ descriptor. Add explicit "GNU" name check.
+ * eblobjnotetypename.c (ebl_object_note_type_name): Add extra
+ argument descsz. Recognize NT_VERSION using descsz. With "GNU"
+ name it is NT_GNU_ABI_TAG.
+ * libebl.h (ebl_object_note_type_name): Add extra argument descsz.
+
2018-10-18 Mark Wielaard <mark@klomp.org>
* eblobjnote.c (ebl_object_note): Handle NT_GNU_PROPERTY_TYPE_0.
diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index 57e9f52f..8fda7d99 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -135,6 +135,14 @@ ebl_object_note (Ebl *ebl, const char *name, uint32_t type,
return;
}
+ /* NT_VERSION doesn't have any info. All data is in the name. */
+ if (descsz == 0 && type == NT_VERSION)
+ return;
+
+ /* Everything else should have the "GNU" owner name. */
+ if (strcmp ("GNU", name) != 0)
+ return;
+
switch (type)
{
case NT_GNU_BUILD_ID:
@@ -337,7 +345,7 @@ ebl_object_note (Ebl *ebl, const char *name, uint32_t type,
break;
case NT_GNU_ABI_TAG:
- if (strcmp (name, "GNU") == 0 && descsz >= 8 && descsz % 4 == 0)
+ if (descsz >= 8 && descsz % 4 == 0)
{
Elf_Data in =
{
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index af23caea..8cdd7819 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -39,6 +39,7 @@
const char *
ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
+ GElf_Word descsz,
char *buf, size_t len)
{
const char *res = ebl->object_note_type_name (name, type, buf, len);
@@ -80,14 +81,19 @@ ebl_object_note_type_name (Ebl *ebl, const char *name, uint32_t type,
if (strcmp (name, "GNU") != 0)
{
+ /* NT_VERSION is special, all data is in the name. */
+ if (descsz == 0 && type == NT_VERSION)
+ return "VERSION";
+
snprintf (buf, len, "%s: %" PRIu32, gettext ("<unknown>"), type);
return buf;
}
+ /* And finally all the "GNU" note types. */
static const char *knowntypes[] =
{
#define KNOWNSTYPE(name) [NT_##name] = #name
- KNOWNSTYPE (VERSION),
+ KNOWNSTYPE (GNU_ABI_TAG),
KNOWNSTYPE (GNU_HWCAP),
KNOWNSTYPE (GNU_BUILD_ID),
KNOWNSTYPE (GNU_GOLD_VERSION),
diff --git a/libebl/libebl.h b/libebl/libebl.h
index a34fe48d..58306547 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -175,8 +175,8 @@ extern const char *ebl_core_note_type_name (Ebl *ebl, uint32_t type, char *buf,
/* Return name of the note section type for an object file. */
extern const char *ebl_object_note_type_name (Ebl *ebl, const char *name,
- uint32_t type, char *buf,
- size_t len);
+ uint32_t type, GElf_Word descsz,
+ char *buf, size_t len);
/* Print information about object note if available. */
extern void ebl_object_note (Ebl *ebl, const char *name, uint32_t type,