summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2011-05-03 11:45:27 +0200
committerMark Wielaard <[email protected]>2011-05-03 11:45:27 +0200
commite88df500789902ffa14dbaefc9bc1daad7e6dc05 (patch)
treed1eadb45274d6260d5ef87382e7c61f4fdb70f23
parent54e3eae4dc7ff5276b709f21785a30abea4a9d1a (diff)
parentbcdb09dcb97d00a1718507f64302f57f92558af0 (diff)
Merge branch 'master' into dwarf
Conflicts: tests/Makefile.am: New tests merged.
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_child.c4
-rw-r--r--libdw/dwarf_tag.c5
-rw-r--r--libdwfl/ChangeLog6
-rw-r--r--libdwfl/linux-kernel-modules.c4
-rw-r--r--libebl/ChangeLog13
-rw-r--r--libebl/ebl-hooks.h3
-rw-r--r--libebl/ebldynamictagname.c2
-rw-r--r--libebl/eblobjnote.c90
-rw-r--r--libebl/eblobjnotetypename.c14
-rw-r--r--libebl/eblopenbackend.c7
-rw-r--r--libebl/eblrelativerelocp.c2
-rw-r--r--libebl/libebl.h5
-rw-r--r--libelf/libelfP.h2
-rw-r--r--src/ChangeLog22
-rw-r--r--src/arlib.c2
-rw-r--r--src/elf32-i386.script2
-rw-r--r--src/ld.c2
-rw-r--r--src/ldgeneric.c5
-rw-r--r--src/readelf.c239
-rw-r--r--tests/ChangeLog9
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/alldts.c275
-rwxr-xr-xtests/run-alldts.sh106
-rwxr-xr-xtests/run-rerequest_tag.sh3
-rw-r--r--tests/testfile57.bz2bin0 -> 593 bytes
26 files changed, 794 insertions, 43 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index bc417020..e2fcb6e1 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2011-04-26 Mark Wielaard <[email protected]>
+
+ * dwarf_child (dwarf_child): Sanity check end of section against
+ cu_data () of die->cu.
+
2011-02-24 Roland McGrath <[email protected]>
* libdw.map (ELFUTILS_PRIVATE_TMP): New version set;
diff --git a/libdw/dwarf_child.c b/libdw/dwarf_child.c
index 1ec3704e..0c2df004 100644
--- a/libdw/dwarf_child.c
+++ b/libdw/dwarf_child.c
@@ -177,13 +177,13 @@ dwarf_child (die, result)
/* RESULT can be the same as DIE. So preserve what we need. */
struct Dwarf_CU *cu = die->cu;
+ Elf_Data *cu_sec = cu_data (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;
- const unsigned char *endp = (cu->dbg->sectiondata[IDX_debug_info]->d_buf
- + cu->dbg->sectiondata[IDX_debug_info]->d_size);
+ const unsigned char *endp = (cu_sec->d_buf + cu_sec->d_size);
while (1)
{
if (unlikely (code >= endp)) /* Truncated section. */
diff --git a/libdw/dwarf_tag.c b/libdw/dwarf_tag.c
index 6d9090c6..fa8b384c 100644
--- a/libdw/dwarf_tag.c
+++ b/libdw/dwarf_tag.c
@@ -90,6 +90,11 @@ __libdw_findabbrev (struct Dwarf_CU *cu, unsigned int code)
break;
}
+ /* This is our second (or third, etc.) call to __libdw_findabbrev
+ and the code is invalid. */
+ if (unlikely (abb == NULL))
+ abb = DWARF_END_ABBREV;
+
return abb;
}
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 3edc11be..abad77b5 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-11 Mark Wielaard <[email protected]>
+
+ * linux-kernel-modules.c (vmlinux_suffixes): Guard definition
+ by check for zlib, bzlib or lzma defines to check it isn't empty.
+ (try_kernel_name): Use same guard for use of vmlinux_suffixes.
+
2011-03-08 Roland McGrath <[email protected]>
* dwfl_module_getdwarf.c (open_elf): Clear errno before CBFAIL.
diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c
index f3d9af10..ae74a497 100644
--- a/libdwfl/linux-kernel-modules.c
+++ b/libdwfl/linux-kernel-modules.c
@@ -78,6 +78,7 @@
#define MODULE_SECT_NAME_LEN 32 /* Minimum any linux/module.h has had. */
+#if defined (USE_ZLIB) || defined (USE_BZLIB) || defined (USE_LZMA)
static const char *vmlinux_suffixes[] =
{
#ifdef USE_ZLIB
@@ -90,6 +91,7 @@ static const char *vmlinux_suffixes[] =
".xz",
#endif
};
+#endif
/* Try to open the given file as it is or under the debuginfo directory. */
static int
@@ -127,6 +129,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug)
}
}
+#if defined (USE_ZLIB) || defined (USE_BZLIB) || defined (USE_LZMA)
if (fd < 0)
for (size_t i = 0;
i < sizeof vmlinux_suffixes / sizeof vmlinux_suffixes[0];
@@ -145,6 +148,7 @@ try_kernel_name (Dwfl *dwfl, char **fname, bool try_debug)
}
}
}
+#endif
if (fd < 0)
{
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index bec6511f..ac2160de 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,16 @@
+2011-04-26 Mark Wielaard <[email protected]>
+
+ * libebl.h (ebl_object_note_type_name): Add const char *name arg.
+ * eblhooks.h (object_note_type_name): Likewise.
+ * eblopenbackend.c (default_object_note_type_name): Likewise.
+ * eblobjnotetypename.c (ebl_object_note_type_name): Likewise.
+ And print version if name is "stapsdt".
+ * eblobjnote.c (ebl_object_note): Add output for "stapsdt" notes.
+
+2011-03-21 Marek Polacek <[email protected]>
+
+ * ebldynamictagname.c: Fix typo in TLSDESC_GOT.
+
2011-03-10 Mark Wielaard <[email protected]>
* Makefile.am (gen_SOURCES): Add eblstother.c.
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index 82c6c640..a04b3db0 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -111,7 +111,8 @@ const char *EBLHOOK(osabi_name) (int, char *, size_t);
const char *EBLHOOK(core_note_type_name) (uint32_t, char *, size_t);
/* Name of a note entry type for object files. */
-const char *EBLHOOK(object_note_type_name) (uint32_t, char *, size_t);
+const char *EBLHOOK(object_note_type_name) (const char *, uint32_t,
+ char *, size_t);
/* Describe core note format. */
int EBLHOOK(core_note) (const GElf_Nhdr *, const char *,
diff --git a/libebl/ebldynamictagname.c b/libebl/ebldynamictagname.c
index e0972ede..cb65b929 100644
--- a/libebl/ebldynamictagname.c
+++ b/libebl/ebldynamictagname.c
@@ -100,7 +100,7 @@ ebl_dynamic_tag_name (ebl, tag, buf, len)
{
static const char *addrrntags[] =
{
- "GNU_HASH", "TLSDESC_PLT", "TLSDESC_DOT",
+ "GNU_HASH", "TLSDESC_PLT", "TLSDESC_GOT",
"GNU_CONFLICT", "GNU_LIBLIST", "CONFIG", "DEPAUDIT", "AUDIT",
"PLTPAD", "MOVETAB", "SYMINFO"
};
diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c
index b56c6cbc..ec5bb7da 100644
--- a/libebl/eblobjnote.c
+++ b/libebl/eblobjnote.c
@@ -1,5 +1,5 @@
/* Print contents of object file note.
- Copyright (C) 2002, 2007, 2009 Red Hat, Inc.
+ Copyright (C) 2002, 2007, 2009, 2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <[email protected]>, 2002.
@@ -68,6 +68,94 @@ ebl_object_note (ebl, name, type, descsz, desc)
{
if (! ebl->object_note (name, type, descsz, desc))
/* The machine specific function did not know this type. */
+
+ if (strcmp ("stapsdt", name) == 0)
+ {
+ if (type != 3)
+ {
+ printf (gettext ("unknown SDT version %u\n"), type);
+ return;
+ }
+
+ /* Descriptor starts with three addresses, pc, base ref and
+ semaphore. Then three zero terminated strings provider,
+ name and arguments. */
+
+ union
+ {
+ Elf64_Addr a64[3];
+ Elf32_Addr a32[3];
+ } addrs;
+
+ size_t addrs_size = gelf_fsize (ebl->elf, ELF_T_ADDR, 3, EV_CURRENT);
+ if (descsz < addrs_size + 3)
+ {
+ invalid_sdt:
+ printf (gettext ("invalid SDT probe descriptor\n"));
+ return;
+ }
+
+ Elf_Data src =
+ {
+ .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
+ .d_buf = (void *) desc, .d_size = addrs_size
+ };
+
+ Elf_Data dst =
+ {
+ .d_type = ELF_T_ADDR, .d_version = EV_CURRENT,
+ .d_buf = &addrs, .d_size = addrs_size
+ };
+
+ if (gelf_xlatetom (ebl->elf, &dst, &src,
+ elf_getident (ebl->elf, NULL)[EI_DATA]) == NULL)
+ {
+ printf ("%s\n", elf_errmsg (-1));
+ return;
+ }
+
+ const char *provider = desc + addrs_size;
+ const char *pname = memchr (provider, '\0', desc + descsz - provider);
+ if (pname == NULL)
+ goto invalid_sdt;
+
+ ++pname;
+ const char *args = memchr (pname, '\0', desc + descsz - pname);
+ if (args == NULL ||
+ memchr (++args, '\0', desc + descsz - pname) != desc + descsz - 1)
+ goto invalid_sdt;
+
+ GElf_Addr pc;
+ GElf_Addr base;
+ GElf_Addr sem;
+ if (gelf_getclass (ebl->elf) == ELFCLASS32)
+ {
+ pc = addrs.a32[0];
+ base = addrs.a32[1];
+ sem = addrs.a32[2];
+ }
+ else
+ {
+ pc = addrs.a64[0];
+ base = addrs.a64[1];
+ sem = addrs.a64[2];
+ }
+
+ printf (gettext (" PC: "));
+ printf ("%#" PRIx64 ",", pc);
+ printf (gettext (" Base: "));
+ printf ("%#" PRIx64 ",", base);
+ printf (gettext (" Semaphore: "));
+ printf ("%#" PRIx64 "\n", sem);
+ printf (gettext (" Provider: "));
+ printf ("%s,", provider);
+ printf (gettext (" Name: "));
+ printf ("%s,", pname);
+ printf (gettext (" Args: "));
+ printf ("'%s'\n", args);
+ return;
+ }
+
switch (type)
{
case NT_GNU_BUILD_ID:
diff --git a/libebl/eblobjnotetypename.c b/libebl/eblobjnotetypename.c
index 8e99dbb4..0ceb5a87 100644
--- a/libebl/eblobjnotetypename.c
+++ b/libebl/eblobjnotetypename.c
@@ -1,5 +1,5 @@
/* Return note type name.
- Copyright (C) 2002, 2007, 2009 Red Hat, Inc.
+ Copyright (C) 2002, 2007, 2009, 2011 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <[email protected]>, 2002.
@@ -54,20 +54,28 @@
#include <inttypes.h>
#include <stdio.h>
+#include <string.h>
#include <libeblP.h>
const char *
-ebl_object_note_type_name (ebl, type, buf, len)
+ebl_object_note_type_name (ebl, name, type, buf, len)
Ebl *ebl;
+ const char *name;
uint32_t type;
char *buf;
size_t len;
{
- const char *res = ebl->object_note_type_name (type, buf, len);
+ const char *res = ebl->object_note_type_name (name, type, buf, len);
if (res == NULL)
{
+ if (strcmp (name, "stapsdt") == 0)
+ {
+ snprintf (buf, len, "Version: %" PRIu32, type);
+ return buf;
+ }
+
static const char *knowntypes[] =
{
#define KNOWNSTYPE(name) [NT_##name] = #name
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 24f472ce..60e7f84a 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -184,8 +184,8 @@ static const char *default_osabi_name (int ignore, char *buf, size_t len);
static void default_destr (struct ebl *ignore);
static const char *default_core_note_type_name (uint32_t, char *buf,
size_t len);
-static const char *default_object_note_type_name (uint32_t, char *buf,
- size_t len);
+static const char *default_object_note_type_name (const char *name, uint32_t,
+ char *buf, size_t len);
static int default_core_note (const GElf_Nhdr *nhdr, const char *name,
GElf_Word *regs_offset, size_t *nregloc,
const Ebl_Register_Location **reglocs,
@@ -619,7 +619,8 @@ default_core_note (const GElf_Nhdr *nhdr __attribute__ ((unused)),
}
static const char *
-default_object_note_type_name (uint32_t ignore __attribute__ ((unused)),
+default_object_note_type_name (const char *name __attribute__ ((unused)),
+ uint32_t ignore __attribute__ ((unused)),
char *buf __attribute__ ((unused)),
size_t len __attribute__ ((unused)))
{
diff --git a/libebl/eblrelativerelocp.c b/libebl/eblrelativerelocp.c
index 8ea97b88..9c28b59c 100644
--- a/libebl/eblrelativerelocp.c
+++ b/libebl/eblrelativerelocp.c
@@ -1,4 +1,4 @@
-/* Check whether given relocation is a relocation relocation.
+/* Check whether given relocation is a relative relocation.
Copyright (C) 2006 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <[email protected]>, 2006.
diff --git a/libebl/libebl.h b/libebl/libebl.h
index b4307282..3a334024 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -184,8 +184,9 @@ extern const char *ebl_core_note_type_name (Ebl *ebl, uint32_t type, char *buf,
size_t len);
/* Return name of the note section type for an object file. */
-extern const char *ebl_object_note_type_name (Ebl *ebl, uint32_t type,
- char *buf, size_t len);
+extern const char *ebl_object_note_type_name (Ebl *ebl, const char *name,
+ uint32_t type, char *buf,
+ size_t len);
/* Print information about object note if available. */
extern void ebl_object_note (Ebl *ebl, const char *name, uint32_t type,
diff --git a/libelf/libelfP.h b/libelf/libelfP.h
index 2b8391bd..8f2f33a4 100644
--- a/libelf/libelfP.h
+++ b/libelf/libelfP.h
@@ -251,7 +251,7 @@ struct Elf_Scn
char *rawdata_base; /* The unmodified data of the section. */
char *data_base; /* The converted data of the section. */
- struct Elf_ScnList *list; /* Pointer the the section list element the
+ struct Elf_ScnList *list; /* Pointer to the section list element the
data is in. */
};
diff --git a/src/ChangeLog b/src/ChangeLog
index e2796595..a71eea82 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,25 @@
+2011-04-26 Mark Wielaard <[email protected]>
+
+ * readelf.c (handle_notes_data): Call ebl_object_note_type_name
+ with note name.
+
+2011-04-14 Mark Wielaard <[email protected]>
+
+ * readelf.c (options): Add gdb_index.
+ (section_e): Define section_gdb_index.
+ (parse_opt): Recognize gdb_index debug-dump argument.
+ (print_gdb_index_section): New function.
+ (print_debug): Add gdb_index to debug_sections.
+
+2011-03-24 Petr Machata <[email protected]>
+
+ * readelf.c (print_debug_line_section): Emit initial space for all
+ opcode lines. Print offset in front of each opcode.
+
+2011-03-22 Marek Polacek <[email protected]>
+
+ * readelf.c (handle_dynamic): Don't segfault at DT_PLTREL case.
+
2011-03-22 Mark Wielaard <[email protected]>
* readelf.c (dwarf_tag_string): Support DW_TAG_GNU_call_site
diff --git a/src/arlib.c b/src/arlib.c
index af98454c..c69a138f 100644
--- a/src/arlib.c
+++ b/src/arlib.c
@@ -61,7 +61,7 @@ arlib_init (void)
/* Using snprintf here has a problem: the call always wants to add a
NUL byte. We could use a trick whereby we specify the target
buffer size longer than it is and this would not actually fail,
- since all the fields are consecutive and we fill them in in
+ since all the fields are consecutive and we fill them in
sequence (i.e., the NUL byte gets overwritten). But
_FORTIFY_SOURCE=2 would not let us play these games. Therefore
we play it safe. */
diff --git a/src/elf32-i386.script b/src/elf32-i386.script
index a6cfffa1..2083278f 100644
--- a/src/elf32-i386.script
+++ b/src/elf32-i386.script
@@ -120,7 +120,7 @@ SEGMENT [RW]
is in. */
KEEP (*crtbegin.o(.ctors))
/* We don't want to include the .ctor section from
- from the crtend.o file until after the sorted ctors.
+ the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
diff --git a/src/ld.c b/src/ld.c
index 932496e1..a3b09349 100644
--- a/src/ld.c
+++ b/src/ld.c
@@ -1465,7 +1465,7 @@ static void
create_lscript_symbols (void)
{
/* Walk through the data from the linker script and generate all the
- symbols which are required to be present and and those marked
+ symbols which are required to be present and those marked
with PROVIDE if there is a undefined reference. */
if (ld_state.output_segments == NULL)
return;
diff --git a/src/ldgeneric.c b/src/ldgeneric.c
index d51b54fe..98bdc225 100644
--- a/src/ldgeneric.c
+++ b/src/ldgeneric.c
@@ -5854,9 +5854,8 @@ section index too large in dynamic symbol table"));
- the symbol is for a file
- it is not externally visible (internal, hidden)
- - if export_all_dynamic is not set and is only defined in
- the executable (i.e., it is defined, but not (also) in
- in DSO)
+ - export_all_dynamic is not set and the symbol is only defined
+ in the executable (i.e., it is defined, but not (also) in DSO)
Set symstrent[cnt] to NULL in case an entry is ignored. */
if (XELF_ST_TYPE (sym->st_info) == STT_FILE
diff --git a/src/readelf.c b/src/readelf.c
index d4442756..43dc5d92 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -94,8 +94,8 @@ static const struct argp_option options[] =
{ NULL, 0, NULL, 0, N_("Additional output selection:"), 0 },
{ "debug-dump", 'w', "SECTION", OPTION_ARG_OPTIONAL,
N_("Display DWARF section content. SECTION can be one of abbrev, "
- "aranges, frame, info, loc, line, ranges, pubnames, str, macinfo, "
- "or exception"), 0 },
+ "aranges, frame, gdb_index, info, loc, line, ranges, pubnames, str, "
+ "macinfo, or exception"), 0 },
{ "hex-dump", 'x', "SECTION", 0,
N_("Dump the uninterpreted contents of SECTION, by number or name"), 0 },
{ "strings", 'p', "SECTION", OPTION_ARG_OPTIONAL,
@@ -190,10 +190,11 @@ static enum section_e
section_macinfo = 256, /* .debug_macinfo */
section_ranges = 512, /* .debug_ranges */
section_exception = 1024, /* .eh_frame & al. */
+ section_gdb_index = 2048, /* .gdb_index */
section_all = (section_abbrev | section_aranges | section_frame
| section_info | section_line | section_loc
| section_pubnames | section_str | section_macinfo
- | section_ranges | section_exception)
+ | section_ranges | section_exception | section_gdb_index)
} print_debug_sections, implicit_debug_sections;
/* Select hex dumping of sections. */
@@ -404,6 +405,8 @@ parse_opt (int key, char *arg,
print_debug_sections |= section_macinfo;
else if (strcmp (arg, "exception") == 0)
print_debug_sections |= section_exception;
+ else if (strcmp (arg, "gdb_index") == 0)
+ print_debug_sections |= section_gdb_index;
else
{
fprintf (stderr, gettext ("Unknown DWARF debug section `%s'.\n"),
@@ -1446,8 +1449,10 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr)
printf ("%" PRId64 "\n", dyn->d_un.d_val);
break;
- case DT_PLTREL:
- puts (ebl_dynamic_tag_name (ebl, dyn->d_un.d_val, NULL, 0));
+ case DT_PLTREL:;
+ const char *tagname = ebl_dynamic_tag_name (ebl, dyn->d_un.d_val,
+ NULL, 0);
+ puts (tagname ?: "???");
break;
case DT_FLAGS:
@@ -5440,12 +5445,14 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
while (linep < lineendp)
{
+ size_t offset = linep - (const unsigned char *) data->d_buf;
unsigned int u128;
int s128;
/* Read the opcode. */
unsigned int opcode = *linep++;
+ printf (" [%6" PRIx64 "]", (uint64_t)offset);
/* Is this a special opcode? */
if (likely (opcode >= opcode_base))
{
@@ -5494,7 +5501,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
switch (opcode)
{
case DW_LNE_end_sequence:
- puts (gettext ("end of sequence"));
+ puts (gettext (" end of sequence"));
/* Reset the registers we care about. */
address = 0;
@@ -5511,7 +5518,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
address = read_8ubyte_unaligned_inc (dbg, linep);
{
char *a = format_dwarf_addr (dwflmod, 0, address);
- printf (gettext ("set address to %s\n"), a);
+ printf (gettext (" set address to %s\n"), a);
free (a);
}
break;
@@ -5533,7 +5540,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
get_uleb128 (filelength, linep);
printf (gettext ("\
-define new file: dir=%u, mtime=%" PRIu64 ", length=%" PRIu64 ", name=%s\n"),
+ define new file: dir=%u, mtime=%" PRIu64 ", length=%" PRIu64 ", name=%s\n"),
diridx, (uint64_t) mtime, (uint64_t) filelength,
fname);
}
@@ -5550,7 +5557,7 @@ define new file: dir=%u, mtime=%" PRIu64 ", length=%" PRIu64 ", name=%s\n"),
default:
/* Unknown, ignore it. */
- puts (gettext ("unknown opcode"));
+ puts (gettext (" unknown opcode"));
linep += len - 1;
break;
}
@@ -5574,10 +5581,10 @@ define new file: dir=%u, mtime=%" PRIu64 ", length=%" PRIu64 ", name=%s\n"),
char *a = format_dwarf_addr (dwflmod, 0, address);
if (show_op_index)
printf (gettext ("\
-advance address by %u to %s, op_index to %u\n"),
+ advance address by %u to %s, op_index to %u\n"),
op_addr_advance, a, op_index);
else
- printf (gettext ("advance address by %u to %s\n"),
+ printf (gettext (" advance address by %u to %s\n"),
op_addr_advance, a);
free (a);
}
@@ -5629,11 +5636,11 @@ advance address by %u to %s, op_index to %u\n"),
char *a = format_dwarf_addr (dwflmod, 0, address);
if (show_op_index)
printf (gettext ("\
-advance address by constant %u to %s, op_index to %u\n"),
+ advance address by constant %u to %s, op_index to %u\n"),
op_addr_advance, a, op_index);
else
printf (gettext ("\
-advance address by constant %u to %s\n"),
+ advance address by constant %u to %s\n"),
op_addr_advance, a);
free (a);
}
@@ -5651,7 +5658,7 @@ advance address by constant %u to %s\n"),
{
char *a = format_dwarf_addr (dwflmod, 0, address);
printf (gettext ("\
-advance address by fixed value %u to %s\n"),
+ advance address by fixed value %u to %s\n"),
u128, a);
free (a);
}
@@ -6318,6 +6325,205 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)),
}
}
+/* Print the content of the '.gdb_index' section.
+ http://sourceware.org/gdb/current/onlinedocs/gdb/Index-Section-Format.html
+*/
+static void
+print_gdb_index_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr,
+ Elf_Scn *scn, GElf_Shdr *shdr, Dwarf *dbg)
+{
+ printf (gettext ("\nGDB section [%2zu] '%s' at offset %#" PRIx64
+ " contains %" PRId64 " bytes :\n"),
+ elf_ndxscn (scn), section_name (ebl, ehdr, shdr),
+ (uint64_t) shdr->sh_offset, (uint64_t) shdr->sh_size);
+
+ Elf_Data *data = elf_rawdata (scn, NULL);
+
+ if (unlikely (data == NULL))
+ {
+ error (0, 0, gettext ("cannot get %s content: %s"),
+ ".gdb_index", elf_errmsg (-1));
+ return;
+ }
+
+ // .gdb_index is always in little endian.
+ Dwarf dummy_dbg = { .other_byte_order = MY_ELFDATA != ELFDATA2LSB };
+ dbg = &dummy_dbg;
+
+ const unsigned char *readp = data->d_buf;
+ const unsigned char *const dataend = readp + data->d_size;
+
+ if (unlikely (readp + 4 > dataend))
+ {
+ invalid_data:
+ error (0, 0, gettext ("invalid data"));
+ return;
+ }
+
+ int32_t vers = read_4ubyte_unaligned (dbg, readp);
+ printf (gettext (" Version: %" PRId32 "\n"), vers);
+
+ // The only difference between version 4 and version 5 is the
+ // hash used for generating the table.
+ if (vers < 4 || vers > 5)
+ {
+ printf (gettext (" unknown version, cannot parse section\n"));
+ return;
+ }
+
+ readp += 4;
+ if (unlikely (readp + 4 > dataend))
+ goto invalid_data;
+
+ uint32_t cu_off = read_4ubyte_unaligned (dbg, readp);
+ printf (gettext (" CU offset: %#" PRIx32 "\n"), cu_off);
+
+ readp += 4;
+ if (unlikely (readp + 4 > dataend))
+ goto invalid_data;
+
+ uint32_t tu_off = read_4ubyte_unaligned (dbg, readp);
+ printf (gettext (" TU offset: %#" PRIx32 "\n"), tu_off);
+
+ readp += 4;
+ if (unlikely (readp + 4 > dataend))
+ goto invalid_data;
+
+ uint32_t addr_off = read_4ubyte_unaligned (dbg, readp);
+ printf (gettext (" address offset: %#" PRIx32 "\n"), addr_off);
+
+ readp += 4;
+ if (unlikely (readp + 4 > dataend))
+ goto invalid_data;
+
+ uint32_t sym_off = read_4ubyte_unaligned (dbg, readp);
+ printf (gettext (" symbol offset: %#" PRIx32 "\n"), sym_off);
+
+ readp += 4;
+ if (unlikely (readp + 4 > dataend))
+ goto invalid_data;
+
+ uint32_t const_off = read_4ubyte_unaligned (dbg, readp);
+ printf (gettext (" constant offset: %#" PRIx32 "\n"), const_off);
+
+ readp = data->d_buf + cu_off;
+
+ const unsigned char *nextp = data->d_buf + tu_off;
+ size_t nr = (nextp - readp) / 16;
+
+ printf (gettext ("\n CU list at offset %#" PRIx32
+ " contains %zu entries:\n"),
+ cu_off, nr);
+
+ size_t n = 0;
+ while (readp + 16 <= dataend && n < nr)
+ {
+ uint64_t off = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ uint64_t len = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ printf (" [%4zu] start: %0#8" PRIx64
+ ", length: %5" PRIu64 "\n", n, off, len);
+ n++;
+ }
+
+ readp = data->d_buf + tu_off;
+ nextp = data->d_buf + addr_off;
+ nr = (nextp - readp) / 24;
+
+ printf (gettext ("\n TU list at offset %#" PRIx32
+ " contains %zu entries:\n"),
+ tu_off, nr);
+
+ n = 0;
+ while (readp + 24 <= dataend && n < nr)
+ {
+ uint64_t off = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ uint64_t type = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ uint64_t sig = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ printf (" [%4zu] CU offset: %5" PRId64
+ ", type offset: %5" PRId64
+ ", signature: %0#8" PRIx64 "\n", n, off, type, sig);
+ n++;
+ }
+
+ readp = data->d_buf + addr_off;
+ nextp = data->d_buf + sym_off;
+ nr = (nextp - readp) / 20;
+
+ printf (gettext ("\n Address list at offset %#" PRIx32
+ " contains %zu entries:\n"),
+ addr_off, nr);
+
+ n = 0;
+ while (readp + 20 <= dataend && n < nr)
+ {
+ uint64_t low = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ uint64_t high = read_8ubyte_unaligned (dbg, readp);
+ readp += 8;
+
+ uint32_t idx = read_4ubyte_unaligned (dbg, readp);
+ readp += 4;
+
+ char *l = format_dwarf_addr (dwflmod, 8, low);
+ char *h = format_dwarf_addr (dwflmod, 8, high - 1);
+ printf (" [%4zu] %s..%s, CU index: %5" PRId32 "\n",
+ n, l, h, idx);
+ n++;
+ }
+
+ readp = data->d_buf + sym_off;
+ nextp = data->d_buf + const_off;
+ nr = (nextp - readp) / 8;
+
+ printf (gettext ("\n Symbol table at offset %#" PRIx32
+ " contains %zu slots:\n"),
+ addr_off, nr);
+
+ n = 0;
+ while (readp + 8 <= dataend && n < nr)
+ {
+ uint32_t name = read_4ubyte_unaligned (dbg, readp);
+ readp += 4;
+
+ uint32_t vector = read_4ubyte_unaligned (dbg, readp);
+ readp += 4;
+
+ if (name != 0 || vector != 0)
+ {
+ const unsigned char *sym = data->d_buf + const_off + name;
+ if (unlikely (sym > dataend))
+ goto invalid_data;
+
+ printf (" [%4zu] symbol: %s, CUs: ", n, sym);
+
+ const unsigned char *readcus = data->d_buf + const_off + vector;
+ if (unlikely (readcus + 8 > dataend))
+ goto invalid_data;
+
+ uint32_t cus = read_4ubyte_unaligned (dbg, readcus);
+ while (cus--)
+ {
+ uint32_t cu;
+ readcus += 4;
+ cu = read_4ubyte_unaligned (dbg, readcus);
+ printf ("%" PRId32 "%s", cu, ((cus > 0) ? ", " : ""));
+ }
+ printf ("\n");
+ }
+ n++;
+ }
+}
static void
print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
@@ -6377,7 +6583,8 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr)
{ ".eh_frame_hdr", section_frame | section_exception,
print_debug_frame_hdr_section },
{ ".gcc_except_table", section_frame | section_exception,
- print_debug_exception_table }
+ print_debug_exception_table },
+ { ".gdb_index", section_gdb_index, print_gdb_index_section }
};
const int ndebug_sections = (sizeof (debug_sections)
/ sizeof (debug_sections[0]));
@@ -7200,7 +7407,7 @@ handle_notes_data (Ebl *ebl, const GElf_Ehdr *ehdr,
ehdr->e_type == ET_CORE
? ebl_core_note_type_name (ebl, nhdr.n_type,
buf, sizeof (buf))
- : ebl_object_note_type_name (ebl, nhdr.n_type,
+ : ebl_object_note_type_name (ebl, name, nhdr.n_type,
buf2, sizeof (buf2)));
/* Filter out invalid entries. */
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 0d7d15ac..271096a5 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,8 +1,15 @@
+2011-03-28 Marek Polacek <[email protected]>
+
+ * alldts.c: New file.
+ * run-alldts.sh: Use it.
+ * Makefile.am (TESTS, EXTRA_DIST, noinst_PROGRAMS): Add them.
+ (alldts_LDADD): New variable.
+
2011-02-24 Roland McGrath <[email protected]>
* Makefile.am (TESTS): Put the slow dwarfcmp tests last.
-2011-04-02 Marek Polacek <[email protected]>
+2011-03-02 Marek Polacek <[email protected]>
* dwarf-getstring.c: New test.
* run-dwarf-getstring.sh: And its wrapper.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d8176441..b60e4cc9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,7 +60,8 @@ 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 dwarf-getstring rerequest_tag
+ test-flag-nobits dwarf-getstring rerequest_tag \
+ alldts
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -74,7 +75,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-strip-test3.sh run-strip-test4.sh run-strip-test5.sh \
run-strip-test6.sh run-strip-test7.sh run-strip-test8.sh \
run-unstrip-test.sh run-unstrip-test2.sh \
- run-ecp-test.sh run-ecp-test2.sh \
+ run-ecp-test.sh run-ecp-test2.sh run-alldts.sh \
run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \
run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
@@ -128,7 +129,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 \
+ run-dwarf-getstring.sh run-alldts.sh \
testfile15.bz2 testfile15.debug.bz2 \
testfile16.bz2 testfile16.debug.bz2 \
testfile17.bz2 testfile17.debug.bz2 \
@@ -167,7 +168,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
testfile55-32.bz2 testfile55-32.debug.bz2 \
testfile55-32.prelink.bz2 testfile55-64.bz2 \
testfile55-64.debug.bz2 testfile55-64.prelink.bz2 \
- testfile56.bz2
+ testfile56.bz2 testfile57.bz2
installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
bindir=$(DESTDIR)$(bindir) \
@@ -275,6 +276,7 @@ dwarf_getstring_LDADD = $(libdw) $(libmudflap)
addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
test_flag_nobits_LDADD = $(libelf) $(libmudflap)
rerequest_tag_LDADD = $(libdw) $(libmudflap)
+alldts_LDADD = $(libebl) $(libelf) $(libmudflap)
if GCOV
check: check-am coverage
diff --git a/tests/alldts.c b/tests/alldts.c
new file mode 100644
index 00000000..ed7624a7
--- /dev/null
+++ b/tests/alldts.c
@@ -0,0 +1,275 @@
+/* Create an ELF file with all the DT_* flags set.
+ Copyright (C) 2011 Red Hat, Inc.
+ This file is part of Red Hat elfutils.
+ Written by Marek Polacek <[email protected]>, 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(ebl)
+#include <elf.h>
+#include <gelf.h>
+#include <fcntl.h>
+#include <libelf.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+
+int
+main (void)
+{
+ static const char fname[] = "testfile-alldts";
+ struct Ebl_Strtab *shst;
+ struct Ebl_Strent *dynscn;
+ struct Ebl_Strent *shstrtabse;
+ const Elf32_Sword dtflags[] =
+ {
+ DT_NULL, DT_NEEDED, DT_PLTRELSZ, DT_PLTGOT,
+ DT_HASH, DT_STRTAB, DT_SYMTAB, DT_RELA,
+ DT_RELASZ, DT_RELAENT, DT_STRSZ, DT_SYMENT,
+ DT_INIT, DT_FINI, DT_SONAME, DT_RPATH,
+ DT_SYMBOLIC, DT_REL, DT_RELSZ, DT_RELENT,
+ DT_PLTREL, DT_DEBUG, DT_TEXTREL, DT_JMPREL,
+ DT_BIND_NOW, DT_INIT_ARRAY, DT_FINI_ARRAY,
+ DT_INIT_ARRAYSZ, DT_FINI_ARRAYSZ, DT_RUNPATH,
+ DT_FLAGS, DT_ENCODING, DT_PREINIT_ARRAY,
+ DT_PREINIT_ARRAYSZ, DT_VERSYM, DT_GNU_PRELINKED,
+ DT_GNU_CONFLICTSZ, DT_GNU_LIBLISTSZ, DT_CHECKSUM,
+ DT_PLTPADSZ, DT_MOVEENT, DT_MOVESZ, DT_FEATURE_1,
+ DT_POSFLAG_1, DT_SYMINSZ, DT_SYMINENT, DT_GNU_HASH,
+ DT_TLSDESC_PLT, DT_TLSDESC_GOT, DT_GNU_CONFLICT,
+ DT_GNU_LIBLIST, DT_CONFIG, DT_DEPAUDIT, DT_AUDIT,
+ DT_PLTPAD, DT_MOVETAB, DT_SYMINFO, DT_RELACOUNT,
+ DT_RELCOUNT, DT_FLAGS_1, DT_VERDEF, DT_VERDEFNUM,
+ DT_VERNEED, DT_VERNEEDNUM, DT_AUXILIARY, DT_FILTER
+ };
+ const int ndtflags = sizeof (dtflags) / sizeof (dtflags[0]);
+
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
+ /* Open the file. */
+ int fd = open64 (fname, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ if (fd == -1)
+ {
+ printf ("cannot open `%s': %m\n", fname);
+ return 1;
+ }
+
+ /* Tell the library which version are we expecting. */
+ elf_version (EV_CURRENT);
+
+ /* Create an ELF descriptor. */
+ Elf *elf = elf_begin (fd, ELF_C_WRITE, NULL);
+ if (elf == NULL)
+ {
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* Create an ELF header. */
+ Elf32_Ehdr *ehdr = elf32_newehdr (elf);
+ if (ehdr == NULL)
+ {
+ printf ("cannot create ELF header: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ ehdr->e_ident[0] = 42;
+ ehdr->e_ident[5] = 1;
+ ehdr->e_ident[6] = 2;
+ ehdr->e_type = ET_EXEC;
+ ehdr->e_machine = EM_386;
+ ehdr->e_version = 1;
+ ehdr->e_ehsize = 1;
+ ehdr->e_shnum = 3;
+
+ elf_flagehdr (elf, ELF_C_SET, ELF_F_DIRTY);
+
+ /* Create the program headers. */
+ Elf32_Phdr *phdr = elf32_newphdr (elf, 2);
+ if (phdr == NULL)
+ {
+ printf ("cannot create program headers: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ phdr[0].p_type = PT_PHDR;
+ phdr[1].p_type = PT_DYNAMIC;
+
+ elf_flagphdr (elf, ELF_C_SET, ELF_F_DIRTY);
+ shst = ebl_strtabinit (true);
+
+ /* Create the .dynamic section. */
+ Elf_Scn *scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create DYNAMIC section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ Elf32_Shdr *shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for DYNAMIC section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ dynscn = ebl_strtabadd (shst, ".dynamic", 0);
+
+ /* We'll need to know the section offset. But this will be set up
+ by elf_update later, so for now just store the address. */
+ const Elf32_Off *const dynscn_offset = &shdr->sh_offset;
+ shdr->sh_type = SHT_DYNAMIC;
+ shdr->sh_flags = SHF_ALLOC | SHF_WRITE;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ /* This section will start here. */
+ shdr->sh_addr = 0x1a0;
+
+ /* Create new section data. */
+ Elf_Data *data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data for DYNAMIC section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* Allocate memory for all the .dynamic entries. */
+ Elf32_Dyn *dyn = malloc (ndtflags * sizeof (Elf32_Dyn));
+ if (dyn == NULL)
+ {
+ printf ("malloc failed: %m\n");
+ return 1;
+ }
+
+ /* Now write all the DT_* flags. */
+ for (int i = 0; i < ndtflags; ++i)
+ {
+ dyn[i].d_tag = dtflags[i];
+ dyn[i].d_un.d_val = 0xdeadbeef;
+ }
+
+ /* Set the pointer to allocated memory. */
+ data->d_buf = dyn;
+ data->d_type = ELF_T_DYN;
+ data->d_version = EV_CURRENT;
+ data->d_size = ndtflags * sizeof (Elf32_Dyn);
+ data->d_align = 0x8;
+
+ /* Create .shstrtab section. */
+ scn = elf_newscn (elf);
+ if (scn == NULL)
+ {
+ printf ("cannot create SHSTRTAB section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ shdr = elf32_getshdr (scn);
+ if (shdr == NULL)
+ {
+ printf ("cannot get header for SHSTRTAB section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ shstrtabse = ebl_strtabadd (shst, ".shstrtab", 0);
+
+ shdr->sh_type = SHT_STRTAB;
+ shdr->sh_flags = 0;
+ shdr->sh_addr = 0;
+ shdr->sh_link = SHN_UNDEF;
+ shdr->sh_info = SHN_UNDEF;
+ shdr->sh_entsize = 1;
+
+ /* We have to store the section index in the ELF header. */
+ ehdr->e_shstrndx = elf_ndxscn (scn);
+
+ data = elf_newdata (scn);
+ if (data == NULL)
+ {
+ printf ("cannot create data SHSTRTAB section: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* No more sections, finalize the section header string table. */
+ ebl_strtabfinalize (shst, data);
+
+ elf32_getshdr (elf_getscn (elf, 1))->sh_name = ebl_strtaboffset (dynscn);
+ shdr->sh_name = ebl_strtaboffset (shstrtabse);
+
+ /* Let the library compute the internal structure information. */
+ if (elf_update (elf, ELF_C_NULL) < 0)
+ {
+ printf ("failure in elf_update(NULL): %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ ehdr = elf32_getehdr (elf);
+
+ phdr[0].p_offset = ehdr->e_phoff;
+ phdr[0].p_vaddr = ehdr->e_phoff;
+ phdr[0].p_paddr = ehdr->e_phoff;
+ phdr[0].p_flags = PF_R | PF_X;
+ phdr[0].p_filesz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_memsz = ehdr->e_phnum * elf32_fsize (ELF_T_PHDR, 1, EV_CURRENT);
+ phdr[0].p_align = sizeof (Elf32_Word);
+
+ phdr[1].p_flags = PF_W | PF_R;
+ phdr[1].p_offset = *dynscn_offset;
+ /* Set up the start of this segment to equal start address of the
+ .dynamic section. */
+ phdr[1].p_vaddr = 0x1a0;
+ phdr[1].p_paddr = 0x1a0;
+ phdr[1].p_align = 2 * sizeof (Elf32_Word);
+ phdr[1].p_filesz = ndtflags * sizeof (Elf32_Dyn);
+ phdr[1].p_memsz = ndtflags * sizeof (Elf32_Dyn);
+
+ /* Write out the file. */
+ if (elf_update (elf, ELF_C_WRITE) < 0)
+ {
+ printf ("failure in elf_update(WRITE): %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ /* We don't need the string table anymore. */
+ ebl_strtabfree (shst);
+
+ /* And the data allocated in the .shstrtab section. */
+ free (data->d_buf);
+
+ /* All done. */
+ if (elf_end (elf) != 0)
+ {
+ printf ("failure in elf_end: %s\n", elf_errmsg (-1));
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/tests/run-alldts.sh b/tests/run-alldts.sh
new file mode 100755
index 00000000..327f2f14
--- /dev/null
+++ b/tests/run-alldts.sh
@@ -0,0 +1,106 @@
+#! /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
+
+# This will produce "testfile-alldts" file
+./alldts
+
+testrun_compare ../src/readelf -d testfile-alldts <<\EOF
+
+Dynamic segment contains 66 entries:
+ Addr: 0x000001a0 Offset: 0x000078 Link to section: [ 0] ''
+ Type Value
+ NULL
+ NEEDED Shared library: [(null)]
+ PLTRELSZ 3735928559 (bytes)
+ PLTGOT 0xdeadbeef
+ HASH 0xdeadbeef
+ STRTAB 0xdeadbeef
+ SYMTAB 0xdeadbeef
+ RELA 0xdeadbeef
+ RELASZ 3735928559 (bytes)
+ RELAENT 3735928559 (bytes)
+ STRSZ 3735928559 (bytes)
+ SYMENT 3735928559 (bytes)
+ INIT 0xdeadbeef
+ FINI 0xdeadbeef
+ SONAME Library soname: [(null)]
+ RPATH Library rpath: [(null)]
+ SYMBOLIC 0xdeadbeef
+ REL 0xdeadbeef
+ RELSZ 3735928559 (bytes)
+ RELENT 3735928559 (bytes)
+ PLTREL ???
+ DEBUG
+ TEXTREL
+ JMPREL 0xdeadbeef
+ BIND_NOW
+ INIT_ARRAY 0xdeadbeef
+ FINI_ARRAY 0xdeadbeef
+ INIT_ARRAYSZ 3735928559 (bytes)
+ FINI_ARRAYSZ 3735928559 (bytes)
+ RUNPATH Library runpath: [(null)]
+ FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW 0xdeadbee0
+ PREINIT_ARRAY 0xdeadbeef
+ PREINIT_ARRAY 0xdeadbeef
+ PREINIT_ARRAYSZ 0xdeadbeef
+ VERSYM 0xdeadbeef
+ GNU_PRELINKED 0xdeadbeef
+ GNU_CONFLICTSZ 3735928559 (bytes)
+ GNU_LIBLISTSZ 3735928559 (bytes)
+ CHECKSUM 0xdeadbeef
+ PLTPADSZ 3735928559 (bytes)
+ MOVEENT 3735928559 (bytes)
+ MOVESZ 3735928559 (bytes)
+ FEATURE_1 PARINIT CONFEXP 0xdeadbeec
+ POSFLAG_1 LAZYLOAD GROUPPERM 0xdeadbeec
+ SYMINSZ 3735928559 (bytes)
+ SYMINENT 3735928559 (bytes)
+ GNU_HASH 0xdeadbeef
+ TLSDESC_PLT 0xdeadbeef
+ TLSDESC_GOT 0xdeadbeef
+ GNU_CONFLICT 0xdeadbeef
+ GNU_LIBLIST 0xdeadbeef
+ CONFIG 0xdeadbeef
+ DEPAUDIT 0xdeadbeef
+ AUDIT 0xdeadbeef
+ PLTPAD 0xdeadbeef
+ MOVETAB 0xdeadbeef
+ SYMINFO 0xdeadbeef
+ RELACOUNT 3735928559
+ RELCOUNT 3735928559
+ FLAGS_1 NOW GLOBAL GROUP NODELETE INITFIRST NOOPEN ORIGIN TRANS INTERPOSE NODEFLIB NODUMP CONFALT DISPRELDNE DISPRELPND 0xdeac0000
+ VERDEF 0xdeadbeef
+ VERDEFNUM 3735928559
+ VERNEED 0xdeadbeef
+ VERNEEDNUM 3735928559
+ AUXILIARY 0xdeadbeef
+ FILTER 0xdeadbeef
+EOF
+
+rm -f testfile-alldts
+
+exit 0
diff --git a/tests/run-rerequest_tag.sh b/tests/run-rerequest_tag.sh
index 1636fbfe..c61a9fd6 100755
--- a/tests/run-rerequest_tag.sh
+++ b/tests/run-rerequest_tag.sh
@@ -25,8 +25,9 @@
. $srcdir/test-subr.sh
-testfiles testfile56
+testfiles testfile56 testfile57
testrun ./rerequest_tag testfile56
+testrun ./rerequest_tag testfile57
exit 0
diff --git a/tests/testfile57.bz2 b/tests/testfile57.bz2
new file mode 100644
index 00000000..59dbde10
--- /dev/null
+++ b/tests/testfile57.bz2
Binary files differ