diff options
author | Mark Wielaard <mark@klomp.org> | 2018-11-11 23:50:41 +0100 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2018-11-13 13:40:00 +0100 |
commit | 7a3f6fe60b8519b5372f5a5521ccbac59411f33f (patch) | |
tree | 48f21c4114d440e49483699a2dda27198b2f76d4 /src | |
parent | cff53f1784c9a4344604bedf41b7d499b3eb30d5 (diff) |
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 'src')
-rw-r--r-- | src/ChangeLog | 7 | ||||
-rw-r--r-- | src/elflint.c | 27 | ||||
-rw-r--r-- | src/readelf.c | 1 |
3 files changed, 29 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f1a35798..0ed86bbf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2018-11-11 Mark Wielaard <mark@klomp.org> + + * readelf.c (handle_notes_data): Pass n_descsz to + ebl_object_note_type_name. + * elflint.c (check_note_data): Recognize NT_VERSION, add owner + name to unknown note error. + 2018-10-20 Mark Wielaard <mark@klomp.org> * readelf.c (process_elf_file): Use dwelf_elf_begin to open pure_elf. diff --git a/src/elflint.c b/src/elflint.c index fa3af4c5..dff74eee 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -1,5 +1,5 @@ /* Pedantic checking of ELF files compliance with gABI/psABI spec. - Copyright (C) 2001-2015, 2017 Red Hat, Inc. + Copyright (C) 2001-2015, 2017, 2018 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2001. @@ -4332,7 +4332,17 @@ section [%2d] '%s': unknown core file note type %" PRIu32 case NT_GNU_BUILD_ID: case NT_GNU_GOLD_VERSION: case NT_GNU_PROPERTY_TYPE_0: - break; + if (nhdr.n_namesz == sizeof ELF_NOTE_GNU + && strcmp (data->d_buf + name_offset, ELF_NOTE_GNU) == 0) + break; + else + { + /* NT_VERSION is 1, same as NT_GNU_ABI_TAG. It has no + descriptor and (ab)uses the name as version string. */ + if (nhdr.n_descsz == 0 && nhdr.n_type == NT_VERSION) + break; + } + goto unknown_note; case 0: /* Linux vDSOs use a type 0 note for the kernel version word. */ @@ -4341,16 +4351,21 @@ section [%2d] '%s': unknown core file note type %" PRIu32 break; FALLTHROUGH; default: + { + unknown_note: if (shndx == 0) ERROR (gettext ("\ -phdr[%d]: unknown object file note type %" PRIu32 " at offset %zu\n"), - phndx, (uint32_t) nhdr.n_type, offset); +phdr[%d]: unknown object file note type %" PRIu32 " with owner name '%s' at offset %zu\n"), + phndx, (uint32_t) nhdr.n_type, + (char *) data->d_buf + name_offset, offset); else ERROR (gettext ("\ section [%2d] '%s': unknown object file note type %" PRIu32 - " at offset %zu\n"), + " with owner name '%s' at offset %zu\n"), shndx, section_name (ebl, shndx), - (uint32_t) nhdr.n_type, offset); + (uint32_t) nhdr.n_type, + (char *) data->d_buf + name_offset, offset); + } } } diff --git a/src/readelf.c b/src/readelf.c index c6c3fb32..659e34fb 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -12201,6 +12201,7 @@ handle_notes_data (Ebl *ebl, const GElf_Ehdr *ehdr, ? ebl_core_note_type_name (ebl, nhdr.n_type, buf, sizeof (buf)) : ebl_object_note_type_name (ebl, name, nhdr.n_type, + nhdr.n_descsz, buf2, sizeof (buf2))); /* Filter out invalid entries. */ |