summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-03-23 18:45:05 +0100
committerPetr Machata <pmachata@redhat.com>2011-03-23 18:45:05 +0100
commit86a4c3e51f26ff72156ced7f8a1334f19d66b25f (patch)
treea68e3866ca89523100542c40a84cf708bd9b4c21
parent3e010bdf21ebb6b8c88cbfe88986bbe20fdee4df (diff)
parent4e606b469ec251f625d2e3f4572e3d2a8ecaa51e (diff)
downloadelfutils-86a4c3e51f26ff72156ced7f8a1334f19d66b25f.tar.gz
Merge branch 'dwarf' of ssh://git.fedorahosted.org/git/elfutils into dwarf
-rw-r--r--NEWS4
-rw-r--r--backends/ChangeLog10
-rw-r--r--backends/alpha_init.c4
-rw-r--r--backends/alpha_symbol.c32
-rw-r--r--libdw/ChangeLog34
-rw-r--r--libdw/dwarf.h11
-rw-r--r--libdw/dwarf_begin_elf.c83
-rw-r--r--libdw/dwarf_child.c21
-rw-r--r--libdw/dwarf_end.c24
-rw-r--r--libdw/dwarf_tag.c6
-rw-r--r--libdw/libdwP.h11
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/dwfl_module_getdwarf.c4
-rw-r--r--libebl/ChangeLog9
-rw-r--r--libebl/Makefile.am3
-rw-r--r--libebl/ebl-hooks.h6
-rw-r--r--libebl/eblopenbackend.c11
-rw-r--r--libebl/eblstother.c64
-rw-r--r--libebl/libebl.h3
-rw-r--r--src/ChangeLog49
-rw-r--r--src/dwarfstrings.c40
-rw-r--r--src/elflint.c2
-rw-r--r--src/readelf.c112
-rw-r--r--tests/ChangeLog15
-rw-r--r--tests/Makefile.am15
-rw-r--r--tests/dwarf-getstring.c85
-rw-r--r--tests/rerequest_tag.c54
-rwxr-xr-xtests/run-dwarf-getstring.sh133
-rwxr-xr-xtests/run-readelf-twofiles.sh32
-rwxr-xr-xtests/run-rerequest_tag.sh32
-rw-r--r--tests/testfile56.bz2bin0 -> 2768 bytes
31 files changed, 858 insertions, 56 deletions
diff --git a/NEWS b/NEWS
index 115261e7..e4b2402f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+Version 0.153
+
+libdw: Support reading .zdebug_* DWARF sections compressed via zlib.
+
Version 0.152
Various build and warning nits fixed for newest GCC and Autoconf.
diff --git a/backends/ChangeLog b/backends/ChangeLog
index 7865338f..744d1d55 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,13 @@
+2011-03-09 Mark Wielaard <mjw@redhat.com>
+
+ * alpha_init.c (alpha_init): Initialize check_st_other_bits hook.
+ * alpha_symbol.c (alpha_check_st_other_bits): New function.
+
+2011-03-09 Roland McGrath <roland@redhat.com>
+
+ * alpha_symbol.c (alpha_check_special_symbol): New function.
+ * alpha_init.c (alpha_init): Initialize hook.
+
2010-11-08 Roland McGrath <roland@redhat.com>
* i386_retval.c (loc_intreg): Typo fix.
diff --git a/backends/alpha_init.c b/backends/alpha_init.c
index 1ca99abc..30fe5c6c 100644
--- a/backends/alpha_init.c
+++ b/backends/alpha_init.c
@@ -1,5 +1,5 @@
/* Initialization of Alpha specific backend library.
- Copyright (C) 2002, 2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2002-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -56,6 +56,8 @@ alpha_init (elf, machine, eh, ehlen)
HOOK (eh, return_value_location);
HOOK (eh, machine_section_flag_check);
HOOK (eh, check_special_section);
+ HOOK (eh, check_special_symbol);
+ HOOK (eh, check_st_other_bits);
HOOK (eh, register_info);
HOOK (eh, core_note);
HOOK (eh, auxv_info);
diff --git a/backends/alpha_symbol.c b/backends/alpha_symbol.c
index aa45c61e..5d25d3e4 100644
--- a/backends/alpha_symbol.c
+++ b/backends/alpha_symbol.c
@@ -1,5 +1,5 @@
/* Alpha specific symbolic name handling.
- Copyright (C) 2002,2005,2007,2008 Red Hat, Inc.
+ Copyright (C) 2002-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -30,6 +30,7 @@
#include <elf.h>
#include <stddef.h>
+#include <string.h>
#define BACKEND alpha_
#include "libebl_CPU.h"
@@ -121,3 +122,32 @@ alpha_check_special_section (Ebl *ebl,
return false;
}
+
+/* Check whether given symbol's st_value and st_size are OK despite failing
+ normal checks. */
+bool
+alpha_check_special_symbol (Elf *elf __attribute__ ((unused)),
+ GElf_Ehdr *ehdr __attribute__ ((unused)),
+ const GElf_Sym *sym __attribute__ ((unused)),
+ const char *name,
+ const GElf_Shdr *destshdr __attribute__ ((unused)))
+{
+ if (name == NULL)
+ return false;
+
+ if (strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+ /* On Alpha any place in the section is valid. */
+ return true;
+
+ return false;
+}
+
+/* Check whether only valid bits are set on the st_other symbol flag.
+ Standard ST_VISIBILITY have already been masked off. */
+bool
+alpha_check_st_other_bits (unsigned char st_other)
+{
+ return ((((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_NOPV)
+ || ((st_other & STO_ALPHA_STD_GPLOAD) == STO_ALPHA_STD_GPLOAD))
+ && (st_other &~ STO_ALPHA_STD_GPLOAD) == 0);
+}
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 704dc116..bc417020 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -35,6 +35,40 @@
* c++/line_info.cc (dwarf::directory_table): Remove methods.
* c++/edit-values.cc (dwarf_data::line_table): Update instantiation.
+2011-03-22 Mark Wielaard <mjw@redhat.com>
+
+ * dwarf.h: Add DW_TAG_GNU_call_site,
+ DW_TAG_GNU_call_site_parameter,
+ 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,
+ DW_AT_GNU_tail_call,
+ DW_AT_GNU_all_tail_call_sites,
+ DW_AT_GNU_all_call_sites,
+ DW_AT_GNU_all_source_call_sites,
+ and DW_OP_GNU_entry_value.
+
+2011-03-10 Petr Machata <pmachata@redhat.com>
+
+ * libdw/dwarf_tag.c (__libdw_findabbrev): Reject requests for
+ abbreviation with code 0.
+
+2011-03-09 Petr Machata <pmachata@redhat.com>
+
+ * libdw/dwarf_child.c (dwarf_child): Check for section overrun.
+
+2011-02-23 Roland McGrath <roland@redhat.com>
+
+ * libdwP.h (struct Dwarf) [USE_ZLIB]: New member sectiondata_gzip_mask.
+ Declare __libdw_free_zdata.
+ * dwarf_end.c [USE_ZLIB] (__libdw_free_zdata): New function.
+ (dwarf_end): Call it.
+
+ * dwarf_begin_elf.c (valid_p): Likewise.
+ (check_section, scngrp_read): Likewise.
+ (check_section) [USE_ZLIB]: Grok .z* flavors of sections.
+
2010-10-13 Roland McGrath <roland@redhat.com>
* dwarf.h: Add DW_LANG_Go.
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 940ffe33..c0dcbdd2 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -128,6 +128,8 @@ enum
DW_TAG_GNU_template_template_param = 0x4106,
DW_TAG_GNU_template_parameter_pack = 0x4107,
DW_TAG_GNU_formal_parameter_pack = 0x4108,
+ DW_TAG_GNU_call_site = 0x4109,
+ DW_TAG_GNU_call_site_parameter = 0x410a,
DW_TAG_hi_user = 0xffff
};
@@ -277,6 +279,14 @@ enum
DW_AT_GNU_shared_locks_required = 0x210e,
DW_AT_GNU_odr_signature = 0x210f,
DW_AT_GNU_template_name = 0x2110,
+ DW_AT_GNU_call_site_value = 0x2111,
+ DW_AT_GNU_call_site_data_value = 0x2112,
+ DW_AT_GNU_call_site_target = 0x2113,
+ DW_AT_GNU_call_site_target_clobbered = 0x2114,
+ DW_AT_GNU_tail_call = 0x2115,
+ DW_AT_GNU_all_tail_call_sites = 0x2116,
+ DW_AT_GNU_all_call_sites = 0x2117,
+ DW_AT_GNU_all_source_call_sites = 0x2118,
DW_AT_hi_user = 0x3fff
};
@@ -476,6 +486,7 @@ enum
DW_OP_GNU_uninit = 0xf0,
DW_OP_GNU_encoded_addr = 0xf1,
DW_OP_GNU_implicit_pointer = 0xf2,
+ DW_OP_GNU_entry_value = 0xf3,
DW_OP_lo_user = 0xe0, /* Implementation-defined range start. */
DW_OP_hi_user = 0xff /* Implementation-defined range end. */
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index b5fb7c91..9ec7d51f 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -1,5 +1,5 @@
/* Create descriptor from ELF descriptor for processing file.
- Copyright (C) 2002-2010 Red Hat, Inc.
+ Copyright (C) 2002-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -61,6 +61,13 @@
#include "libdwP.h"
+#if USE_ZLIB
+# include <endian.h>
+# define crc32 loser_crc32
+# include <zlib.h>
+# undef crc32
+#endif
+
/* Section names. */
static const char dwarf_scnnames[IDX_last][17] =
@@ -117,6 +124,7 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
{
/* The section name must be valid. Otherwise is the ELF file
invalid. */
+ __libdw_free_zdata (result);
__libdw_seterrno (DWARF_E_INVALID_ELF);
free (result);
return NULL;
@@ -141,6 +149,76 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
break;
}
+#if USE_ZLIB
+ else if (scnname[0] == '.' && scnname[1] == 'z'
+ && strcmp (&scnname[2], &dwarf_scnnames[cnt][1]) == 0)
+ {
+ /* A compressed section. */
+
+ if (unlikely (result->sectiondata[cnt] != NULL))
+ /* A section appears twice. That's bad. We ignore the section. */
+ break;
+
+ /* Get the section data. */
+ Elf_Data *data = elf_getdata (scn, NULL);
+ if (data != NULL && data->d_size != 0)
+ {
+ /* There is a 12-byte header of "ZLIB" followed by
+ an 8-byte big-endian size. */
+
+ if (unlikely (data->d_size < 4 + 8)
+ || unlikely (memcmp (data->d_buf, "ZLIB", 4) != 0))
+ break;
+
+ uint64_t size;
+ memcpy (&size, data->d_buf + 4, sizeof size);
+ size = be64toh (size);
+
+ Elf_Data *zdata = malloc (sizeof (Elf_Data) + size);
+ if (unlikely (zdata == NULL))
+ break;
+
+ zdata->d_buf = &zdata[1];
+ zdata->d_type = ELF_T_BYTE;
+ zdata->d_version = EV_CURRENT;
+ zdata->d_size = size;
+ zdata->d_off = 0;
+ zdata->d_align = 1;
+
+ z_stream z =
+ {
+ .next_in = data->d_buf + 4 + 8,
+ .avail_in = data->d_size - 4 - 8,
+ .next_out = zdata->d_buf,
+ .avail_out = zdata->d_size
+ };
+ int zrc = inflateInit (&z);
+ while (z.avail_in > 0 && likely (zrc == Z_OK))
+ {
+ z.next_out = zdata->d_buf + (zdata->d_size - z.avail_out);
+ zrc = inflate (&z, Z_FINISH);
+ if (unlikely (zrc != Z_STREAM_END))
+ {
+ zrc = Z_DATA_ERROR;
+ break;
+ }
+ zrc = inflateReset (&z);
+ }
+ if (likely (zrc == Z_OK))
+ zrc = inflateEnd (&z);
+
+ if (unlikely (zrc != Z_OK) || unlikely (z.avail_out != 0))
+ free (zdata);
+ else
+ {
+ result->sectiondata[cnt] = zdata;
+ result->sectiondata_gzip_mask |= 1U << cnt;
+ }
+ }
+
+ break;
+ }
+#endif
return result;
}
@@ -159,6 +237,7 @@ valid_p (Dwarf *result)
if (likely (result != NULL)
&& unlikely (result->sectiondata[IDX_debug_info] == NULL))
{
+ __libdw_free_zdata (result);
__libdw_seterrno (DWARF_E_NO_DWARF);
free (result);
result = NULL;
@@ -189,6 +268,7 @@ scngrp_read (Dwarf *result, Elf *elf, GElf_Ehdr *ehdr, Elf_Scn *scngrp)
if (data == NULL)
{
/* We cannot read the section content. Fail! */
+ __libdw_free_zdata (result);
free (result);
return NULL;
}
@@ -204,6 +284,7 @@ scngrp_read (Dwarf *result, Elf *elf, GElf_Ehdr *ehdr, Elf_Scn *scngrp)
{
/* A section group refers to a non-existing section. Should
never happen. */
+ __libdw_free_zdata (result);
__libdw_seterrno (DWARF_E_INVALID_ELF);
free (result);
return NULL;
diff --git a/libdw/dwarf_child.c b/libdw/dwarf_child.c
index 0080cf9d..1ec3704e 100644
--- a/libdw/dwarf_child.c
+++ b/libdw/dwarf_child.c
@@ -1,5 +1,5 @@
/* Return child of current DIE.
- Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Red Hat, Inc.
+ Copyright (C) 2003-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -175,18 +175,27 @@ dwarf_child (die, result)
if (addr == NULL)
return -1;
+ /* RESULT can be the same as DIE. So preserve what we need. */
+ struct Dwarf_CU *cu = die->cu;
+
/* It's kosher (just suboptimal) to have a null entry first thing (7.5.3).
So if this starts with ULEB128 of 0 (even with silly encoding of 0),
it is a kosher null entry and we do not really have any children. */
const unsigned char *code = addr;
- while (unlikely (*code == 0x80))
- ++code;
+ const unsigned char *endp = (cu->dbg->sectiondata[IDX_debug_info]->d_buf
+ + cu->dbg->sectiondata[IDX_debug_info]->d_size);
+ while (1)
+ {
+ if (unlikely (code >= endp)) /* Truncated section. */
+ return 1;
+ if (unlikely (*code == 0x80))
+ ++code;
+ else
+ break;
+ }
if (unlikely (*code == '\0'))
return 1;
- /* RESULT can be the same as DIE. So preserve what we need. */
- struct Dwarf_CU *cu = die->cu;
-
/* Clear the entire DIE structure. This signals we have not yet
determined any of the information. */
memset (result, '\0', sizeof (Dwarf_Die));
diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c
index ec10542e..1e733cae 100644
--- a/libdw/dwarf_end.c
+++ b/libdw/dwarf_end.c
@@ -1,5 +1,5 @@
/* Release debugging handling context.
- Copyright (C) 2002-2010 Red Hat, Inc.
+ Copyright (C) 2002-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -54,6 +54,8 @@
#include <search.h>
#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
#include "libdwP.h"
#include "cfi.h"
@@ -76,6 +78,24 @@ cu_free (void *arg)
}
+#if USE_ZLIB
+void
+internal_function
+__libdw_free_zdata (Dwarf *dwarf)
+{
+ unsigned int gzip_mask = dwarf->sectiondata_gzip_mask;
+ while (gzip_mask != 0)
+ {
+ int i = ffs (gzip_mask);
+ assert (i > 0);
+ --i;
+ assert (i < IDX_last);
+ free (dwarf->sectiondata[i]);
+ gzip_mask &= ~(1U << i);
+ }
+}
+#endif
+
int
dwarf_end (dwarf)
Dwarf *dwarf;
@@ -106,6 +126,8 @@ dwarf_end (dwarf)
/* Free the pubnames helper structure. */
free (dwarf->pubnames_sets);
+ __libdw_free_zdata (dwarf);
+
/* Free the ELF descriptor if necessary. */
if (dwarf->free_elf)
elf_end (dwarf->elf);
diff --git a/libdw/dwarf_tag.c b/libdw/dwarf_tag.c
index 15183d2d..6d9090c6 100644
--- a/libdw/dwarf_tag.c
+++ b/libdw/dwarf_tag.c
@@ -1,5 +1,5 @@
/* Return tag of given DIE.
- Copyright (C) 2003, 2004, 2005, 2006, 2008 Red Hat, Inc.
+ Copyright (C) 2003-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2003.
@@ -61,6 +61,10 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
{
Dwarf_Abbrev *abb;
+ /* Abbreviation code can never have a value of 0. */
+ if (unlikely (code == 0))
+ return DWARF_END_ABBREV;
+
/* See whether the entry is already in the hash table. */
abb = Dwarf_Abbrev_Hash_find (&cu->abbrev_hash, code, NULL);
if (abb == NULL)
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 58f3f908..0baa0e38 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -150,6 +150,11 @@ struct Dwarf
/* The section data. */
Elf_Data *sectiondata[IDX_last];
+#if USE_ZLIB
+ /* The 1 << N bit is set if sectiondata[N] is malloc'd decompressed data. */
+ unsigned int sectiondata_gzip_mask:IDX_last;
+#endif
+
/* True if the file has a byte order different from the host. */
bool other_byte_order;
@@ -392,6 +397,12 @@ extern void *__libdw_allocate (Dwarf *dbg, size_t minsize, size_t align)
/* Default OOM handler. */
extern void __libdw_oom (void) __attribute ((noreturn, visibility ("hidden")));
+#if USE_ZLIB
+extern void __libdw_free_zdata (Dwarf *dwarf) internal_function;
+#else
+# define __libdw_free_zdata(dwarf) ((void) (dwarf))
+#endif
+
/* Allocate the internal data for a unit not seen before. */
extern struct Dwarf_CU *__libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
__nonnull_attribute__ (1) internal_function;
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 0cbeb850..3edc11be 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-08 Roland McGrath <roland@redhat.com>
+
+ * dwfl_module_getdwarf.c (open_elf): Clear errno before CBFAIL.
+ Reported by Kurt Roeckx <kurt@roeckx.be>.
+
2011-02-11 Roland McGrath <roland@redhat.com>
* linux-kernel-modules.c (try_kernel_name): Try .gz, .bz2, .xz
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index dbb1d604..9c677131 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -61,6 +61,10 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
{
if (file->elf == NULL)
{
+ /* CBFAIL uses errno if it's set, so clear it first in case we don't
+ set it with an open failure below. */
+ errno = 0;
+
/* If there was a pre-primed file name left that the callback left
behind, try to open that file name. */
if (file->fd < 0 && file->name != NULL)
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index 96f70ff8..bec6511f 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,12 @@
+2011-03-10 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (gen_SOURCES): Add eblstother.c.
+ * eblstother.c: New file.
+ * ebl-hooks.h: Add check_st_other_bits hook.
+ * eblopenbackend.c (default_check_st_other_bits): New function.
+ (fill_defaults): Hook default_check_st_other_bits.
+ * libebl.h (ebl_check_st_other_bits): New prototype.
+
2010-07-07 Roland McGrath <roland@redhat.com>
* eblopenbackend.c (default_debugscn_p): Match .gdb_index section.
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index d157195e..ced5668b 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -50,7 +50,8 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \
ebl_check_special_symbol.c eblbsspltp.c eblretval.c \
eblreginfo.c eblnonerelocp.c eblrelativerelocp.c \
eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c \
- ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c
+ ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c \
+ eblstother.c
libebl_a_SOURCES = $(gen_SOURCES)
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index 59e73c54..82c6c640 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -1,5 +1,5 @@
/* Backend hook signatures internal interface for libebl.
- Copyright (C) 2000-2010 Red Hat, Inc.
+ Copyright (C) 2000-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -144,6 +144,10 @@ bool EBLHOOK(relative_reloc_p) (int);
bool EBLHOOK(check_special_symbol) (Elf *, GElf_Ehdr *, const GElf_Sym *,
const char *, const GElf_Shdr *);
+/* Check whether only valid bits are set on the st_other symbol flag.
+ Standard ST_VISIBILITY have already been masked off. */
+bool EBLHOOK(check_st_other_bits) (unsigned char st_other);
+
/* Check if backend uses a bss PLT in this file. */
bool EBLHOOK(bss_plt_p) (Elf *, GElf_Ehdr *);
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index e11ff067..24f472ce 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -1,5 +1,5 @@
/* Generate ELF backend handle.
- Copyright (C) 2000-2010 Red Hat, Inc.
+ Copyright (C) 2000-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -202,6 +202,7 @@ static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
const GElf_Sym *sym,
const char *name,
const GElf_Shdr *destshdr);
+static bool default_check_st_other_bits (unsigned char st_other);
static bool default_check_special_section (Ebl *, int,
const GElf_Shdr *, const char *);
static bool default_bss_plt_p (Elf *elf, GElf_Ehdr *ehdr);
@@ -253,6 +254,7 @@ fill_defaults (Ebl *result)
result->none_reloc_p = default_none_reloc_p;
result->relative_reloc_p = default_relative_reloc_p;
result->check_special_symbol = default_check_special_symbol;
+ result->check_st_other_bits = default_check_st_other_bits;
result->bss_plt_p = default_bss_plt_p;
result->return_value_location = default_return_value_location;
result->register_info = default_register_info;
@@ -698,6 +700,13 @@ default_check_special_symbol (Elf *elf __attribute__ ((unused)),
}
static bool
+default_check_st_other_bits (unsigned char st_other __attribute__ ((unused)))
+{
+ return false;
+}
+
+
+static bool
default_bss_plt_p (Elf *elf __attribute__ ((unused)),
GElf_Ehdr *ehdr __attribute__ ((unused)))
{
diff --git a/libebl/eblstother.c b/libebl/eblstother.c
new file mode 100644
index 00000000..ba8c9dac
--- /dev/null
+++ b/libebl/eblstother.c
@@ -0,0 +1,64 @@
+/* Check st_other flag.
+ Copyright (C) 2011 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.
+
+ In addition, as a special exception, Red Hat, Inc. gives You the
+ additional right to link the code of Red Hat elfutils with code licensed
+ under any Open Source Initiative certified open source license
+ (http://www.opensource.org/licenses/index.php) which requires the
+ distribution of source code with any binary distribution and to
+ distribute linked combinations of the two. Non-GPL Code permitted under
+ this exception must only link to the code of Red Hat elfutils through
+ those well defined interfaces identified in the file named EXCEPTION
+ found in the source code files (the "Approved Interfaces"). The files
+ of Non-GPL Code may instantiate templates or use macros or inline
+ functions from the Approved Interfaces without causing the resulting
+ work to be covered by the GNU General Public License. Only Red Hat,
+ Inc. may make changes or additions to the list of Approved Interfaces.
+ Red Hat's grant of this exception is conditioned upon your not adding
+ any new exceptions. If you wish to add a new Approved Interface or
+ exception, please contact Red Hat. You must obey the GNU General Public
+ License in all respects for all of the Red Hat elfutils code and other
+ code used in conjunction with Red Hat elfutils except the Non-GPL Code
+ covered by this exception. If you modify this file, you may extend this
+ exception to your version of the file, but you are not obligated to do
+ so. If you do not wish to provide this exception without modification,
+ you must delete this exception statement from your version and license
+ this file solely under the GPL without exception.
+
+ 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>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libeblP.h>
+
+
+bool
+ebl_check_st_other_bits (ebl, st_other)
+ Ebl *ebl;
+ unsigned char st_other;
+{
+ return ((st_other ^ GELF_ST_VISIBILITY (st_other)) == 0
+ || ebl->check_st_other_bits (st_other ^ GELF_ST_VISIBILITY (st_other)));
+}
diff --git a/libebl/libebl.h b/libebl/libebl.h
index c94ad78f..b4307282 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -168,6 +168,9 @@ extern bool ebl_check_special_symbol (Ebl *ebl, GElf_Ehdr *ehdr,
const GElf_Sym *sym, const char *name,
const GElf_Shdr *destshdr);
+/* Check whether only valid bits are set on the st_other symbol flag. */
+extern bool ebl_check_st_other_bits (Ebl *ebl, unsigned char st_other);
+
/* Return combined section header flags value. */
extern GElf_Word ebl_sh_flags_combine (Ebl *ebl, GElf_Word flags1,
GElf_Word flags2);
diff --git a/src/ChangeLog b/src/ChangeLog
index 096c4e7a..e2796595 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,52 @@
+2011-03-22 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (dwarf_tag_string): Support DW_TAG_GNU_call_site
+ and DW_TAG_GNU_call_site_parameter.
+ (dwarf_attr_string): Support 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,
+ DW_AT_GNU_tail_call,
+ DW_AT_GNU_all_tail_call_sites,
+ DW_AT_GNU_all_call_sites,
+ and DW_AT_GNU_all_source_call_sites.
+ (print_ops): Handle DW_OP_GNU_entry_value.
+ (attr_callback): Handle DW_AT_GNU_call_site_value,
+ DW_AT_GNU_call_site_data_value,
+ DW_AT_GNU_call_site_target,
+ and DW_AT_GNU_call_site_target_clobbered.
+
+2011-03-10 Mark Wielaard <mjw@redhat.com>
+
+ * elflint.c (check_symtab): Use ebl_check_st_other_bits.
+
+2011-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * readelf.c (reset_listptr): Clear TABLE->TABLE.
+
+2011-02-25 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (dwarf_attr_string): Add DW_AT_GNU_* handling.
+ (dwarf_form_string): Properly format and return unknown form.
+
+2011-02-23 Roland McGrath <roland@redhat.com>
+
+ * readelf.c (section_name): New function.
+ (print_debug_abbrev_section): Use it instead of constant.
+ (print_debug_aranges_section): Likewise.
+ (print_debug_ranges_section): Likewise.
+ (print_debug_units): Likewise.
+ (print_debug_line_section): Likewise.
+ (print_debug_loc_section): Likewise.
+ (print_debug_macinfo_section): Likewise.
+ (print_debug_pubnames_section): Likewise.
+ (print_debug_str_section): Likewise.
+ (print_debug) [USE_ZLIB]: Match .zdebug_* sections too.
+ (print_debug_abbrev_section): Use decoded d_size, not sh_size.
+ (print_debug_str_section): Likewise.
+
+ * readelf.c (dwarf_attr_string): Grok DW_AT_GNU_odr_signature.
+
2011-02-11 Roland McGrath <roland@redhat.com>
* elfcmp.c (verbose): New variable.
diff --git a/src/dwarfstrings.c b/src/dwarfstrings.c
index 3909e131..91933f01 100644
--- a/src/dwarfstrings.c
+++ b/src/dwarfstrings.c
@@ -149,6 +149,14 @@ dwarf_tag_string (unsigned int tag)
result = "GNU_formal_parameter_pack";
break;
+ case DW_TAG_GNU_call_site:
+ result = "DW_TAG_GNU_call_site";
+ break;
+
+ case DW_TAG_GNU_call_site_parameter:
+ result = "DW_TAG_GNU_call_site_parameter";
+ break;
+
default:
if (tag < DW_TAG_lo_user)
snprintf (buf, sizeof buf, gettext ("unknown tag %hx"), tag);
@@ -407,6 +415,38 @@ dwarf_attr_string (unsigned int attrnum)
result = "GNU_template_name";
break;
+ case DW_AT_GNU_call_site_value:
+ result = "GNU_call_site_value";
+ break;
+
+ case DW_AT_GNU_call_site_data_value:
+ result = "GNU_call_site_data_value";
+ break;
+
+ case DW_AT_GNU_call_site_target:
+ result = "GNU_call_site_target";
+ break;
+
+ case DW_AT_GNU_call_site_target_clobbered:
+ result = "GNU_call_site_target_clobbered";
+ break;
+
+ case DW_AT_GNU_tail_call:
+ result = "GNU_tail_call";
+ break;
+
+ case DW_AT_GNU_all_tail_call_sites:
+ result = "GNU_all_tail_call_sites";
+ break;
+
+ case DW_AT_GNU_all_call_sites:
+ result = "GNU_all_call_sites";
+ break;
+
+ case DW_AT_GNU_all_source_call_sites:
+ result = "GNU_all_source_call_sites";
+ break;
+
default:
if (attrnum < DW_AT_lo_user)
snprintf (buf, sizeof buf, gettext ("unknown attribute %hx"),
diff --git a/src/elflint.c b/src/elflint.c
index c1227355..5c8d0aaf 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -1011,7 +1011,7 @@ section [%2d] '%s': _DYNAMIC symbol size %" PRIu64 " does not match dynamic segm
ERROR (gettext ("\
section [%2d] '%s': symbol %zu: symbol in dynamic symbol table with non-default visibility\n"),
idx, section_name (ebl, idx), cnt);
- if ((sym->st_other ^ GELF_ST_VISIBILITY (sym->st_other)) != 0)
+ if (! ebl_check_st_other_bits (ebl, sym->st_other))
ERROR (gettext ("\
section [%2d] '%s': symbol %zu: unknown bit set in st_other\n"),
idx, section_name (ebl, idx), cnt);
diff --git a/src/readelf.c b/src/readelf.c
index 30c2be09..d4442756 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1,5 +1,5 @@
/* Print information from ELF file in human-readable form.
- Copyright (C) 1999-2010 Red Hat, Inc.
+ Copyright (C) 1999-2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 1999.
@@ -1155,6 +1155,13 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr)
}
+static const char *
+section_name (Ebl *ebl, GElf_Ehdr *ehdr, GElf_Shdr *shdr)
+{
+ return elf_strptr (ebl->elf, ehdr->e_shstrndx, shdr->sh_name) ?: "???";
+}
+
+
static void
handle_scngrp (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
{
@@ -3351,6 +3358,7 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
[DW_OP_implicit_value] = "implicit_value",
[DW_OP_stack_value] = "stack_value",
[DW_OP_GNU_implicit_pointer] = "GNU_implicit_pointer",
+ [DW_OP_GNU_entry_value] = "GNU_entry_value",
};
if (len == 0)
@@ -3615,6 +3623,21 @@ print_ops (Dwfl_Module *dwflmod, Dwarf *dbg, int indent, int indentrest,
offset += 1 + (data - start);
break;
+ case DW_OP_GNU_entry_value:
+ /* Size plus expression block. */
+ start = data;
+ NEED (1);
+ get_uleb128 (uleb, data); /* XXX check overrun */
+ printf ("%*s[%4" PRIuMAX "] %s:\n",
+ indent, "", (uintmax_t) offset, known[op]);
+ NEED (uleb);
+ print_ops (dwflmod, dbg, indent + 6, indent + 6, vers,
+ addrsize, offset_size, uleb, data);
+ data += uleb;
+ CONSUME (data - start);
+ offset += 1 + (data - start);
+ break;
+
default:
/* No Operand. */
if (op < sizeof known / sizeof known[0] && known[op] != NULL)
@@ -3696,6 +3719,7 @@ static void
reset_listptr (struct listptr_table *table)
{
free (table->table);
+ table->table = NULL;
table->n = table->alloc = 0;
}
@@ -3777,16 +3801,16 @@ skip_listptr_hole (struct listptr_table *table, size_t *idxp,
static void
print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr __attribute__ ((unused)),
+ Ebl *ebl, GElf_Ehdr *ehdr,
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"
" [ Code]\n"),
- elf_ndxscn (scn), ".debug_abbrev", (uint64_t) shdr->sh_offset);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset);
Dwarf_Off offset = 0;
- while (offset < shdr->sh_size)
+ while (offset < dbg->sectiondata[IDX_debug_abbrev]->d_size)
{
printf (gettext ("\nAbbreviation section at offset %" PRIu64 ":\n"),
offset);
@@ -3848,8 +3872,7 @@ print_debug_abbrev_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
takes care of it. */
static void
print_debug_aranges_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr, Elf_Scn *scn,
+ Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn,
GElf_Shdr *shdr, Dwarf *dbg)
{
Dwarf_Aranges *aranges;
@@ -3866,7 +3889,8 @@ print_debug_aranges_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
"\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 " contains %zu entries:\n",
cnt),
- elf_ndxscn (scn), ".debug_aranges", (uint64_t) shdr->sh_offset, cnt);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset, cnt);
/* Compute floor(log16(cnt)). */
size_t tmp = cnt;
@@ -3904,8 +3928,8 @@ print_debug_aranges_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
/* Print content of DWARF .debug_ranges section. */
static void
print_debug_ranges_section (Dwfl_Module *dwflmod,
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr,
+ Ebl *ebl, GElf_Ehdr *ehdr,
+ Elf_Scn *scn, GElf_Shdr *shdr,
Dwarf *dbg)
{
Elf_Data *data = elf_rawdata (scn, NULL);
@@ -3919,7 +3943,8 @@ print_debug_ranges_section (Dwfl_Module *dwflmod,
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), ".debug_ranges", (uint64_t) shdr->sh_offset);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset);
sort_listptr (&known_rangelistptr, "rangelistptr");
size_t listptr_idx = 0;
@@ -4864,6 +4889,10 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
case DW_AT_frame_base:
case DW_AT_return_addr:
case DW_AT_static_link:
+ 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:
notice_listptr (section_loc, &known_loclistptr,
cbargs->addrsize, cbargs->offset_size, num);
if (!cbargs->silent)
@@ -4993,6 +5022,11 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
case DW_AT_count:
case DW_AT_lower_bound:
case DW_AT_upper_bound:
+ 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:
+ putchar ('\n');
print_ops (cbargs->dwflmod, cbargs->dbg,
12 + level * 2, 12 + level * 2,
cbargs->version, cbargs->addrsize, cbargs->offset_size,
@@ -5015,14 +5049,12 @@ attr_callback (Dwarf_Attribute *attrp, void *arg)
static void
print_debug_units (Dwfl_Module *dwflmod,
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr __attribute__ ((unused)),
- Elf_Scn *scn,
- GElf_Shdr *shdr, Dwarf *dbg,
- bool debug_types)
+ Ebl *ebl, GElf_Ehdr *ehdr,
+ Elf_Scn *scn, GElf_Shdr *shdr,
+ Dwarf *dbg, bool debug_types)
{
const bool silent = !(print_debug_sections & section_info);
- const char *secname = debug_types ? ".debug_types" : ".debug_info";
+ const char *secname = section_name (ebl, ehdr, shdr);
if (!silent)
printf (gettext ("\
@@ -5185,13 +5217,13 @@ print_debug_types_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
static void
-print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl,
- GElf_Ehdr *ehdr __attribute__ ((unused)),
+print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), ".debug_line", (uint64_t) shdr->sh_offset);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset);
if (shdr->sh_size == 0)
return;
@@ -5224,7 +5256,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl,
{
invalid_data:
error (0, 0, gettext ("invalid data in section [%zu] '%s'"),
- elf_ndxscn (scn), ".debug_line");
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
return;
}
unit_length = read_8ubyte_unaligned_inc (dbg, linep);
@@ -5292,7 +5324,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl,
error (0, 0,
gettext ("invalid data at offset %tu in section [%zu] '%s'"),
linep - (const unsigned char *) data->d_buf,
- elf_ndxscn (scn), ".debug_line");
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr));
linep = lineendp;
continue;
}
@@ -5675,7 +5707,7 @@ advance address by fixed value %u to %s\n"),
static void
print_debug_loc_section (Dwfl_Module *dwflmod,
- Ebl *ebl __attribute__ ((unused)), GElf_Ehdr *ehdr,
+ Ebl *ebl, GElf_Ehdr *ehdr,
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
Elf_Data *data = elf_rawdata (scn, NULL);
@@ -5689,7 +5721,8 @@ print_debug_loc_section (Dwfl_Module *dwflmod,
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), ".debug_loc", (uint64_t) shdr->sh_offset);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset);
sort_listptr (&known_loclistptr, "loclistptr");
size_t listptr_idx = 0;
@@ -5798,13 +5831,13 @@ mac_compare (const void *p1, const void *p2)
static void
print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr __attribute__ ((unused)),
+ Ebl *ebl, GElf_Ehdr *ehdr,
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\
\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), ".debug_macinfo", (uint64_t) shdr->sh_offset);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset);
putc_unlocked ('\n', stdout);
/* There is no function in libdw to iterate over the raw content of
@@ -5970,12 +6003,12 @@ print_pubnames (Dwarf *dbg __attribute__ ((unused)), Dwarf_Global *global,
/* Print the known exported symbols in the DWARF section '.debug_pubnames'. */
static void
print_debug_pubnames_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr __attribute__ ((unused)),
+ Ebl *ebl, GElf_Ehdr *ehdr,
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"),
- elf_ndxscn (scn), ".debug_pubnames", (uint64_t) shdr->sh_offset);
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset);
int n = 0;
(void) dwarf_getpubnames (dbg, print_pubnames, &n, 0);
@@ -5984,12 +6017,13 @@ print_debug_pubnames_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
/* Print the content of the DWARF string section '.debug_str'. */
static void
print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
- Ebl *ebl __attribute__ ((unused)),
- GElf_Ehdr *ehdr __attribute__ ((unused)),
+ Ebl *ebl, GElf_Ehdr *ehdr,
Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
{
+ const size_t sh_size = dbg->sectiondata[IDX_debug_str]->d_size;
+
/* Compute floor(log16(shdr->sh_size)). */
- GElf_Addr tmp = shdr->sh_size;
+ GElf_Addr tmp = sh_size;
int digits = 1;
while (tmp >= 16)
{
@@ -6001,12 +6035,12 @@ print_debug_str_section (Dwfl_Module *dwflmod __attribute__ ((unused)),
printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"
" %*s String\n"),
elf_ndxscn (scn),
- ".debug_str", (uint64_t) shdr->sh_offset,
+ section_name (ebl, ehdr, shdr), (uint64_t) shdr->sh_offset,
/* TRANS: the debugstr| prefix makes the string unique. */
digits + 2, sgettext ("debugstr|Offset"));
Dwarf_Off offset = 0;
- while (offset < shdr->sh_size)
+ while (offset < sh_size)
{
size_t len;
const char *str = dwarf_getstring (dbg, offset, &len);
@@ -6352,7 +6386,13 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
int n;
for (n = 0; n < ndebug_sections; ++n)
- if (strcmp (name, debug_sections[n].name) == 0)
+ if (strcmp (name, debug_sections[n].name) == 0
+#if USE_ZLIB
+ || (name[0] == '.' && name[1] == 'z'
+ && debug_sections[n].name[1] == 'd'
+ && strcmp (&name[2], &debug_sections[n].name[1]) == 0)
+#endif
+ )
{
if ((print_debug_sections | implicit_debug_sections)
& debug_sections[n].bitmask)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 8a39c5bf..0d7d15ac 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -2,6 +2,21 @@
* Makefile.am (TESTS): Put the slow dwarfcmp tests last.
+2011-04-02 Marek Polacek <mpolacek@redhat.com>
+
+ * dwarf-getstring.c: New test.
+ * run-dwarf-getstring.sh: And its wrapper.
+ * Makefile.am (EXTRA_DIST): Add and update all.
+
+2011-02-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * Makefile.am (TESTS): Add run-readelf-twofiles.sh.
+ * run-readelf-twofiles.sh: New file.
+
+2011-02-25 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (BUILD_RPATH): Be consistent in naming.
+
2011-02-02 Josh Stone <jistone@redhat.com>
* run-prelink-addr-test.sh: Add testfile55, 32 and 64-bit.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 641bce2e..d8176441 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,7 +28,7 @@ include $(top_srcdir)/config/eu.am
if MUDFLAP
BUILD_RPATH = \$$ORIGIN/../backends
else
-BUILT_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf
+BUILD_RPATH = \$$ORIGIN/../libasm:\$$ORIGIN/../libdw:\$$ORIGIN/../backends:\$$ORIGIN/../libelf
endif
AM_LDFLAGS =
@@ -42,7 +42,7 @@ AM_LDFLAGS += -Wl,-rpath-link,../libasm:../libdw:../libelf
endif
if TESTS_RPATH
-AM_LDFLAGS += -Wl,-rpath,$(BUILT_RPATH)
+AM_LDFLAGS += -Wl,-rpath,$(BUILD_RPATH)
tests_rpath = yes
else
tests_rpath = no
@@ -60,7 +60,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
dwfl-addr-sect dwfl-bug-report early-offscn \
dwfl-bug-getmodules dwarf-getmacros addrcfi \
dwarf-print dwarf_edit dwarf_edit_output \
- test-flag-nobits
+ test-flag-nobits dwarf-getstring rerequest_tag
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -80,7 +80,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
run-find-prologues.sh run-allregs.sh \
run-readelf-test1.sh run-readelf-test2.sh run-readelf-test3.sh \
- run-readelf-test4.sh \
+ run-readelf-test4.sh run-readelf-twofiles.sh \
run-native-test.sh run-bug1-test.sh \
dwfl-bug-addr-overflow run-addrname-test.sh \
dwfl-bug-fd-leak dwfl-bug-report \
@@ -90,6 +90,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-dwarf-attributes.sh \
run-dwarf_edit.sh dwarf_edit_output \
run-test-flag-nobits.sh run-prelink-addr-test.sh \
+ run-dwarf-getstring.sh run-rerequest_tag.sh \
run-dwarflint-self.sh \
run-dwarfcmp-self.sh run-dwarfcmp-test-self.sh
# run-show-ciefde.sh
@@ -127,6 +128,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-dwarf-getmacros.sh run-test-flag-nobits.sh \
run-dwarfcmp-self.sh run-dwarfcmp-test-self.sh \
run-dwarflint-self.sh run-dwarf-attributes.sh run-dwarf_edit.sh \
+ run-dwarf-getstring.sh \
testfile15.bz2 testfile15.debug.bz2 \
testfile16.bz2 testfile16.debug.bz2 \
testfile17.bz2 testfile17.debug.bz2 \
@@ -164,7 +166,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile54-64.prelink.so.bz2 testfile54-64.noshdrs.so.bz2 \
testfile55-32.bz2 testfile55-32.debug.bz2 \
testfile55-32.prelink.bz2 testfile55-64.bz2 \
- testfile55-64.debug.bz2 testfile55-64.prelink.bz2
+ testfile55-64.debug.bz2 testfile55-64.prelink.bz2 \
+ testfile56.bz2
installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
bindir=$(DESTDIR)$(bindir) \
@@ -268,8 +271,10 @@ dwfl_bug_getmodules_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
sha1_tst_LDADD = $(libeu) $(libmudflap)
dwarf_getmacros_LDADD = $(libdw) $(libmudflap)
+dwarf_getstring_LDADD = $(libdw) $(libmudflap)
addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
test_flag_nobits_LDADD = $(libelf) $(libmudflap)
+rerequest_tag_LDADD = $(libdw) $(libmudflap)
if GCOV
check: check-am coverage
diff --git a/tests/dwarf-getstring.c b/tests/dwarf-getstring.c
new file mode 100644
index 00000000..66ab329d
--- /dev/null
+++ b/tests/dwarf-getstring.c
@@ -0,0 +1,85 @@
+/* Copyright (C) 2011 Red Hat, Inc.
+ This file is part of Red Hat elfutils.
+ Written by Marek Polacek <mpolacek@redhat.com>, 2011.
+
+ 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>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include ELFUTILS_HEADER(dwfl)
+#include <assert.h>
+#include <dwarf.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+
+int
+main (int argc, char *argv[])
+{
+ int cnt;
+
+ for (cnt = 1; cnt < argc; ++cnt)
+ {
+ Dwarf_Off offset = 0;
+ size_t len;
+
+ int fd = open64 (argv[cnt], O_RDONLY);
+ if (fd == -1)
+ {
+ printf ("cannot open '%s': %m\n", argv[cnt]);
+ return 1;
+ }
+
+ Dwarf *dbg = dwarf_begin (fd, DWARF_C_READ);
+ if (dbg == NULL)
+ {
+ printf ("%s not usable: %s\n", argv[cnt], dwarf_errmsg (-1));
+ close (fd);
+ return 1;
+ }
+
+ /* Try to use NULL Dwarf object. */
+ const char *str = dwarf_getstring (NULL, offset, &len);
+ assert (str == NULL);
+
+ /* Use insane offset. */
+ str = dwarf_getstring (dbg, ~0UL, &len);
+ assert (str == NULL);
+
+ /* Now do some real work. */
+ for (int i = 0; i < 100; ++i)
+ {
+ str = dwarf_getstring (dbg, offset, &len);
+ puts (str);
+
+ /* Advance. */
+ offset += len + 1;
+ }
+
+ close (fd);
+ }
+
+ return 0;
+}
diff --git a/tests/rerequest_tag.c b/tests/rerequest_tag.c
new file mode 100644
index 00000000..bd76731e
--- /dev/null
+++ b/tests/rerequest_tag.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2011 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(dw)
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+
+int
+main (int argc, char **argv)
+{
+ assert (argc > 1);
+
+ int i = open (argv[1], O_RDONLY);
+ assert (i >= 0);
+
+ Dwarf *dw = dwarf_begin (i, DWARF_C_READ);
+ assert (dw != NULL);
+
+ Dwarf_Die die_mem, *die;
+ die = dwarf_offdie (dw, 11, &die_mem);
+ assert (die == &die_mem);
+ assert (dwarf_tag (die) == 0);
+
+ die = dwarf_offdie (dw, 11, &die_mem);
+ assert (die == &die_mem);
+ assert (dwarf_tag (die) == 0);
+
+ return 0;
+}
diff --git a/tests/run-dwarf-getstring.sh b/tests/run-dwarf-getstring.sh
new file mode 100755
index 00000000..df90a584
--- /dev/null
+++ b/tests/run-dwarf-getstring.sh
@@ -0,0 +1,133 @@
+#! /bin/sh
+# Copyright (C) 2011 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>.
+
+. $srcdir/test-subr.sh
+
+testfiles testfile11
+
+testrun_compare ./dwarf-getstring testfile11 <<\EOF
+_ZNSbIwSt11char_traitsIwESaIwEE13_S_copy_charsEPwS3_S3_
+itimerspec
+_G_int32_t
+_IO_last_state
+antiquities
+_ZNSbIwSt11char_traitsIwESaIwEEpLEw
+insert
+_ZNSbIwSt11char_traitsIwESaIwEE12_M_leak_hardEv
+__lockkind
+_ZNKSbIwSt11char_traitsIwESaIwEE8capacityEv
+_ZNSs7_M_leakEv
+_M_ref_count
+_ZNSt11char_traitsIwE6assignEPwjw
+_ZNKSs13find_first_ofEPKcj
+._14
+._15
+._16
+._17
+_ZNKSs16find_last_not_ofEPKcj
+_G_iconv_t
+_ZN10__gnu_test9gnu_obj_2IlEaSERKS1_
+_ZN11random_dataaSERKS_
+_ZNSt11char_traitsIcE7not_eofERKi
+__class_type_info
+tm_sec
+_ZNKSbIwSt11char_traitsIwESaIwEE5c_strEv
+__rlim64_t
+seek
+pthread_mutex_t
+_ZNSs5eraseEN9__gnu_cxx17__normal_iteratorIPcSsEE
+_ZNSsaSEc
+__not_va_list__
+_ZNKSs12find_last_ofEPKcj
+_ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_S2_S2_
+__gconv_info
+_ZNSt11__ios_flags12_S_showpointE
+output_iterator_tag
+gnu_obj_2<long int>
+_ZNSs6insertEjRKSsjj
+_ZN13__type_traitsIbEaSERKS0_
+_ZNKSbIwSt11char_traitsIwESaIwEE4copyEPwjj
+_ZNSs9_M_mutateEjjj
+__ios_flags
+short unsigned int
+_ZNKSs4findEPKcj
+compare
+_ZNSbIwSt11char_traitsIwESaIwEE4_Rep7_M_grabERKS1_S5_
+tm_yday
+unsigned char
+__stacksize
+__gconv_init_fct
+_IO_FILE
+__counter
+._26
+._27
+bidirectional_iterator_tag
+._29
+it_value
+const_iterator
+_ZNSt11__ios_flags6_S_outE
+_M_set_leaked
+_Is_integer<unsigned int>
+__value
+timeval
+_IO_jump_t
+_ZN11sched_paramaSERKS_
+__normal_iterator<char*,std::basic_string<char, std::char_traits<char>, std::allocator<char> > >
+_ZNSs4_Rep7_M_grabERKSaIcES2_
+_wide_vtable
+__codecvt_destr
+_STL_mutex_lock
+_ZNSt24__default_alloc_templateILb1ELi0EE17_S_freelist_indexEj
+_ZNSbIwSt11char_traitsIwESaIwEE7replaceEjjjw
+_ZN17__gconv_step_dataaSERKS_
+__w_stopval
+__int64_t
+__type_traits<double>
+~_Lock
+_ZNKSbIwSt11char_traitsIwESaIwEE5beginEv
+ptrdiff_t
+test
+_Integral
+cookie_seek_function_t
+__vmi_class_type_info
+_ZNSs7replaceEjjjc
+__int32_t
+register_t
+~_STL_auto_lock
+_ZNKSbIwSt11char_traitsIwESaIwEE16find_last_not_ofEPKwjj
+__arg
+_ZNSs7replaceEjjPKcj
+_ZNSbIwSt11char_traitsIwESaIwEE7replaceEjjRKS2_jj
+_ZNKSbIwSt11char_traitsIwESaIwEE12find_last_ofEPKwjj
+_ZN11_Is_integerImEaSERKS0_
+__default_alloc_template
+_S_hex
+__statep
+_ZNSt11char_traitsIwE2ltERKwS2_
+_M_p
+_ZNKSs4sizeEv
+EOF
+
+exit 0
diff --git a/tests/run-readelf-twofiles.sh b/tests/run-readelf-twofiles.sh
new file mode 100755
index 00000000..4255587c
--- /dev/null
+++ b/tests/run-readelf-twofiles.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2011 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>.
+
+. $srcdir/test-subr.sh
+
+testfiles testfile14
+
+testrun >/dev/null ../src/readelf -w testfile14 testfile14
+
+exit 0
diff --git a/tests/run-rerequest_tag.sh b/tests/run-rerequest_tag.sh
new file mode 100755
index 00000000..1636fbfe
--- /dev/null
+++ b/tests/run-rerequest_tag.sh
@@ -0,0 +1,32 @@
+#! /bin/sh
+# Copyright (C) 2011 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>.
+
+. $srcdir/test-subr.sh
+
+testfiles testfile56
+
+testrun ./rerequest_tag testfile56
+
+exit 0
diff --git a/tests/testfile56.bz2 b/tests/testfile56.bz2
new file mode 100644
index 00000000..0e2257cf
--- /dev/null
+++ b/tests/testfile56.bz2
Binary files differ