[PATCH] libelf: ar_size cannot be negative. Fix max ar size.
by Mark Wielaard
Elf_Arhdr ar_size is loff_t, which is signed. Make sure it isn't negative.
When the parent start_offset is non-zero maxsize should include it to
compensate for ar offset.
Found with afl-fuzz.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libelf/ChangeLog | 5 +++++
libelf/elf_begin.c | 9 ++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 3b88d03..6a1c925 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@
+2014-12-25 Mark Wielaard <mjw(a)redhat.com>
+
+ * elf_begin.c (__libelf_next_arhdr_wrlock): ar_size cannot be
+ negative. Include start_offset in maxsize.
+
2014-12-18 Ulrich Drepper <drepper(a)gmail.com>
* Makefile.am: Suppress output of textrel_check command.
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 30abe0b..947b0ed 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -924,9 +924,16 @@ __libelf_next_arhdr_wrlock (elf)
INT_FIELD (ar_mode);
INT_FIELD (ar_size);
+ if (elf_ar_hdr->ar_size < 0)
+ {
+ __libelf_seterrno (ELF_E_INVALID_ARCHIVE);
+ return -1;
+ }
+
/* Truncated file? */
size_t maxsize;
- maxsize = elf->maximum_size - elf->state.ar.offset - sizeof (struct ar_hdr);
+ maxsize = (elf->start_offset + elf->maximum_size
+ - elf->state.ar.offset - sizeof (struct ar_hdr));
if ((size_t) elf_ar_hdr->ar_size > maxsize)
elf_ar_hdr->ar_size = maxsize;
--
1.8.3.1
9 years, 3 months
[PATCH] readelf: Don't try to read macinfo cus sentinel or beyond.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 5 +++++
src/readelf.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 00a587c..7203dd9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2014-12-20 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (print_debug_macinfo_section): Mark cus sentinel files
+ as -1 non-existent. Check macoff against sentinel cus.
+
+2014-12-20 Mark Wielaard <mjw(a)redhat.com>
+
* readelf.c (print_debug_exception_table): Add max_action overflow
check. Check action_table_end before reading slib128. Check
max_ar_filter underflow.
diff --git a/src/readelf.c b/src/readelf.c
index a05b238..237975f 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7061,6 +7061,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
* sizeof (*cus));
/* Add sentinel. */
cus[nculist].offset = data->d_size;
+ cus[nculist].files = (Dwarf_Files *) -1l;
if (nculist > 0)
{
for (size_t cnt = nculist - 1; culist != NULL; --cnt)
@@ -7136,7 +7137,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
const char *fname = "???";
if (macoff >= cus[0].offset)
{
- while (macoff >= cus[1].offset)
+ while (macoff >= cus[1].offset && cus[1].offset != data->d_size)
++cus;
if (cus[0].files == NULL
--
2.1.0
9 years, 3 months
[PATCH] readelf: Add more sanity checks to print_debug_exception_table.
by Mark Wielaard
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 6 ++++++
src/readelf.c | 18 ++++++++++++++----
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 0ae863e..00a587c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-20 Mark Wielaard <mjw(a)redhat.com>
+
+ * readelf.c (print_debug_exception_table): Add max_action overflow
+ check. Check action_table_end before reading slib128. Check
+ max_ar_filter underflow.
+
2014-12-18 Ulrich Drepper <drepper(a)gmail.com>
* Makefile.am: Suppress output of textrel_check command.
diff --git a/src/readelf.c b/src/readelf.c
index df0a874..a05b238 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -7853,8 +7853,10 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
{
puts ("\n Action table:");
- if ((size_t) (dataend - action_table) < max_action + 1)
+ size_t maxdata = (size_t) (dataend - action_table);
+ if (max_action > maxdata || maxdata - max_action < 1)
{
+ invalid_action_table:
fputs (gettext (" <INVALID DATA>\n"), stdout);
return;
}
@@ -7870,6 +7872,8 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
if (ar_filter > 0 && (unsigned int) ar_filter > max_ar_filter)
max_ar_filter = ar_filter;
int ar_disp;
+ if (readp >= action_table_end)
+ goto invalid_action_table;
get_sleb128 (ar_disp, readp, action_table_end);
printf (" [%4u] ar_filter: % d\n"
@@ -7888,6 +7892,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
if (max_ar_filter > 0 && ttype_base != NULL)
{
+ unsigned char dsize;
puts ("\n TType table:");
// XXX Not *4, size of encoding;
@@ -7895,20 +7900,25 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
{
case DW_EH_PE_udata2:
case DW_EH_PE_sdata2:
- readp = ttype_base - max_ar_filter * 2;
+ dsize = 2;
break;
case DW_EH_PE_udata4:
case DW_EH_PE_sdata4:
- readp = ttype_base - max_ar_filter * 4;
+ dsize = 4;
break;
case DW_EH_PE_udata8:
case DW_EH_PE_sdata8:
- readp = ttype_base - max_ar_filter * 8;
+ dsize = 8;
break;
default:
error (1, 0, gettext ("invalid TType encoding"));
}
+ if (max_ar_filter
+ > (size_t) (ttype_base - (const unsigned char *) data->d_buf) / dsize)
+ goto invalid_data;
+
+ readp = ttype_base - max_ar_filter * dsize;
do
{
uint64_t ttype;
--
2.1.0
9 years, 3 months
Directory traversal in `ar`
by Alexander Cherepanov
Hi!
There is a directory traversal in `ar`:
# printf '!<arch>\n%-48s%-10s`\n//file/\n%-48s%-10s`\n' // 8 /1 0 > test.a
# ar -xv test.a
x - /file
Patch attached.
--
Alexander Cherepanov
9 years, 3 months
Fuzzing elfutils
by Alexander Cherepanov
Hi!
[Please Cc me, I'm not subscribed.]
I've been fuzzing binutils for some time now and I've spotted that you
are also intersted in it. So I have tried to fuzz elfutils. Results
attached. valgrind logs or gdb backtraces are included. Cases are
deduplicated based on the full stacktrackes as provided by the
corresponding tools.
I'm not very familiar with elfutils. Which commands give the most code
coverage (and shortest run time)? I've used two commands so far:
objdump -rs
readelf -aAdehIlnrsSVcp -w
and crashes seem to differ for them.
BTW does indended use of elfutils include the use against untrusted
files and do you track corresponding security issues?
Any feedback is welcome.
Contents:
objdump-crashes.tar.gz:
Files: 11
Errors:
10 Invalid read of size ...
7 Process terminating with default action of signal 11 (SIGSEGV)
3 Process terminating with default action of signal 8 (SIGFPE)
readelf-crashes.tar.gz:
Files: 11
Errors:
1 Argument 'size' of function malloc has a fishy (possibly
negative) value: ...
1 Invalid free() / delete / delete[] / realloc()
9 Invalid read of size ...
6 Process terminating with default action of signal 11 (SIGSEGV)
1 Process terminating with default action of signal 8 (SIGFPE)
readelf-asserts.tar.gz:
Files: 2
Errors:
1 No assertion info in gdb backtrace.
1 readelf.c:7731: print_debug_exception_table: Assertion `readp
== action_table' failed.
--
Alexander Cherepanov
9 years, 3 months
elfutils 0.161 released
by Mark Wielaard
A new release of elfutils is available now at:
https://fedorahosted.org/releases/e/l/elfutils/0.161/
* NEWS *
Version 0.161
libdw: New function dwarf_peel_type. dwarf_aggregate_size now uses
dwarf_peel_type to also provide the sizes of qualified types.
dwarf_getmacros will now serve either of .debug_macro and
.debug_macinfo transparently. New interfaces
dwarf_getmacros_off, dwarf_macro_getsrcfiles,
dwarf_macro_getparamcnt, and dwarf_macro_param are available
for more generalized inspection of macros and their parameters.
dwarf.h: Add DW_AT_GNU_deleted, DW_AT_noreturn, DW_LANG_C11,
DW_LANG_C_plus_plus_11 and DW_LANG_C_plus_plus_14.
Thanks to Hanno Böck and Alexander Cherepanov for running various
fuzzers and reporting crashers in the eu-readelf tool, libelf and libdw
libraries. elfutils should now be a little bit less crashy. But we still
recommend users to be careful processing possibly corrupt ELF and DWARF
files.
* GIT SHORTLOG *
Jan Kratochvil (3):
Fix resolving ELF symbols for live PIDs with deleted files
Add is_executable to Dwfl_Module.
Support note NT_FILE for locating files.
Josh Stone (10):
addr2line: Iterate scopes for inline's parent function
addr2line: Always prefer linkage_name over plain names
libdw: unify die->abbrev lookups
libdw: optimize dwarf_hasattr to just look at abbrev
libdw: save startp/endp boundaries in Dwarf_CU
libdw: Make srclines use a stable sort
libdwfl: Search for the last matching address in lines
tests: Test addr2line -i with lexical blocks present
Add config/compile as installed by automake 1.14
libdw: pre-compute leb128 loop limits
Mark Wielaard (92):
libdwfl: dwfl_segment_report_module use ei_class, ei_data and e_type.
libdw: dwarf_aggregate_size return CU address_size for sizeless pointer/refs.
tests: run-deleted.sh unset VALGRIND_CMD before running deleted.
dwarf.h: Add DW_AT_GNU_deleted.
libdw: Add dwarf_peel_type. Use it in dwarf_aggregate_size.
libelf: Correct shdr size check for (raw) getdata.
readelf: Sanity check hash section contents before processing.
readelf.c (handle_versym): Initialize vername and filename array elements.
libdw: Fix dwarf_getsrclines.c 32bit compile error.
libelf: Use mempcpy not __mempcpy.
libelf: Fix unsigned overflow check in elf_getdata.
libdwfl: find_dynsym don't assume dynamic linker has adjusted DYNAMIC entries.
readelf: Check def == NULL before use in handle_versym.
libdwfl: dwfl_module_getdwarf.c don't use symtab with bogus sh_entsize.
libdwelf: Check the d_buf actually exists in dwelf_elf_gnu_debuglink.
libelf: gelf_getnote check for offset overflow.
readelf: Sanity check CIE unit_length and augmentationlen in debug_frame.
libelf: getdata check 64bit values correctly on 32bit arch.
gelf_getnote: Check padding overflow.
readelf: Robustify print_cfa_program.
libelf: Fix handling of (extended) phnum.
libelf: elf_getshdrstrndx cannot use SHN_XINDEX without section headers.
readelf: Warn if ptr_size is not 4 or 8 bytes.
Check elf_strptr didn't fail getting section name.
readelf: When the version chain ends, stop processing the entries.
libelf: Check for overflow in version_xlate elf_cvt_Verdef and elf_cvt_Verneed.
readelf: Fix sanity check of DW_FORM_block length in print_cfa_program
libdwfl: Sanity check the symbol table before use.
dwarf.h: Add DW_AT_noreturn.
dwarf.h: Add DW_LANG_C11, DW_LANG_C_plus_plus_11 and DW_LANG_C_plus_plus_14.
libelf: elf_getphdrnum sanity check the returned phnum result.
Use elf_getphdrnum instead of accessing ehdr->e_phnum directly.
readelf: print_attributes (-A) robustify and handle non-gnu attributes.
libelf: Copy over any leftover data from src to dest in elf_cvt_note.
readelf: Check length for nexthdr overflow in print_debug_aranges_section.
libelf: Change signed overflow check to unsigned in elf_getdata_rawchunk.
libdw: Don't assert in __libdw_getabbrev when seeing bad DWARF.
libdw: Always check __libdw_find_attr return value.
readelf, libdw: Guard against divide by zero line_range in .debug_line.
readelf: Cast Dwarf_Word length to ptrdiff_t for comparison.
tests: vdsosyms call dwfl_linux_proc_attach.
libdw: Initialize variables in getcfi_gnu_eh_frame.
Add configure --disable-textrelcheck option to enable CC=afl-fuzz on 32bit.
readelf: Don't trash destshdr for STT_SECTION in handle_relocs_rel[a].
libdwfl: Check relocations don't overlap ELF ehdr, shdrs or phdrs.
readelf: Fix overflow check in handle_sysv_hash64.
objdump: Add various sanity checks to guard against corrupted data.
libdw: Add overflow checking to __libdw_form_val_len.
libdwfl: Never relocate value against section zero (load address).
libdwfl: Check actually used ehsize, shentsize and phentsize in relocate.c
readelf: DW_OP_call_ref and DW_OP_GNU_implicit_pointer are invalid for CFA.
readelf: maximum operations per instruction cannot be zero in .debug_line.
readelf: Report invalid data if action table doesn't follow call site table.
readelf: Check count fits and doesn't overflow fptr in handle_file_note.
libdwfl: Check file count overflow in handle_file_note.
libelf: Make sure n * w doesn't overflow in elf_getarsym.
tests: Add an explicit -fasynchronous-unwind-tables for deleted-lib.so.
libelf: Add some ar header sanity checking.
libelf: Correct ELF64 section offset check in file_read_elf.
readelf: Don't print more augmentation characters than there are.
readelf: Check TType base offset and Action table are sane in exception table.
Guard against 64bit unsigned wrap around in (int) compare functions.
libdw: Make sure end of next cu doesn't overflow section data size.
libdwfl: Make sure elf_getdata_rawchunk size_t doesn't overflow find_dynsym.
elfcmp: Make sure Elf32_Word difference doesn't wrap around in int compare.
libdw: Make sure all attributes come with a (fake) CU for bound checks.
libdw: Add get_uleb128 and get_sleb128 bounds checking.
libdw: Unroll the first get_sleb128 step to help the compiler optimize.
libelf: Clear any garbage left in the ar name table.
readelf: Check there is enough room for the DW_LNE_set_address argument
readelf: Make sure there is enough room for reading .debug_line unit_length.
libdw: Add bounds checking to dwarf_getpubnames.
readelf: Add more bounds checks to print_gdb_index_section.
libdw: dwarf_getpubnames set error to DWARF_E_NO_ENTRY for zero entries.
readelf: Don't assert when addr_size or ref_size is not 4 or 8 in print_ops.
readelf: Warn, don't assert, if loclist or rangelist offset is too big.
readelf,libdw: Correct .debug_line overflow check for unit_length.
readelf: Correct overflow check for length in print_debug_aranges_section.
libdw: Make sure there is enough space to read offset in dwarf_getpubnames.
libelf: Check index_size doesn't overflow in elf_getarsym.
libelf: Make sure ar archive long_names len fits in mapped ELF file.
readelf: Print dwarf_errmsg if dwarf_onesrcline or dwarf_linesrc fails.
libdw: Check diridx is valid under DW_LNE_define_file in dwarf_getsrclines.
readelf: Add bounds check before each CFA op that takes an argument.
libdwfl: Make sure symstrdata->d_buf != NULL in relocate resolve_symbol.
tests: Add testfile-macros-0xff.bz2 to EXTRA_DIST.
Prepare 0.161 release.
libdwfl: Remove p_align sanity check from elf_from_memory.
libdwfl: Always try find_dynsym last, also on find_symtab ELF errors.
tests: run-deleted.sh should SKIP if arch doesn't support unwinding.
tests: vdsosyms should not fail for architectures that don't have a vdso.
tests: Don't match libfunc symbol on ppc64 in run-deleted.sh testcase.
Petr Machata (8):
elf_begin sets elf_errno for cases that the file is completely unreadable
Accept DW_AT_GNU_call_site_* as attributes that hold location expressions
Rename read_ubyte_unaligned_inc to read_addr_unaligned_inc
readelf: Fix typo in a check in handle_relocs_rela
Drop unused field struct Dwarf_Files_s.cu
Support .debug_macro
Test cases for .debug_macro support
Change calling convention of dwarf_getmacros to allow opcode 0xff
Ulrich Drepper (1):
avoid scary command output
9 years, 4 months
[COMMITTED] tests: Don't match libfunc symbol on ppc64 in run-deleted.sh testcase.
by Mark Wielaard
For PPC64 we need access to the OPD table which we get through the shdrs
but for the deleted-lib we only have phdrs. So we don't have the name of
the function. But since we should find the EH_FRAME through phdrs just
fine, we can unwind into main. Skip the libfunc name check for now till
we find a nice way to enable the lookup without opd:
https://bugzilla.redhat.com/show_bug.cgi?id=1176238
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
tests/ChangeLog | 4 ++++
tests/run-deleted.sh | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 94058fd..59048f6 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,9 @@
2014-12-19 Mark Wielaard <mjw(a)redhat.com>
+ * run-deleted.sh: Don't check libfunc on ppc64.
+
+2014-12-19 Mark Wielaard <mjw(a)redhat.com>
+
* vdsosyms.c (vdso_seen): Removed.
(vdso_syms): New global.
(module_callback): Set and check vdso_syms.
diff --git a/tests/run-deleted.sh b/tests/run-deleted.sh
index 95d9444..2b5a9a8 100755
--- a/tests/run-deleted.sh
+++ b/tests/run-deleted.sh
@@ -38,5 +38,11 @@ cat bt bt.err
kill -9 $pid
wait
check_native_unsupported bt.err deleted
-grep -qw libfunc bt
+# For PPC64 we need access to the OPD table which we get through the shdrs
+# (see backends/ppc64_init.c) but for the deleted-lib we only have phdrs.
+# So we don't have the name of the function. But since we should find
+# the EH_FRAME through phdrs just fine, we can unwind into main.
+if test "`uname -m`" != "ppc64"; then
+ grep -qw libfunc bt
+fi
grep -qw main bt
--
1.8.3.1
9 years, 4 months
[COMMITTED] libdwfl: Remove p_align sanity check from elf_from_memory.
by Mark Wielaard
In commit f15bcd "elf_from_remote_memory should use pagesize, not p_align"
we already relaxed the p_align sanity check to allow alignment of the
segment against the pagesize since that is what the glibc dynamic linker
actually does. But on some architectures the kernel inserts a vdso with
a completely bogus p_align for some PT_LOAD segments. So just drop the
whole sanity check and allow anything since we won't use p_align, but
always already use pagesize anyway.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdwfl/ChangeLog | 4 ++++
libdwfl/elf-from-memory.c | 14 +++++---------
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index f6db301..3d3edc5 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2014-12-19 Mark Wielaard <mjw(a)redhat.com>
+
+ * elf-from-memory.c (handle_segment): Remove palign sanity check.
+
2014-12-18 Mark Wielaard <mjw(a)redhat.com>
* relocate.c (resolve_symbol): Make sure symstrdata->d_buf != NULL.
diff --git a/libdwfl/elf-from-memory.c b/libdwfl/elf-from-memory.c
index df9fbe6..b35fac7 100644
--- a/libdwfl/elf-from-memory.c
+++ b/libdwfl/elf-from-memory.c
@@ -206,12 +206,10 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
found_base yet). Returns true if sanity checking failed,
false otherwise. */
inline bool handle_segment (GElf_Addr vaddr, GElf_Off offset,
- GElf_Xword filesz, GElf_Xword memsz,
- GElf_Xword palign)
+ GElf_Xword filesz, GElf_Xword memsz)
{
- /* Sanity check the alignment requirements. */
- if ((palign & (pagesize - 1)) != 0
- || ((vaddr - offset) & (palign - 1)) != 0)
+ /* Sanity check the segment load aligns with the pagesize. */
+ if (((vaddr - offset) & (pagesize - 1)) != 0)
return true;
GElf_Off segment_end = ((offset + filesz + pagesize - 1)
@@ -238,8 +236,7 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
for (uint_fast16_t i = 0; i < phnum; ++i)
if (phdrs.p32[i].p_type == PT_LOAD)
if (handle_segment (phdrs.p32[i].p_vaddr, phdrs.p32[i].p_offset,
- phdrs.p32[i].p_filesz, phdrs.p32[i].p_memsz,
- phdrs.p32[i].p_align))
+ phdrs.p32[i].p_filesz, phdrs.p32[i].p_memsz))
goto bad_elf;
break;
@@ -250,8 +247,7 @@ elf_from_remote_memory (GElf_Addr ehdr_vma,
for (uint_fast16_t i = 0; i < phnum; ++i)
if (phdrs.p64[i].p_type == PT_LOAD)
if (handle_segment (phdrs.p64[i].p_vaddr, phdrs.p64[i].p_offset,
- phdrs.p64[i].p_filesz, phdrs.p64[i].p_memsz,
- phdrs.p64[i].p_align))
+ phdrs.p64[i].p_filesz, phdrs.p64[i].p_memsz))
goto bad_elf;
break;
--
1.8.3.1
9 years, 4 months
[COMMITTED] tests: vdsosyms should not fail for architectures that don't have a vdso.
by Mark Wielaard
Not finding a vdso is not fatal. But there should be no errors trying.
And if the vdso is found, then getting the symbol table shouldn't fail.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
tests/ChangeLog | 7 +++++++
tests/vdsosyms.c | 15 ++++++++-------
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 89336da..94058fd 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,12 @@
2014-12-19 Mark Wielaard <mjw(a)redhat.com>
+ * vdsosyms.c (vdso_seen): Removed.
+ (vdso_syms): New global.
+ (module_callback): Set and check vdso_syms.
+ (main): Return value depends on vdso_syms.
+
+2014-12-19 Mark Wielaard <mjw(a)redhat.com>
+
* backtrace-subr.sh (check_native_unsupported): Relax special ARM
grep a little.
* run-deleted.sh: Call check_native_unsupported.
diff --git a/tests/vdsosyms.c b/tests/vdsosyms.c
index d04f36a..c1f8d89 100644
--- a/tests/vdsosyms.c
+++ b/tests/vdsosyms.c
@@ -34,7 +34,7 @@ main (int argc __attribute__ ((unused)), char **argv)
return 77;
}
#else /* __linux__ */
-static bool vdso_seen = false;
+static int vdso_syms = 0;
static int
module_callback (Dwfl_Module *mod, void **userdata __attribute__((unused)),
@@ -42,15 +42,15 @@ module_callback (Dwfl_Module *mod, void **userdata __attribute__((unused)),
void *arg __attribute__((unused)))
{
/* We can only recognize the vdso by inspecting the "magic name". */
+ printf ("module name: %s\n", name);
if (strncmp ("[vdso: ", name, 7) == 0)
{
- int syms = dwfl_module_getsymtab (mod);
- printf ("vdso syms: %d\n", syms);
- if (syms < 0)
+ vdso_syms = dwfl_module_getsymtab (mod);
+ printf ("vdso syms: %d\n", vdso_syms);
+ if (vdso_syms < 0)
error (2, 0, "dwfl_module_getsymtab: %s", dwfl_errmsg (-1));
- vdso_seen = true;
- for (int i = 0; i < syms; i++)
+ for (int i = 0; i < vdso_syms; i++)
{
GElf_Sym sym;
GElf_Addr addr;
@@ -102,7 +102,8 @@ main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
if (dwfl_getmodules (dwfl, module_callback, NULL, 0) != 0)
error (1, 0, "dwfl_getmodules: %s", dwfl_errmsg (-1));
- return vdso_seen ? 0 : -1;
+ /* No symbols is ok, then we haven't seen the vdso at all on this arch. */
+ return vdso_syms >= 0 ? 0 : -1;
}
#endif /* ! __linux__ */
--
1.8.3.1
9 years, 4 months
[COMMITTED] tests: run-deleted.sh should SKIP if arch doesn't support unwinding.
by Mark Wielaard
Also relax the special ARM needs DWARF check a little to account for eu-stack
error output.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
tests/ChangeLog | 6 ++++++
tests/backtrace-subr.sh | 2 +-
tests/run-deleted.sh | 9 +++++----
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2c3ba87..89336da 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-19 Mark Wielaard <mjw(a)redhat.com>
+
+ * backtrace-subr.sh (check_native_unsupported): Relax special ARM
+ grep a little.
+ * run-deleted.sh: Call check_native_unsupported.
+
2014-12-18 Mark Wielaard <mjw(a)redhat.com>
* Makefile.am (EXTRA_DIST): Add testfile-macros-0xff.bz2.
diff --git a/tests/backtrace-subr.sh b/tests/backtrace-subr.sh
index 1d3d6d4..f04721c 100644
--- a/tests/backtrace-subr.sh
+++ b/tests/backtrace-subr.sh
@@ -87,7 +87,7 @@ check_native_unsupported()
# and we can fall back on .debug_frame for the CFI.
case "`uname -m`" in
arm* )
- if grep 'dwfl_thread_getframes: No DWARF information found' $err; then
+ if egrep 'dwfl_thread_getframes(.*)No DWARF information found' $err; then
echo >&2 $testname: arm needs debuginfo installed for all libraries
exit 77
fi
diff --git a/tests/run-deleted.sh b/tests/run-deleted.sh
index 8c4d928..95d9444 100755
--- a/tests/run-deleted.sh
+++ b/tests/run-deleted.sh
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. $srcdir/test-subr.sh
+. $srcdir/backtrace-subr.sh
tempfiles deleted deleted-lib.so
cp -p ${abs_builddir}/deleted ${abs_builddir}/deleted-lib.so .
@@ -28,14 +28,15 @@ unset VALGRIND_CMD
pid=$(testrun ${abs_builddir}/deleted)
sleep 1
rm -f deleted deleted-lib.so
-tempfiles bt
+tempfiles bt bt.err
set VALGRIND_CMD="$OLD_VALGRIND_CMD"
# It may have non-zero exit code with:
# .../elfutils/src/stack: dwfl_thread_getframes tid 26376 at 0x4006c8 in .../elfutils/tests/deleted: no matching address range
-testrun ${abs_top_builddir}/src/stack -p $pid >bt || true
-cat bt
+testrun ${abs_top_builddir}/src/stack -p $pid 1>bt 2>bt.err || true
+cat bt bt.err
kill -9 $pid
wait
+check_native_unsupported bt.err deleted
grep -qw libfunc bt
grep -qw main bt
--
1.8.3.1
9 years, 4 months