--- Begin Message ---
./
2014-02-22 Jan Kratochvil <jan.kratoch...@redhat.com>
Extend __libdw_open_file and elf_begin as *_at_offset.
* NEWS (libelf): New, with elf_begin_at_offset.
libdwfl/
2014-02-22 Jan Kratochvil <jan.kratoch...@redhat.com>
Extend __libdw_open_file and elf_begin as *_at_offset.
* libdwflP.h (__libdw_open_file_at_offset): New declaration.
* open.c (__libdw_open_file): Rename to ...
(__libdw_open_file_at_offset): ... here and add parameters start_offset
and maximum_size.
(__libdw_open_file): New wrapper of it.
libelf/
2014-02-22 Jan Kratochvil <jan.kratoch...@redhat.com>
Extend __libdw_open_file and elf_begin as *_at_offset.
* elf_begin.c (elf_begin): Rename to ...
(elf_begin_at_offset): ... here and add parameters start_offset and
maximum_size.
(elf_begin): New wrapper of it.
* libelf.h (elf_begin_at_offset): New declaration.
* libelf.map (ELFUTILS_1.7): New, with elf_begin_at_offset.
Signed-off-by: Jan Kratochvil <jan.kratoch...@redhat.com>
---
NEWS | 2 ++
libdwfl/libdwflP.h | 10 ++++++++++
libdwfl/open.c | 14 ++++++++++++--
libelf/elf_begin.c | 20 ++++++++++++++------
libelf/libelf.h | 6 ++++++
libelf/libelf.map | 5 +++++
6 files changed, 49 insertions(+), 8 deletions(-)
diff --git a/NEWS b/NEWS
index b774ec4..b0653f1 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ Version 0.159
stack: New option -d, --debugname to lookup DWARF debuginfo name for frame.
New option -i, --inlines to show inlined frames using DWARF debuginfo.
+libelf: New function elf_begin_at_offset.
+
Version 0.158
libdwfl: dwfl_core_file_report has new parameter executable.
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index 710e699..9d7157d 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -563,6 +563,16 @@ extern Dwfl_Error __libdw_open_file (int *fdp, Elf **elfp,
bool close_on_fail, bool archive_ok)
internal_function;
+/* Call __libdw_open_file but the ELF file starts in *FDP at START_OFFSET and
+ has length MAXIMUM_SIZE. __libdw_open_file defaults to 0 and ~((size_t) 0)
+ respectively. */
+extern Dwfl_Error __libdw_open_file_at_offset (int *fdp, Elf **elfp,
+ off_t start_offset,
+ size_t maximum_size,
+ bool close_on_fail,
+ bool archive_ok)
+ internal_function;
+
/* Fetch PT_DYNAMIC P_VADDR from ELF and store it to *VADDRP. Return success.
*VADDRP is not modified if the function fails. */
extern bool __libdwfl_dynamic_vaddr_get (Elf *elf, GElf_Addr *vaddrp)
diff --git a/libdwfl/open.c b/libdwfl/open.c
index 40aac38..352f734 100644
--- a/libdwfl/open.c
+++ b/libdwfl/open.c
@@ -119,11 +119,14 @@ what_kind (int fd, Elf **elfp, Elf_Kind *kind, bool
*close_fd)
}
Dwfl_Error internal_function
-__libdw_open_file (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok)
+__libdw_open_file_at_offset (int *fdp, Elf **elfp, off_t start_offset,
+ size_t maximum_size, bool close_on_fail,
+ bool archive_ok)
{
bool close_fd = false;
- Elf *elf = elf_begin (*fdp, ELF_C_READ_MMAP_PRIVATE, NULL);
+ Elf *elf = elf_begin_at_offset (*fdp, ELF_C_READ_MMAP_PRIVATE, NULL,
+ start_offset, maximum_size);
Elf_Kind kind;
Dwfl_Error error = what_kind (*fdp, &elf, &kind, &close_fd);
@@ -180,3 +183,10 @@ __libdw_open_file (int *fdp, Elf **elfp, bool
close_on_fail, bool archive_ok)
*elfp = elf;
return error;
}
+
+Dwfl_Error internal_function
+__libdw_open_file (int *fdp, Elf **elfp, bool close_on_fail, bool archive_ok)
+{
+ return __libdw_open_file_at_offset (fdp, elfp, 0, ~((size_t) 0),
+ close_on_fail, archive_ok);
+}
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index a592fbf..5bd14eb 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -1013,10 +1013,8 @@ write_file (int fd, Elf_Cmd cmd)
/* Return a descriptor for the file belonging to FILDES. */
Elf *
-elf_begin (fildes, cmd, ref)
- int fildes;
- Elf_Cmd cmd;
- Elf *ref;
+elf_begin_at_offset (int fildes, Elf_Cmd cmd, Elf *ref, off_t start_offset,
+ size_t maximum_size)
{
Elf *retval;
@@ -1073,7 +1071,7 @@ elf_begin (fildes, cmd, ref)
retval = lock_dup_elf ();
else
/* Create descriptor for existing file. */
- retval = read_file (fildes, 0, ~((size_t) 0), cmd, NULL);
+ retval = read_file (fildes, start_offset, maximum_size, cmd, NULL);
break;
case ELF_C_RDWR:
@@ -1095,7 +1093,7 @@ elf_begin (fildes, cmd, ref)
}
else
/* Create descriptor for existing file. */
- retval = read_file (fildes, 0, ~((size_t) 0), cmd, NULL);
+ retval = read_file (fildes, start_offset, maximum_size, cmd, NULL);
break;
case ELF_C_WRITE:
@@ -1116,4 +1114,14 @@ elf_begin (fildes, cmd, ref)
return retval;
}
+INTDEF(elf_begin_at_offset)
+
+Elf *
+elf_begin (fildes, cmd, ref)
+ int fildes;
+ Elf_Cmd cmd;
+ Elf *ref;
+{
+ return elf_begin_at_offset (fildes, cmd, ref, 0, ~((size_t) 0));
+}
INTDEF(elf_begin)
diff --git a/libelf/libelf.h b/libelf/libelf.h
index 5a2b3af..bd5157b 100644
--- a/libelf/libelf.h
+++ b/libelf/libelf.h
@@ -164,6 +164,12 @@ extern "C" {
/* Return descriptor for ELF file to work according to CMD. */
extern Elf *elf_begin (int __fildes, Elf_Cmd __cmd, Elf *__ref);
+/* Call elf_begin but the ELF file starts in FILDES at START_OFFSET and
+ has length MAXIMUM_SIZE. elf_begin defaults to 0 and ~((size_t) 0)
+ respectively. */
+extern Elf *elf_begin_at_offset (int fildes, Elf_Cmd __cmd, Elf *__ref,
+ off_t start_offset, size_t maximum_size);
+
/* Create a clone of an existing ELF descriptor. */
extern Elf *elf_clone (Elf *__elf, Elf_Cmd __cmd);
diff --git a/libelf/libelf.map b/libelf/libelf.map
index de6d912..0b56396 100644
--- a/libelf/libelf.map
+++ b/libelf/libelf.map
@@ -138,3 +138,8 @@ ELFUTILS_1.6 {
global:
elf_getphdrnum;
} ELFUTILS_1.5;
+
+ELFUTILS_1.7 {
+ global:
+ elf_begin_at_offset;
+} ELFUTILS_1.6;
--
1.8.5.3
--- End Message ---