forked from pool/elfutils
This commit is contained in:
parent
61f6c27c1b
commit
57f31c0794
553
elfutils-0.137-dwfl_getmodules-fixes.diff
Normal file
553
elfutils-0.137-dwfl_getmodules-fixes.diff
Normal file
@ -0,0 +1,553 @@
|
||||
From: Roland McGrath <roland@redhat.com>
|
||||
Date: Wed, 3 Dec 2008 03:41:58 +0000 (+0000)
|
||||
Subject: src/
|
||||
X-Git-Url: http://git.fedorahosted.org/git/elfutils.git?p=elfutils.git;a=commitdiff_plain;h=a845f68bf43f90e0670ed6b33154f2aff98ad46b
|
||||
|
||||
src/
|
||||
2008-12-02 Roland McGrath <roland@redhat.com>
|
||||
|
||||
* readelf.c (count_dwflmod, process_file): Don't presume encoding of
|
||||
nonzero OFFSET argument to dwfl_getmodules.
|
||||
---
|
||||
|
||||
diff --git a/backends/Makefile.am b/backends/Makefile.am
|
||||
index ebf6b09..5b55294 100644
|
||||
--- a/backends/Makefile.am
|
||||
+++ b/backends/Makefile.am
|
||||
@@ -146,7 +146,7 @@ uninstall: uninstall-am
|
||||
done
|
||||
rmdir --ignore-fail-on-non-empty $(DESTDIR)$(libdir)/$(LIBEBL_SUBDIR)
|
||||
|
||||
-noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c
|
||||
+noinst_HEADERS = libebl_CPU.h common-reloc.c linux-core-note.c x86_corenote.c
|
||||
EXTRA_DIST = $(foreach m,$(modules),$($(m)_SRCS)) $(modules:=_reloc.def)
|
||||
|
||||
CLEANFILES = *.gcno *.gcda \
|
||||
diff --git a/backends/i386_corenote.c b/backends/i386_corenote.c
|
||||
index 02d8ec3..c371c4c 100644
|
||||
--- a/backends/i386_corenote.c
|
||||
+++ b/backends/i386_corenote.c
|
||||
@@ -103,9 +103,8 @@ static const Ebl_Register_Location prxfpreg_regs[] =
|
||||
#define EXTRA_NOTES \
|
||||
EXTRA_REGSET (NT_PRFPXREG, 512, prxfpreg_regs) \
|
||||
case NT_386_TLS: \
|
||||
- return tls_info (descsz, regs_offset, nregloc, reglocs, nitems, items);
|
||||
-
|
||||
-#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
|
||||
+ return tls_info (descsz, regs_offset, nregloc, reglocs, nitems, items); \
|
||||
+ EXTRA_NOTES_IOPERM
|
||||
|
||||
static const Ebl_Core_Item tls_items[] =
|
||||
{
|
||||
@@ -131,4 +130,5 @@ tls_info (GElf_Word descsz, GElf_Word *regs_offset,
|
||||
return 1;
|
||||
}
|
||||
|
||||
+#include "x86_corenote.c"
|
||||
#include "linux-core-note.c"
|
||||
diff --git a/backends/x86_64_corenote.c b/backends/x86_64_corenote.c
|
||||
index c2bc72e..552ac88 100644
|
||||
--- a/backends/x86_64_corenote.c
|
||||
+++ b/backends/x86_64_corenote.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* x86-64 specific core note handling.
|
||||
- Copyright (C) 2005, 2007 Red Hat, Inc.
|
||||
+ Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
|
||||
This file is part of Red Hat elfutils.
|
||||
|
||||
Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
@@ -103,4 +103,7 @@ static const Ebl_Register_Location fpregset_regs[] =
|
||||
};
|
||||
#define FPREGSET_SIZE 512
|
||||
|
||||
+#define EXTRA_NOTES EXTRA_NOTES_IOPERM
|
||||
+
|
||||
+#include "x86_corenote.c"
|
||||
#include "linux-core-note.c"
|
||||
diff --git a/backends/x86_corenote.c b/backends/x86_corenote.c
|
||||
new file mode 100644
|
||||
index 0000000..7d55067
|
||||
--- /dev/null
|
||||
+++ b/backends/x86_corenote.c
|
||||
@@ -0,0 +1,47 @@
|
||||
+/* x86-specific core note handling, pieces common to x86-64 and i386.
|
||||
+ Copyright (C) 2005, 2008 Red Hat, Inc.
|
||||
+ This file is part of Red Hat elfutils.
|
||||
+
|
||||
+ Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
+ it under the terms of the GNU General Public License as published by the
|
||||
+ Free Software Foundation; version 2 of the License.
|
||||
+
|
||||
+ Red Hat elfutils is distributed in the hope that it will be useful, but
|
||||
+ WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU General Public License along
|
||||
+ with Red Hat elfutils; if not, write to the Free Software Foundation,
|
||||
+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
|
||||
+
|
||||
+ Red Hat elfutils is an included package of the Open Invention Network.
|
||||
+ An included package of the Open Invention Network is a package for which
|
||||
+ Open Invention Network licensees cross-license their patents. No patent
|
||||
+ license is granted, either expressly or impliedly, by designation as an
|
||||
+ included package. Should you wish to participate in the Open Invention
|
||||
+ Network licensing program, please visit www.openinventionnetwork.com
|
||||
+ <http://www.openinventionnetwork.com>. */
|
||||
+
|
||||
+#define EXTRA_NOTES_IOPERM \
|
||||
+ case NT_386_IOPERM: \
|
||||
+ return ioperm_info (descsz, regs_offset, nregloc, reglocs, nitems, items);
|
||||
+
|
||||
+static int
|
||||
+ioperm_info (GElf_Word descsz, GElf_Word *regs_offset,
|
||||
+ size_t *nregloc, const Ebl_Register_Location **reglocs,
|
||||
+ size_t *nitems, const Ebl_Core_Item **items)
|
||||
+{
|
||||
+ static const Ebl_Core_Item ioperm_item =
|
||||
+ { .type = ELF_T_WORD, .format = 'b', .name = "ioperm" };
|
||||
+
|
||||
+ if (descsz % 4 != 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ *regs_offset = 0;
|
||||
+ *nregloc = 0;
|
||||
+ *reglocs = NULL;
|
||||
+ *nitems = 1;
|
||||
+ *items = &ioperm_item;
|
||||
+ return 1;
|
||||
+}
|
||||
diff --git a/libdwfl/dwfl_getmodules.c b/libdwfl/dwfl_getmodules.c
|
||||
index f205b89..7c6ab97 100644
|
||||
--- a/libdwfl/dwfl_getmodules.c
|
||||
+++ b/libdwfl/dwfl_getmodules.c
|
||||
@@ -59,49 +59,55 @@ dwfl_getmodules (Dwfl *dwfl,
|
||||
if (dwfl == NULL)
|
||||
return -1;
|
||||
|
||||
+ /* We iterate through the linked list when it's all we have.
|
||||
+ But continuing from an offset is slow that way. So when
|
||||
+ DWFL->lookup_module is populated, we can instead keep our
|
||||
+ place by jumping directly into the array. Since the actions
|
||||
+ of a callback could cause it to get populated, we must
|
||||
+ choose the style of place-holder when we return an offset,
|
||||
+ and we encode the choice in the low bits of that value. */
|
||||
+
|
||||
Dwfl_Module *m = dwfl->modulelist;
|
||||
|
||||
- if (unlikely (dwfl->lookup_module == NULL))
|
||||
+ if ((offset & 3) == 1)
|
||||
{
|
||||
+ offset >>= 2;
|
||||
for (ptrdiff_t pos = 0; pos < offset; ++pos)
|
||||
if (m == NULL)
|
||||
return -1;
|
||||
else
|
||||
m = m->next;
|
||||
- while (m != NULL)
|
||||
- {
|
||||
- ++offset;
|
||||
- if ((*callback) (MODCB_ARGS (m), arg) != DWARF_CB_OK)
|
||||
- return offset;
|
||||
- m = m->next;
|
||||
- }
|
||||
}
|
||||
- else
|
||||
+ else if (((offset & 3) == 2) && likely (dwfl->lookup_module != NULL))
|
||||
{
|
||||
- if (offset > 0)
|
||||
- {
|
||||
- if ((size_t) offset - 1 == dwfl->lookup_elts)
|
||||
- return 0;
|
||||
+ offset >>= 2;
|
||||
|
||||
- if (unlikely ((size_t) offset - 1 > dwfl->lookup_elts))
|
||||
- return -1;
|
||||
+ if ((size_t) offset - 1 == dwfl->lookup_elts)
|
||||
+ return 0;
|
||||
|
||||
- m = dwfl->lookup_module[offset - 1];
|
||||
- if (unlikely (m == NULL))
|
||||
- return -1;
|
||||
- }
|
||||
+ if (unlikely ((size_t) offset - 1 > dwfl->lookup_elts))
|
||||
+ return -1;
|
||||
|
||||
- while (m != NULL)
|
||||
- {
|
||||
- int ok = (*callback) (MODCB_ARGS (m), arg);
|
||||
- m = m->next;
|
||||
- if (ok != DWARF_CB_OK)
|
||||
- return (m == NULL
|
||||
- ? (ptrdiff_t) dwfl->lookup_elts + 1
|
||||
- : m->segment + 1);
|
||||
- }
|
||||
+ m = dwfl->lookup_module[offset - 1];
|
||||
+ if (unlikely (m == NULL))
|
||||
+ return -1;
|
||||
+ }
|
||||
+ else if (offset != 0)
|
||||
+ {
|
||||
+ __libdwfl_seterrno (DWFL_E_BADSTROFF);
|
||||
+ return -1;
|
||||
}
|
||||
|
||||
+ while (m != NULL)
|
||||
+ {
|
||||
+ int ok = (*callback) (MODCB_ARGS (m), arg);
|
||||
+ ++offset;
|
||||
+ m = m->next;
|
||||
+ if (ok != DWARF_CB_OK)
|
||||
+ return ((dwfl->lookup_module == NULL) ? ((offset << 2) | 1)
|
||||
+ : (((m == NULL ? (ptrdiff_t) dwfl->lookup_elts + 1
|
||||
+ : m->segment + 1) << 2) | 2));
|
||||
+ }
|
||||
return 0;
|
||||
}
|
||||
INTDEF (dwfl_getmodules)
|
||||
diff --git a/libdwfl/dwfl_module_build_id.c b/libdwfl/dwfl_module_build_id.c
|
||||
index 903b79c..8725afb 100644
|
||||
--- a/libdwfl/dwfl_module_build_id.c
|
||||
+++ b/libdwfl/dwfl_module_build_id.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Return build ID information for a module.
|
||||
- Copyright (C) 2007 Red Hat, Inc.
|
||||
+ Copyright (C) 2007, 2008 Red Hat, Inc.
|
||||
This file is part of Red Hat elfutils.
|
||||
|
||||
Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
@@ -88,7 +88,8 @@ check_notes (Dwfl_Module *mod, bool set, Elf_Data *data, GElf_Addr data_vaddr)
|
||||
"GNU", sizeof "GNU"))
|
||||
return found_build_id (mod, set,
|
||||
data->d_buf + desc_pos, nhdr.n_descsz,
|
||||
- data_vaddr == NO_VADDR ? 0 : data_vaddr + pos);
|
||||
+ data_vaddr == NO_VADDR ? 0
|
||||
+ : data_vaddr + desc_pos);
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/libebl/eblcorenotetypename.c b/libebl/eblcorenotetypename.c
|
||||
index d01932f..9376cf5 100644
|
||||
--- a/libebl/eblcorenotetypename.c
|
||||
+++ b/libebl/eblcorenotetypename.c
|
||||
@@ -56,7 +56,6 @@
|
||||
#include <stdio.h>
|
||||
#include <libeblP.h>
|
||||
|
||||
-
|
||||
const char *
|
||||
ebl_core_note_type_name (ebl, type, buf, len)
|
||||
Ebl *ebl;
|
||||
@@ -101,6 +100,7 @@ ebl_core_note_type_name (ebl, type, buf, len)
|
||||
KNOWNSTYPE (PPC_VMX);
|
||||
KNOWNSTYPE (PPC_SPE);
|
||||
KNOWNSTYPE (386_TLS);
|
||||
+ KNOWNSTYPE (386_IOPERM);
|
||||
#undef KNOWNSTYPE
|
||||
|
||||
default:
|
||||
diff --git a/libelf/elf.h b/libelf/elf.h
|
||||
index a413446..b4d3475 100644
|
||||
--- a/libelf/elf.h
|
||||
+++ b/libelf/elf.h
|
||||
@@ -608,7 +608,9 @@ typedef struct
|
||||
#define NT_PRXFPREG 0x46e62b7f /* Contains copy of user_fxsr_struct */
|
||||
#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
|
||||
#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
|
||||
+#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
|
||||
#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
|
||||
+#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
|
||||
|
||||
/* Legal values for the note segment descriptor types for object files. */
|
||||
|
||||
@@ -1397,6 +1399,7 @@ typedef struct
|
||||
#define STO_MIPS_INTERNAL 0x1
|
||||
#define STO_MIPS_HIDDEN 0x2
|
||||
#define STO_MIPS_PROTECTED 0x3
|
||||
+#define STO_MIPS_PLT 0x8
|
||||
#define STO_MIPS_SC_ALIGN_UNUSED 0xff
|
||||
|
||||
/* MIPS specific values for `st_info'. */
|
||||
@@ -1543,8 +1546,10 @@ typedef struct
|
||||
#define R_MIPS_TLS_TPREL_HI16 49 /* TP-relative offset, high 16 bits */
|
||||
#define R_MIPS_TLS_TPREL_LO16 50 /* TP-relative offset, low 16 bits */
|
||||
#define R_MIPS_GLOB_DAT 51
|
||||
+#define R_MIPS_COPY 126
|
||||
+#define R_MIPS_JUMP_SLOT 127
|
||||
/* Keep this the last entry. */
|
||||
-#define R_MIPS_NUM 52
|
||||
+#define R_MIPS_NUM 128
|
||||
|
||||
/* Legal values for p_type field of Elf32_Phdr. */
|
||||
|
||||
@@ -1610,7 +1615,13 @@ typedef struct
|
||||
#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
|
||||
#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
|
||||
#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
|
||||
-#define DT_MIPS_NUM 0x32
|
||||
+/* The address of .got.plt in an executable using the new non-PIC ABI. */
|
||||
+#define DT_MIPS_PLTGOT 0x70000032
|
||||
+/* The base of the PLT in an executable using the new non-PIC ABI if that
|
||||
+ PLT is writable. For a non-writable PLT, this is omitted or has a zero
|
||||
+ value. */
|
||||
+#define DT_MIPS_RWPLT 0x70000034
|
||||
+#define DT_MIPS_NUM 0x35
|
||||
|
||||
/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
|
||||
|
||||
diff --git a/libelf/elf_getarhdr.c b/libelf/elf_getarhdr.c
|
||||
index deeb56d..875b2a1 100644
|
||||
--- a/libelf/elf_getarhdr.c
|
||||
+++ b/libelf/elf_getarhdr.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Read header of next archive member.
|
||||
- Copyright (C) 1998, 1999, 2000, 2002 Red Hat, Inc.
|
||||
+ Copyright (C) 1998, 1999, 2000, 2002, 2008 Red Hat, Inc.
|
||||
This file is part of Red Hat elfutils.
|
||||
Written by Ulrich Drepper <drepper@redhat.com>, 1998.
|
||||
|
||||
@@ -63,6 +63,9 @@ Elf_Arhdr *
|
||||
elf_getarhdr (elf)
|
||||
Elf *elf;
|
||||
{
|
||||
+ if (elf == NULL)
|
||||
+ return NULL;
|
||||
+
|
||||
Elf *parent = elf->parent;
|
||||
|
||||
/* Calling this function is not ok for any file type but archives. */
|
||||
@@ -78,7 +81,6 @@ elf_getarhdr (elf)
|
||||
/* Something went wrong. Maybe there is no member left. */
|
||||
return NULL;
|
||||
|
||||
-
|
||||
/* We can be sure the parent is an archive. */
|
||||
assert (parent->kind == ELF_K_AR);
|
||||
|
||||
diff --git a/src/ChangeLog b/src/ChangeLog
|
||||
index 4ef23a2..fb17835 100644
|
||||
--- a/src/ChangeLog
|
||||
+++ b/src/ChangeLog
|
||||
@@ -1,3 +1,8 @@
|
||||
+2008-12-02 Roland McGrath <roland@redhat.com>
|
||||
+
|
||||
+ * readelf.c (count_dwflmod, process_file): Don't presume encoding of
|
||||
+ nonzero OFFSET argument to dwfl_getmodules.
|
||||
+
|
||||
2008-08-07 Roland McGrath <roland@redhat.com>
|
||||
|
||||
* addr2line.c (main): Pass string to handle_address.
|
||||
diff --git a/src/readelf.c b/src/readelf.c
|
||||
index 7b599ec..2797a84 100644
|
||||
--- a/src/readelf.c
|
||||
+++ b/src/readelf.c
|
||||
@@ -459,8 +459,10 @@ count_dwflmod (Dwfl_Module *dwflmod __attribute__ ((unused)),
|
||||
Dwarf_Addr base __attribute__ ((unused)),
|
||||
void *arg)
|
||||
{
|
||||
- *(bool *) arg = false;
|
||||
- return DWARF_CB_ABORT;
|
||||
+ if (*(bool *) arg)
|
||||
+ return DWARF_CB_ABORT;
|
||||
+ *(bool *) arg = true;
|
||||
+ return DWARF_CB_OK;
|
||||
}
|
||||
|
||||
struct process_dwflmod_args
|
||||
@@ -548,8 +550,11 @@ process_file (int fd, const char *fname, bool only_one)
|
||||
dwfl_report_end (dwfl, NULL, NULL);
|
||||
|
||||
if (only_one)
|
||||
- /* Clear ONLY_ONE if we have multiple modules, from an archive. */
|
||||
- dwfl_getmodules (dwfl, &count_dwflmod, &only_one, 1);
|
||||
+ {
|
||||
+ /* Clear ONLY_ONE if we have multiple modules, from an archive. */
|
||||
+ bool seen = false;
|
||||
+ only_one = dwfl_getmodules (dwfl, &count_dwflmod, &seen, 0) == 0;
|
||||
+ }
|
||||
|
||||
/* Process the one or more modules gleaned from this file. */
|
||||
struct process_dwflmod_args a = { .fd = fd, .only_one = only_one };
|
||||
diff --git a/tests/ChangeLog b/tests/ChangeLog
|
||||
index 15e3818..b1471c1 100644
|
||||
--- a/tests/ChangeLog
|
||||
+++ b/tests/ChangeLog
|
||||
@@ -1,3 +1,15 @@
|
||||
+2008-11-26 Roland McGrath <roland@redhat.com>
|
||||
+
|
||||
+ * dwfl-bug-getmodules.c: New file.
|
||||
+ * Makefile.am (noinst_PROGRAMS): Add it.
|
||||
+ (dwfl_bug_getmodules_LDADD): New variable.
|
||||
+
|
||||
+2008-09-10 Roland McGrath <roland@redhat.com>
|
||||
+
|
||||
+ * test-subr.sh (LC_ALL): Export it set to "C".
|
||||
+ * run-dwfl-addr-sect.sh: Don't do it here.
|
||||
+ * run-strings-test.sh: Likewise.
|
||||
+
|
||||
2008-08-21 Denys Vlasenko <dvlasenk@redhat.com>
|
||||
|
||||
* run-addrname-test.sh: Add a new case.
|
||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
||||
index f57e432..b533521 100644
|
||||
--- a/tests/Makefile.am
|
||||
+++ b/tests/Makefile.am
|
||||
@@ -59,7 +59,8 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
|
||||
show-abbrev hash newscn ecp dwflmodtest \
|
||||
find-prologues funcretval allregs rdwrmmap \
|
||||
dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
|
||||
- dwfl-addr-sect dwfl-bug-report early-offscn
|
||||
+ dwfl-addr-sect dwfl-bug-report early-offscn \
|
||||
+ dwfl-bug-getmodules
|
||||
# get-ciefde
|
||||
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
|
||||
asm-tst6 asm-tst7 asm-tst8 asm-tst9
|
||||
@@ -229,6 +230,7 @@ dwfl_bug_addr_overflow_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
|
||||
arls_LDADD = $(libelf) $(libmudflap)
|
||||
dwfl_bug_fd_leak_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
|
||||
dwfl_bug_report_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
|
||||
+dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
|
||||
dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
|
||||
sha1_tst_LDADD = $(libeu) $(libmudflap)
|
||||
|
||||
diff --git a/tests/dwfl-bug-getmodules.c b/tests/dwfl-bug-getmodules.c
|
||||
new file mode 100644
|
||||
index 0000000..f7042c0
|
||||
--- /dev/null
|
||||
+++ b/tests/dwfl-bug-getmodules.c
|
||||
@@ -0,0 +1,74 @@
|
||||
+/* Test program for dwfl_getmodules bug.
|
||||
+ Copyright (C) 2008 Red Hat, Inc.
|
||||
+ This file is part of Red Hat elfutils.
|
||||
+
|
||||
+ Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
+ it under the terms of the GNU General Public License as published by the
|
||||
+ Free Software Foundation; version 2 of the License.
|
||||
+
|
||||
+ Red Hat elfutils is distributed in the hope that it will be useful, but
|
||||
+ WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ General Public License for more details.
|
||||
+
|
||||
+ You should have received a copy of the GNU General Public License along
|
||||
+ with Red Hat elfutils; if not, write to the Free Software Foundation,
|
||||
+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
|
||||
+
|
||||
+ Red Hat elfutils is an included package of the Open Invention Network.
|
||||
+ An included package of the Open Invention Network is a package for which
|
||||
+ Open Invention Network licensees cross-license their patents. No patent
|
||||
+ license is granted, either expressly or impliedly, by designation as an
|
||||
+ included package. Should you wish to participate in the Open Invention
|
||||
+ Network licensing program, please visit www.openinventionnetwork.com
|
||||
+ <http://www.openinventionnetwork.com>. */
|
||||
+
|
||||
+#include <config.h>
|
||||
+#include ELFUTILS_HEADER(dwfl)
|
||||
+
|
||||
+#include <error.h>
|
||||
+
|
||||
+static const Dwfl_Callbacks callbacks =
|
||||
+ {
|
||||
+ .find_elf = dwfl_linux_proc_find_elf,
|
||||
+ .find_debuginfo = dwfl_standard_find_debuginfo,
|
||||
+ };
|
||||
+
|
||||
+static int
|
||||
+iterate (Dwfl_Module *mod __attribute__ ((unused)),
|
||||
+ void **userdata __attribute__ ((unused)),
|
||||
+ const char *name __attribute__ ((unused)),
|
||||
+ Dwarf_Addr base, void *arg)
|
||||
+{
|
||||
+ if (base != 0x2000)
|
||||
+ return DWARF_CB_OK;
|
||||
+
|
||||
+ if (dwfl_addrmodule (arg, 0x2100) == NULL)
|
||||
+ error (1, 0, "dwfl_addrmodule: %s", dwfl_errmsg (-1));
|
||||
+
|
||||
+ return DWARF_CB_ABORT;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+main (void)
|
||||
+{
|
||||
+ Dwfl *dwfl = dwfl_begin (&callbacks);
|
||||
+
|
||||
+ dwfl_report_module (dwfl, "m1", 0, 0x1000);
|
||||
+ dwfl_report_module (dwfl, "m2", 0x2000, 0x3000);
|
||||
+ dwfl_report_module (dwfl, "m3", 0x4000, 0x5000);
|
||||
+
|
||||
+ dwfl_report_end (dwfl, NULL, NULL);
|
||||
+
|
||||
+ ptrdiff_t offset = dwfl_getmodules (dwfl, &iterate, dwfl, 0);
|
||||
+ if (offset <= 0)
|
||||
+ error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
|
||||
+
|
||||
+ offset = dwfl_getmodules (dwfl, &iterate, NULL, offset);
|
||||
+ if (offset != 0)
|
||||
+ error (1, 0, "dwfl_getmodules (%d): %s", (int) offset, dwfl_errmsg (-1));
|
||||
+
|
||||
+ dwfl_end (dwfl);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/tests/run-dwfl-addr-sect.sh b/tests/run-dwfl-addr-sect.sh
|
||||
index 69280f5..98666f3 100755
|
||||
--- a/tests/run-dwfl-addr-sect.sh
|
||||
+++ b/tests/run-dwfl-addr-sect.sh
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
-# Copyright (C) 2007 Red Hat, Inc.
|
||||
+# Copyright (C) 2007, 2008 Red Hat, Inc.
|
||||
# This file is part of Red Hat elfutils.
|
||||
#
|
||||
# Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
testfiles testfile43
|
||||
|
||||
-export LC_ALL=C
|
||||
testrun_compare ./dwfl-addr-sect -e testfile43 0x64 0x8 0x98 <<\EOF
|
||||
address 0x64 => module "" section 4 + 0
|
||||
address 0x8 => module "" section 1 + 0x8
|
||||
diff --git a/tests/run-strings-test.sh b/tests/run-strings-test.sh
|
||||
index cfd9d23..a5dac63 100755
|
||||
--- a/tests/run-strings-test.sh
|
||||
+++ b/tests/run-strings-test.sh
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
-# Copyright (C) 2005, 2006 Red Hat, Inc.
|
||||
+# Copyright (C) 2005, 2006, 2008 Red Hat, Inc.
|
||||
# This file is part of Red Hat elfutils.
|
||||
# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
|
||||
#
|
||||
@@ -29,9 +29,6 @@
|
||||
files="testfile `seq 2 9 | while read n; do echo testfile$n; done`"
|
||||
testfiles $files
|
||||
|
||||
-LC_ALL=C
|
||||
-export LC_ALL
|
||||
-
|
||||
testrun_compare ../src/strings -tx -f $files <<\EOF
|
||||
testfile: f4 /lib/ld-linux.so.2
|
||||
testfile: 1c9 __gmon_start__
|
||||
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
|
||||
index 7fda05a..cb34b93 100644
|
||||
--- a/tests/test-subr.sh
|
||||
+++ b/tests/test-subr.sh
|
||||
@@ -1,5 +1,5 @@
|
||||
#! /bin/sh
|
||||
-# Copyright (C) 2005, 2007 Red Hat, Inc.
|
||||
+# Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
|
||||
# This file is part of Red Hat elfutils.
|
||||
#
|
||||
# Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
@@ -30,6 +30,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
+#LC_ALL=C
|
||||
+#export LC_ALL
|
||||
+
|
||||
remove_files=
|
||||
trap 'rm -f $remove_files' 0
|
||||
|
19
elfutils-0.137-i386-rel-types.diff
Normal file
19
elfutils-0.137-i386-rel-types.diff
Normal file
@ -0,0 +1,19 @@
|
||||
From: Ulrich Drepper <drepper@redhat.com>
|
||||
Date: Sat, 4 Oct 2008 20:39:55 +0000 (+0000)
|
||||
Subject: Fix some entries in i386_reloc.def.
|
||||
X-Git-Url: http://git.fedorahosted.org/git/elfutils.git?p=elfutils.git;a=commitdiff_plain;h=a4c9d281616090c46ffc4fc3234d64e915008e1a
|
||||
|
||||
Fix some entries in i386_reloc.def.
|
||||
---
|
||||
|
||||
diff --git a/backends/i386_reloc.def b/backends/i386_reloc.def
|
||||
index d8116f3..bc1b835 100644
|
||||
--- a/backends/i386_reloc.def
|
||||
+++ b/backends/i386_reloc.def
|
||||
@@ -61,3 +61,6 @@ RELOC_TYPE (TLS_LE_32, REL)
|
||||
RELOC_TYPE (TLS_DTPMOD32, EXEC|DYN)
|
||||
RELOC_TYPE (TLS_DTPOFF32, EXEC|DYN)
|
||||
RELOC_TYPE (TLS_TPOFF32, EXEC|DYN)
|
||||
+RELOC_TYPE (TLS_GOTDESC, REL)
|
||||
+RELOC_TYPE (TLS_DESC_CALL, REL)
|
||||
+RELOC_TYPE (TLS_DESC, EXEC)
|
23
elfutils-0.137-main-bias-fix.diff
Normal file
23
elfutils-0.137-main-bias-fix.diff
Normal file
@ -0,0 +1,23 @@
|
||||
From 74825c4d9d21ff8ba0828d1790879965764ddb01 Mon Sep 17 00:00:00 2001
|
||||
From: Roland McGrath <roland@redhat.com>
|
||||
Date: Mon, 15 Dec 2008 19:33:33 -0800
|
||||
Subject: [PATCH] (dwfl_module_relocate_address): Apply main.bias, not debug.bias.
|
||||
|
||||
---
|
||||
|
||||
diff --git a/libdwfl/derelocate.c b/libdwfl/derelocate.c
|
||||
index 402bc06..7f390c7 100644
|
||||
--- a/libdwfl/derelocate.c
|
||||
+++ b/libdwfl/derelocate.c
|
||||
@@ -358,7 +358,7 @@ dwfl_module_relocate_address (Dwfl_Module *mod, Dwarf_Addr *addr)
|
||||
|
||||
if (mod->e_type != ET_REL)
|
||||
{
|
||||
- *addr -= mod->debug.bias;
|
||||
+ *addr -= mod->main.bias;
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
1.6.0.5
|
||||
|
121
elfutils-0.137-nm-crash-fix.diff
Normal file
121
elfutils-0.137-nm-crash-fix.diff
Normal file
@ -0,0 +1,121 @@
|
||||
From 468fe4d81a3e92157f4c0446675487dc230b2ec6 Mon Sep 17 00:00:00 2001
|
||||
From: Roland McGrath <roland@redhat.com>
|
||||
Date: Thu, 11 Dec 2008 21:00:12 -0800
|
||||
Subject: [PATCH] Fix crashes on bad sh_name/st_name offsets.
|
||||
|
||||
---
|
||||
|
||||
diff --git a/src/nm.c b/src/nm.c
|
||||
index 1bef49f..9fdf0cc 100644
|
||||
--- a/src/nm.c
|
||||
+++ b/src/nm.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Print symbol information from ELF file in human-readable form.
|
||||
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
|
||||
+ Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008 Red Hat, Inc.
|
||||
This file is part of Red Hat elfutils.
|
||||
Written by Ulrich Drepper <drepper@redhat.com>, 2000.
|
||||
|
||||
@@ -703,6 +703,18 @@ get_local_names (Dwarf *dbg)
|
||||
}
|
||||
}
|
||||
|
||||
+/* Do elf_strptr, but return a backup string and never NULL. */
|
||||
+static const char *
|
||||
+sym_name (Elf *elf, GElf_Word strndx, GElf_Word st_name, char buf[], size_t n)
|
||||
+{
|
||||
+ const char *symstr = elf_strptr (elf, strndx, st_name);
|
||||
+ if (symstr == NULL)
|
||||
+ {
|
||||
+ snprintf (buf, n, "[invalid st_name %#" PRIx32 "]", st_name);
|
||||
+ symstr = buf;
|
||||
+ }
|
||||
+ return symstr;
|
||||
+}
|
||||
|
||||
/* Show symbols in SysV format. */
|
||||
static void
|
||||
@@ -736,9 +748,15 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx,
|
||||
|
||||
assert (elf_ndxscn (scn) == cnt++);
|
||||
|
||||
- scnnames[elf_ndxscn (scn)]
|
||||
- = elf_strptr (ebl->elf, shstrndx,
|
||||
- gelf_getshdr (scn, &shdr_mem)->sh_name);
|
||||
+ char *name = elf_strptr (ebl->elf, shstrndx,
|
||||
+ gelf_getshdr (scn, &shdr_mem)->sh_name);
|
||||
+ if (unlikely (name == NULL))
|
||||
+ {
|
||||
+ name = alloca (sizeof "[invalid sh_name 0x12345678]");
|
||||
+ snprintf (name, sizeof name, "[invalid sh_name %#" PRIx32 "]",
|
||||
+ gelf_getshdr (scn, &shdr_mem)->sh_name);
|
||||
+ }
|
||||
+ scnnames[elf_ndxscn (scn)] = name;
|
||||
}
|
||||
|
||||
int digits = length_map[gelf_getclass (ebl->elf) - 1][radix];
|
||||
@@ -772,8 +790,10 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx,
|
||||
/* Iterate over all symbols. */
|
||||
for (cnt = 0; cnt < nsyms; ++cnt)
|
||||
{
|
||||
- const char *symstr = elf_strptr (ebl->elf, strndx,
|
||||
- syms[cnt].sym.st_name);
|
||||
+ char symstrbuf[50];
|
||||
+ const char *symstr = sym_name (ebl->elf, strndx, syms[cnt].sym.st_name,
|
||||
+ symstrbuf, sizeof symstrbuf);
|
||||
+
|
||||
char symbindbuf[50];
|
||||
char symtypebuf[50];
|
||||
char secnamebuf[1024];
|
||||
@@ -850,7 +870,9 @@ show_symbols_bsd (Elf *elf, GElf_Word strndx,
|
||||
/* Iterate over all symbols. */
|
||||
for (size_t cnt = 0; cnt < nsyms; ++cnt)
|
||||
{
|
||||
- const char *symstr = elf_strptr (elf, strndx, syms[cnt].sym.st_name);
|
||||
+ char symstrbuf[50];
|
||||
+ const char *symstr = sym_name (elf, strndx, syms[cnt].sym.st_name,
|
||||
+ symstrbuf, sizeof symstrbuf);
|
||||
|
||||
/* Printing entries with a zero-length name makes the output
|
||||
not very well parseable. Since these entries don't carry
|
||||
@@ -872,7 +894,7 @@ show_symbols_bsd (Elf *elf, GElf_Word strndx,
|
||||
? (GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK
|
||||
? "*" : " ")
|
||||
: "",
|
||||
- elf_strptr (elf, strndx, syms[cnt].sym.st_name));
|
||||
+ symstr);
|
||||
else
|
||||
printf (print_size ? sfmtstrs[radix] : fmtstrs[radix],
|
||||
digits, syms[cnt].sym.st_value,
|
||||
@@ -881,7 +903,7 @@ show_symbols_bsd (Elf *elf, GElf_Word strndx,
|
||||
? (GELF_ST_BIND (syms[cnt].sym.st_info) == STB_WEAK
|
||||
? "*" : " ")
|
||||
: "",
|
||||
- elf_strptr (elf, strndx, syms[cnt].sym.st_name),
|
||||
+ symstr,
|
||||
digits, (uint64_t) syms[cnt].sym.st_size);
|
||||
}
|
||||
}
|
||||
@@ -907,7 +929,9 @@ show_symbols_posix (Elf *elf, GElf_Word strndx, const char *prefix,
|
||||
/* Iterate over all symbols. */
|
||||
for (size_t cnt = 0; cnt < nsyms; ++cnt)
|
||||
{
|
||||
- const char *symstr = elf_strptr (elf, strndx, syms[cnt].sym.st_name);
|
||||
+ char symstrbuf[50];
|
||||
+ const char *symstr = sym_name (elf, strndx, syms[cnt].sym.st_name,
|
||||
+ symstrbuf, sizeof symstrbuf);
|
||||
|
||||
/* Printing entries with a zero-length name makes the output
|
||||
not very well parseable. Since these entries don't carry
|
||||
@@ -1056,6 +1080,8 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn,
|
||||
{
|
||||
const char *symstr = elf_strptr (ebl->elf, shdr->sh_link,
|
||||
sym->st_name);
|
||||
+ if (symstr == NULL)
|
||||
+ continue;
|
||||
|
||||
longest_name = MAX ((size_t) longest_name, strlen (symstr));
|
||||
|
||||
--
|
||||
1.6.0.5
|
||||
|
49
elfutils-0.137-readelf-crash-fix.diff
Normal file
49
elfutils-0.137-readelf-crash-fix.diff
Normal file
@ -0,0 +1,49 @@
|
||||
From b28a894209451b93ba830f56e40871e44e9c7c28 Mon Sep 17 00:00:00 2001
|
||||
From: Roland McGrath <roland@redhat.com>
|
||||
Date: Thu, 11 Dec 2008 02:09:28 -0800
|
||||
Subject: [PATCH] Fixes RHBZ#465878: eu-readelf crash on empty archive
|
||||
|
||||
---
|
||||
|
||||
diff --git a/libdwfl/offline.c b/libdwfl/offline.c
|
||||
index ff7b793..b3a95dd 100644
|
||||
--- a/libdwfl/offline.c
|
||||
+++ b/libdwfl/offline.c
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Recover relocatibility for addresses computed from debug information.
|
||||
- Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
|
||||
+ Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
|
||||
This file is part of Red Hat elfutils.
|
||||
|
||||
Red Hat elfutils is free software; you can redistribute it and/or modify
|
||||
@@ -259,16 +259,23 @@ process_archive (Dwfl *dwfl, const char *name, const char *file_name, int fd,
|
||||
|
||||
{
|
||||
Dwfl_Module *mod = NULL;
|
||||
+ Elf *member = elf_begin (fd, ELF_C_READ_MMAP_PRIVATE, archive);
|
||||
+ if (unlikely (member == NULL)) /* Empty archive. */
|
||||
+ {
|
||||
+ __libdwfl_seterrno (DWFL_E_BADELF);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
while (process_archive_member (dwfl, name, file_name, predicate,
|
||||
- fd, elf_begin (fd, ELF_C_READ_MMAP_PRIVATE,
|
||||
- archive), &mod) != ELF_C_NULL)
|
||||
- ;
|
||||
+ fd, member, &mod) != ELF_C_NULL)
|
||||
+ member = elf_begin (fd, ELF_C_READ_MMAP_PRIVATE, archive);
|
||||
|
||||
/* We can drop the archive Elf handle even if we're still using members
|
||||
in live modules. When the last module's elf_end on a member returns
|
||||
zero, that module will close FD. If no modules survived the predicate,
|
||||
we are all done with the file right here. */
|
||||
- if (elf_end (archive) == 0)
|
||||
+ if (mod != NULL /* If no modules, caller will clean up. */
|
||||
+ && elf_end (archive) == 0)
|
||||
close (fd);
|
||||
|
||||
return mod;
|
||||
--
|
||||
1.6.0.5
|
||||
|
@ -1,3 +1,10 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 16 13:48:38 CET 2008 - tiwai@suse.de
|
||||
|
||||
- Fix dwfl_getmodules(), assert in systemtap (bnc#448331)
|
||||
- Fix libebl1 dependency
|
||||
- Fix crashes of elfutils binaries, backports from upstream
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Nov 25 13:12:04 CET 2008 - tiwai@suse.de
|
||||
|
||||
|
@ -21,10 +21,11 @@
|
||||
Name: elfutils
|
||||
License: GPL v2 or later
|
||||
Version: 0.137
|
||||
Release: 3
|
||||
Release: 4
|
||||
Summary: Higher-level library to access ELF
|
||||
Group: System/Libraries
|
||||
Url: http://elfutils.fedorahosted.org
|
||||
Recommends: libebl1
|
||||
Source: elfutils-%{version}-no-osl.tar.bz2
|
||||
Patch: elfutils-portability.patch
|
||||
Patch1: elfutils-robustify.patch
|
||||
@ -35,6 +36,11 @@ Patch9: libelf-ignore-NOBITS-sh_offset.patch
|
||||
Patch10: test.diff
|
||||
Patch11: build.diff
|
||||
Patch20: elfutils-0.137-fixes.patch
|
||||
Patch21: elfutils-0.137-dwfl_getmodules-fixes.diff
|
||||
Patch22: elfutils-0.137-i386-rel-types.diff
|
||||
Patch23: elfutils-0.137-readelf-crash-fix.diff
|
||||
Patch24: elfutils-0.137-nm-crash-fix.diff
|
||||
Patch25: elfutils-0.137-main-bias-fix.diff
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
%description
|
||||
@ -94,6 +100,7 @@ Authors:
|
||||
Summary: A collection of utilities and DSOs to handle compiled objects
|
||||
Group: Development/Tools/Other
|
||||
License: GPL v2 or later
|
||||
Requires: libdw1 = %{version}-%{release}
|
||||
Provides: libebl = %{version}
|
||||
Obsoletes: libebl < %{version}
|
||||
|
||||
@ -199,6 +206,11 @@ Authors:
|
||||
#%patch10 -p1
|
||||
%patch11 -p1
|
||||
%patch20 -p1
|
||||
%patch21 -p1
|
||||
%patch22 -p1
|
||||
%patch23 -p1
|
||||
%patch24 -p1
|
||||
%patch25 -p1
|
||||
|
||||
%build
|
||||
autoreconf -fi
|
||||
@ -210,14 +222,10 @@ make DESTDIR=$RPM_BUILD_ROOT install
|
||||
# remove unneeded files
|
||||
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
|
||||
|
||||
%post -n libebl1 -p /sbin/ldconfig
|
||||
|
||||
%post -n libelf1 -p /sbin/ldconfig
|
||||
|
||||
%post -n libdw1 -p /sbin/ldconfig
|
||||
|
||||
%postun -n libebl1 -p /sbin/ldconfig
|
||||
|
||||
%postun -n libelf1 -p /sbin/ldconfig
|
||||
|
||||
%postun -n libdw1 -p /sbin/ldconfig
|
||||
@ -283,6 +291,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||
%{_includedir}/elfutils/libdwfl.h
|
||||
|
||||
%changelog
|
||||
* Tue Dec 16 2008 tiwai@suse.de
|
||||
- Fix dwfl_getmodules(), assert in systemtap (bnc#448331)
|
||||
- Fix libebl1 dependency
|
||||
- Fix crashes of elfutils binaries, backports from upstream
|
||||
* Tue Nov 25 2008 tiwai@suse.de
|
||||
- fix libdwfl regression with realloc DWFL->lookup_module in
|
||||
the fix patch (bnc#448331, likely bnc#445783)
|
||||
|
Loading…
Reference in New Issue
Block a user