diff options
author | Mark Wielaard <mark@klomp.org> | 2019-08-12 00:43:22 +0200 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2019-08-13 12:16:18 +0200 |
commit | 7ea82243ec3e556518116c51b528c3a4eb6d16f3 (patch) | |
tree | 3b5b4b83db7c1c248cabb934e77166a99c1c0e5b /libdw | |
parent | d37f6ea7e3e544e27b6067405a6b5ab0a31a99c8 (diff) |
libdwelf: Make dwelf_elf_begin return NULL only when there is an error.
dwelf_elf_begin was slightly different from elf_begin in case the file
turned out to not be an ELF file. elf_begin would return an Elf handle
with ELF_K_NONE. But dwelf_elf_begin would return NULL. This made it
impossible to tell the difference between a file or decompression error
and a (decompressed) file not being an ELF file.
Since dwelf_elf_begin could still return different kinds of ELF files
(ELF_K_ELF or ELF_K_AR - and theoretically ELF_K_COFF) this was not
really useful anyway. So make it so that dwelf_elf_begin always returns
an Elf handle unless there was a real error reading or decompressing
the file. Otherwise return NULL to make clear there was a real error.
Make sure that the decompression function returns DWFL_E_BADELF only
when the file isn't compressed. In which case the Elf handle won't
be replaced and can be returned (as ELF_K_NONE).
Add a new version to dwelf_elf_begin so programs can rely on it
returning NULL only for real errors.
Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw')
-rw-r--r-- | libdw/ChangeLog | 4 | ||||
-rw-r--r-- | libdw/libdw.map | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 6b779e77..bf1f4857 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2019-08-12 Mark Wielaard <mark@klomp.org> + + * libdw.map (ELFUTILS_0.177): Add new version of dwelf_elf_begin. + 2019-06-28 Mark Wielaard <mark@klomp.org> * libdw.map (ELFUTILS_0.177): New section. Add diff --git a/libdw/libdw.map b/libdw/libdw.map index 2e1c0e9e..decac05c 100644 --- a/libdw/libdw.map +++ b/libdw/libdw.map @@ -365,4 +365,8 @@ ELFUTILS_0.175 { ELFUTILS_0.177 { global: dwelf_elf_e_machine_string; + # Replaced ELFUTILS_0.175 versions. Both versions point to the + # same implementation, but users of the new symbol version can + # presume that NULL is only returned on error (otherwise ELF_K_NONE). + dwelf_elf_begin; } ELFUTILS_0.175; |