- The problem this is trying to solve can be seen for example thus: $ eu-readelf -a / eu-readelf: failed reading '/': (null)
With the fix we see a proper error number and get a reasonable error message:
$ eu-readelf -a / eu-readelf: failed reading '/': invalid file descriptor
Signed-off-by: Petr Machata pmachata@redhat.com --- libelf/ChangeLog | 5 +++++ libelf/elf_begin.c | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 4bc8f56..5ad20a6 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2014-09-10 Petr Machata pmachata@redhat.com + + * elf_begin (read_unmmaped_file): Call __libelf_seterrno if the + file is unreadable. + 2014-07-07 Mark Wielaard mjw@redhat.com
* elf.h: Update from glibc. diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c index 1ef70ac..3ee195d 100644 --- a/libelf/elf_begin.c +++ b/libelf/elf_begin.c @@ -550,9 +550,12 @@ read_unmmaped_file (int fildes, off_t offset, size_t maxsize, Elf_Cmd cmd, maxsize), offset); if (unlikely (nread == -1)) - /* We cannot even read the head of the file. Maybe FILDES is associated - with an unseekable device. This is nothing we can handle. */ - return NULL; + { + __libelf_seterrno (ELF_E_INVALID_FILE); + /* We cannot even read the head of the file. Maybe FILDES is associated + with an unseekable device. This is nothing we can handle. */ + return NULL; + }
/* See what kind of object we have here. */ Elf_Kind kind = determine_kind (mem.header, nread);
- These are extension attributes that correspond in behavior to attributes described in this proposal: http://www.dwarfstd.org/ShowIssue.php?issue=100909.2
- N.B.: DW_AT_call_site_data_location doesn't have a DW_AT_GNU_* counterpart.
Signed-off-by: Petr Machata pmachata@redhat.com --- libdw/ChangeLog | 6 ++++++ libdw/dwarf_getlocation.c | 6 +++++- 2 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 5f9b097..cc44004 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,9 @@ +2014-09-10 Petr Machata pmachata@redhat.com + + * dwarf_getlocation.c (attr_ok): Also accept + DW_AT_GNU_call_site_value, DW_AT_GNU_call_site_data_value, + DW_AT_GNU_call_site_target, DW_AT_GNU_call_site_target_clobbered. + 2014-08-15 Mark Wielaard mjw@redhat.com
* dwarf_cu_die.c: New file. diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c index 8dffb83..2a4c890 100644 --- a/libdw/dwarf_getlocation.c +++ b/libdw/dwarf_getlocation.c @@ -1,5 +1,5 @@ /* Return location expression list. - Copyright (C) 2000-2010, 2013 Red Hat, Inc. + Copyright (C) 2000-2010, 2013, 2014 Red Hat, Inc. This file is part of elfutils. Written by Ulrich Drepper drepper@redhat.com, 2000.
@@ -57,6 +57,10 @@ attr_ok (Dwarf_Attribute *attr) case DW_AT_return_addr: case DW_AT_static_link: case DW_AT_segment: + case DW_AT_GNU_call_site_value: + case DW_AT_GNU_call_site_data_value: + case DW_AT_GNU_call_site_target: + case DW_AT_GNU_call_site_target_clobbered: break;
default:
Looks right.
if (unlikely (nread == -1))
- /* We cannot even read the head of the file. Maybe FILDES is associated
with an unseekable device. This is nothing we can handle. */
- return NULL;
- {
__libelf_seterrno (ELF_E_INVALID_FILE);
/* We cannot even read the head of the file. Maybe FILDES is associated
with an unseekable device. This is nothing we can handle. */
return NULL;
- }
That looks sensible, though I'd keep the comment at the top of the block.
Roland McGrath roland@hack.frob.com writes:
if (unlikely (nread == -1))
- /* We cannot even read the head of the file. Maybe FILDES is associated
with an unseekable device. This is nothing we can handle. */
- return NULL;
- {
__libelf_seterrno (ELF_E_INVALID_FILE);
/* We cannot even read the head of the file. Maybe FILDES is associated
with an unseekable device. This is nothing we can handle. */
return NULL;
- }
That looks sensible, though I'd keep the comment at the top of the block.
Pushed with that fix.
Thanks, PM
elfutils-devel@lists.fedorahosted.org