summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-01-16 15:19:40 +0100
committerMark Wielaard <mjw@redhat.com>2013-01-22 16:09:27 +0100
commit9a91fb2279fc9365b44f4526623ff0851c84f23d (patch)
tree9bcf918f67da4f7d430169f9b993d9164a55de11
parent5083a70d3b64946fa47ea5766943a15a3ecc6891 (diff)
downloadelfutils-9a91fb2279fc9365b44f4526623ff0851c84f23d.tar.gz
tests: readelf --elf-section, dwfl_module_addrsym and dwfl_module_getsym.
Various tests for the new minisymtab support. Signed-off-by: Mark Wielaard <mjw@redhat.com>
-rw-r--r--tests/ChangeLog9
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/dwflsyms.c124
-rwxr-xr-xtests/run-dwflsyms.sh193
-rwxr-xr-xtests/run-readelf-s.sh256
-rwxr-xr-xtests/testfilebazdbg.bz2bin0 -> 2185 bytes
-rwxr-xr-xtests/testfilebazdbg.debug.bz2bin0 -> 2187 bytes
-rwxr-xr-xtests/testfilebazdyn.bz2bin0 -> 2164 bytes
-rwxr-xr-xtests/testfilebazmdb.bz2bin0 -> 3259 bytes
-rwxr-xr-xtests/testfilebazmin.bz2bin0 -> 3194 bytes
-rwxr-xr-xtests/testfilebaztab.bz2bin0 -> 3418 bytes
11 files changed, 590 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 21569ebc..feb9f699 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,12 @@
+2013-01-16 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (check_PROGRAMS): Add dwflsyms.
+ (TESTS): Add run-readelf-s.sh and run-dwflsyms.sh.
+ (EXTRA_DIST): Add run-readelf-s.sh, testfilebazdbg.bz2,
+ testfilebazdyn.bz2, testfilebazmin.bz2, testfilebazdbg.debug.bz2,
+ testfilebazmdb.bz2, testfilebaztab.bz2 and run-dwflsyms.sh.
+ (dwflsyms_LDADD): New variable.
+
2013-01-07 Roland McGrath <roland@hack.frob.com>
* run-prelink-addr-test.sh: Use ln -snf.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8b7b751f..b46c4c23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 1996-2012 Red Hat, Inc.
+## Copyright (C) 1996-2013 Red Hat, Inc.
## This file is part of elfutils.
##
## This file is free software; you can redistribute it and/or modify
@@ -51,7 +51,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
dwfl-bug-getmodules dwarf-getmacros addrcfi \
test-flag-nobits dwarf-getstring rerequest_tag \
alldts md5-sha1-test typeiter low_high_pc \
- test-elf_cntl_gelf_getshdr
+ test-elf_cntl_gelf_getshdr dwflsyms
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -83,6 +83,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-test-flag-nobits.sh run-prelink-addr-test.sh \
run-dwarf-getstring.sh run-rerequest_tag.sh run-typeiter.sh \
run-readelf-d.sh run-readelf-gdb_index.sh run-unstrip-n.sh \
+ run-readelf-s.sh run-dwflsyms.sh \
run-low_high_pc.sh run-macro-test.sh run-elf_cntl_gelf_getshdr.sh \
run-test-archive64.sh run-readelf-vmcoreinfo.sh \
run-readelf-mixed-corenote.sh
@@ -172,6 +173,10 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-readelf-d.sh testlib_dynseg.so.bz2 \
run-readelf-gdb_index.sh testfilegdbindex5.bz2 \
testfilegdbindex7.bz2 \
+ run-readelf-s.sh testfilebazdbg.bz2 testfilebazdyn.bz2 \
+ testfilebazmin.bz2 testfilebazdbg.debug.bz2 testfilebazmdb.bz2 \
+ testfilebaztab.bz2 \
+ run-dwflsyms.sh \
run-unstrip-n.sh testcore-rtlib.bz2 testcore-rtlib-ppc.bz2 \
run-low_high_pc.sh testfile_low_high_pc.bz2 \
run-macro-test.sh testfile-macinfo.bz2 testfile-macros.bz2 \
@@ -288,6 +293,7 @@ md5_sha1_test_LDADD = $(libeu)
typeiter_LDADD = $(libdw) $(libelf) $(libmudflap)
low_high_pc_LDADD = $(libdw) $(libelf) $(libmudflap)
test_elf_cntl_gelf_getshdr_LDADD = $(libelf) $(libmudflap)
+dwflsyms_LDADD = $(libdw) $(libelf) $(libmudflap)
if GCOV
check: check-am coverage
diff --git a/tests/dwflsyms.c b/tests/dwflsyms.c
new file mode 100644
index 00000000..cae3fbea
--- /dev/null
+++ b/tests/dwflsyms.c
@@ -0,0 +1,124 @@
+/* Test program for libdwfl symbol resolving
+ Copyright (C) 2013 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file 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; either version 3 of the License, or
+ (at your option) any later version.
+
+ 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 this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <assert.h>
+#include <inttypes.h>
+#include ELFUTILS_HEADER(dwfl)
+#include <elf.h>
+#include <dwarf.h>
+#include <argp.h>
+#include <stdio.h>
+#include <stdio_ext.h>
+#include <stdlib.h>
+#include <error.h>
+#include <string.h>
+
+static const char *
+gelf_type (GElf_Sym *sym)
+{
+ switch (GELF_ST_TYPE (sym->st_info))
+ {
+ case STT_NOTYPE:
+ return "NOTYPE";
+ case STT_OBJECT:
+ return "OBJECT";
+ case STT_FUNC:
+ return "FUNC";
+ case STT_SECTION:
+ return "SECTION";
+ case STT_FILE:
+ return "FILE";
+ case STT_COMMON:
+ return "COMMON";
+ case STT_TLS:
+ return "TLS";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static const char *
+gelf_bind (GElf_Sym *sym)
+{
+ switch (GELF_ST_BIND (sym->st_info))
+ {
+ case STB_LOCAL:
+ return "LOCAL";
+ case STB_GLOBAL:
+ return "GLOBAL";
+ case STB_WEAK:
+ return "WEAK";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static int
+list_syms (struct Dwfl_Module *mod,
+ void **user __attribute__ ((unused)),
+ const char *mod_name __attribute__ ((unused)),
+ Dwarf_Addr low_addr __attribute__ ((unused)),
+ void *arg __attribute__ ((unused)))
+{
+ int syms = dwfl_module_getsymtab (mod);
+ assert (syms >= 0);
+
+ for (int ndx = 0; ndx < syms; ndx++)
+ {
+ GElf_Sym sym;
+ GElf_Word shndxp;
+ const char *name = dwfl_module_getsym (mod, ndx, &sym, &shndxp);
+ printf("%4d: %s\t%s\t%s (%" PRIu64 ") %#" PRIx64 "\n",
+ ndx, gelf_type (&sym), gelf_bind (&sym), name,
+ sym.st_size, sym.st_value);
+
+ /* And the reverse, which works for function symbols at least.
+ Note this only works because the st.value is adjusted by
+ dwfl_module_getsym (). */
+ if (GELF_ST_TYPE (sym.st_info) == STT_FUNC && shndxp != SHN_UNDEF)
+ {
+ GElf_Addr addr = sym.st_value;
+ GElf_Sym asym;
+ GElf_Word ashndxp;
+ const char *aname = dwfl_module_addrsym (mod, addr, &asym, &ashndxp);
+ assert (strcmp (name, aname) == 0);
+ }
+ }
+
+ return DWARF_CB_OK;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int remaining;
+ Dwfl *dwfl;
+ error_t res;
+
+ res = argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, &dwfl);
+ assert (res == 0 && dwfl != NULL);
+
+ ptrdiff_t off = 0;
+ do
+ off = dwfl_getmodules (dwfl, list_syms, NULL, off);
+ while (off > 0);
+
+ dwfl_end (dwfl);
+
+ return off;
+}
diff --git a/tests/run-dwflsyms.sh b/tests/run-dwflsyms.sh
new file mode 100755
index 00000000..570881ad
--- /dev/null
+++ b/tests/run-dwflsyms.sh
@@ -0,0 +1,193 @@
+#! /bin/sh
+# Copyright (C) 2013 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file 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; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# Tests dwfl_module_addrsym and dwfl_module_getsym.
+# See run-readelf-s.sh for how to generate test binaries.
+
+testfiles testfilebaztab
+testfiles testfilebazdbg testfilebazdbg.debug
+testfiles testfilebazdyn
+testfiles testfilebazmdb
+testfiles testfilebazmin
+
+tempfiles testfile.dynsym.in testfile.symtab.in testfile.minsym.in dwflsyms.out
+
+cat > testfile.symtab.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: SECTION LOCAL (0) 0x254
+ 3: SECTION LOCAL (0) 0x274
+ 4: SECTION LOCAL (0) 0x298
+ 5: SECTION LOCAL (0) 0x2d8
+ 6: SECTION LOCAL (0) 0x428
+ 7: SECTION LOCAL (0) 0x4f2
+ 8: SECTION LOCAL (0) 0x510
+ 9: SECTION LOCAL (0) 0x530
+ 10: SECTION LOCAL (0) 0x638
+ 11: SECTION LOCAL (0) 0x680
+ 12: SECTION LOCAL (0) 0x6a0
+ 13: SECTION LOCAL (0) 0x6e0
+ 14: SECTION LOCAL (0) 0x8f4
+ 15: SECTION LOCAL (0) 0x900
+ 16: SECTION LOCAL (0) 0x904
+ 17: SECTION LOCAL (0) 0x948
+ 18: SECTION LOCAL (0) 0x200dd0
+ 19: SECTION LOCAL (0) 0x200dd8
+ 20: SECTION LOCAL (0) 0x200de0
+ 21: SECTION LOCAL (0) 0x200de8
+ 22: SECTION LOCAL (0) 0x200df0
+ 23: SECTION LOCAL (0) 0x200fc0
+ 24: SECTION LOCAL (0) 0x201000
+ 25: SECTION LOCAL (0) 0x201030
+ 26: SECTION LOCAL (0) 0x20103c
+ 27: SECTION LOCAL (0) 0
+ 28: SECTION LOCAL (0) 0
+ 29: SECTION LOCAL (0) 0
+ 30: SECTION LOCAL (0) 0
+ 31: SECTION LOCAL (0) 0
+ 32: SECTION LOCAL (0) 0
+ 33: FILE LOCAL crtstuff.c (0) 0
+ 34: OBJECT LOCAL __JCR_LIST__ (0) 0x200de0
+ 35: FUNC LOCAL deregister_tm_clones (0) 0x710
+ 36: FUNC LOCAL register_tm_clones (0) 0x740
+ 37: FUNC LOCAL __do_global_dtors_aux (0) 0x780
+ 38: OBJECT LOCAL completed.6137 (1) 0x20103c
+ 39: OBJECT LOCAL __do_global_dtors_aux_fini_array_entry (0) 0x200dd8
+ 40: FUNC LOCAL frame_dummy (0) 0x7c0
+ 41: OBJECT LOCAL __frame_dummy_init_array_entry (0) 0x200dd0
+ 42: FILE LOCAL foo.c (0) 0
+ 43: FILE LOCAL bar.c (0) 0
+ 44: OBJECT LOCAL b1 (4) 0x201034
+ 45: FUNC LOCAL foo (20) 0x814
+ 46: FILE LOCAL crtstuff.c (0) 0
+ 47: OBJECT LOCAL __FRAME_END__ (0) 0xa58
+ 48: OBJECT LOCAL __JCR_END__ (0) 0x200de0
+ 49: FILE LOCAL (0) 0
+ 50: NOTYPE LOCAL __init_array_end (0) 0x200dd8
+ 51: OBJECT LOCAL _DYNAMIC (0) 0x200df0
+ 52: NOTYPE LOCAL __init_array_start (0) 0x200dd0
+ 53: OBJECT LOCAL _GLOBAL_OFFSET_TABLE_ (0) 0x201000
+ 54: FUNC GLOBAL __libc_csu_fini (2) 0x8f0
+ 55: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 56: NOTYPE WEAK data_start (0) 0x201030
+ 57: NOTYPE GLOBAL _edata (0) 0x20103c
+ 58: FUNC GLOBAL bar (44) 0x828
+ 59: FUNC GLOBAL _fini (0) 0x8f4
+ 60: FUNC GLOBAL __libc_start_main@@GLIBC_2.2.5 (0) 0
+ 61: NOTYPE GLOBAL __data_start (0) 0x201030
+ 62: NOTYPE WEAK __gmon_start__ (0) 0
+ 63: OBJECT GLOBAL __dso_handle (0) 0x200de8
+ 64: OBJECT GLOBAL _IO_stdin_used (4) 0x900
+ 65: OBJECT GLOBAL b2 (4) 0x201038
+ 66: FUNC GLOBAL __libc_csu_init (137) 0x860
+ 67: NOTYPE GLOBAL _end (0) 0x201040
+ 68: FUNC GLOBAL _start (0) 0x6e0
+ 69: NOTYPE GLOBAL __bss_start (0) 0x20103c
+ 70: FUNC GLOBAL main (35) 0x7f0
+ 71: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 72: OBJECT GLOBAL __TMC_END__ (0) 0x201040
+ 73: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 74: FUNC WEAK __cxa_finalize@@GLIBC_2.2.5 (0) 0
+ 75: FUNC GLOBAL _init (0) 0x680
+EOF
+
+cat > testfile.dynsym.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 3: FUNC GLOBAL __libc_start_main (0) 0
+ 4: NOTYPE WEAK __gmon_start__ (0) 0
+ 5: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 6: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 7: FUNC WEAK __cxa_finalize (0) 0
+ 8: NOTYPE GLOBAL _edata (0) 0x20103c
+ 9: NOTYPE GLOBAL _end (0) 0x201040
+ 10: FUNC GLOBAL __libc_csu_init (137) 0x860
+ 11: NOTYPE GLOBAL __bss_start (0) 0x20103c
+ 12: FUNC GLOBAL main (35) 0x7f0
+ 13: FUNC GLOBAL __libc_csu_fini (2) 0x8f0
+EOF
+
+cat > testfile.minsym.in <<\EOF
+ 0: NOTYPE LOCAL (0) 0
+ 1: SECTION LOCAL (0) 0x238
+ 2: FUNC LOCAL call_gmon_start (0) 0x4003bc
+ 3: FUNC LOCAL __do_global_dtors_aux (0) 0x4003e0
+ 4: FUNC LOCAL frame_dummy (0) 0x400450
+ 5: FUNC LOCAL __do_global_ctors_aux (0) 0x400580
+ 6: FUNC LOCAL foo (18) 0x400498
+ 7: SECTION LOCAL (0) 0x400200
+ 8: SECTION LOCAL (0) 0x40021c
+ 9: SECTION LOCAL (0) 0x40023c
+ 10: SECTION LOCAL (0) 0x400260
+ 11: SECTION LOCAL (0) 0x400280
+ 12: SECTION LOCAL (0) 0x4002c8
+ 13: SECTION LOCAL (0) 0x400300
+ 14: SECTION LOCAL (0) 0x400308
+ 15: SECTION LOCAL (0) 0x400328
+ 16: SECTION LOCAL (0) 0x400340
+ 17: SECTION LOCAL (0) 0x400358
+ 18: SECTION LOCAL (0) 0x400370
+ 19: SECTION LOCAL (0) 0x400390
+ 20: SECTION LOCAL (0) 0x4005b8
+ 21: SECTION LOCAL (0) 0x4005c8
+ 22: SECTION LOCAL (0) 0x4005d8
+ 23: SECTION LOCAL (0) 0x400610
+ 24: SECTION LOCAL (0) 0x6006d0
+ 25: SECTION LOCAL (0) 0x6006e0
+ 26: SECTION LOCAL (0) 0x6006f0
+ 27: SECTION LOCAL (0) 0x6006f8
+ 28: SECTION LOCAL (0) 0x600888
+ 29: SECTION LOCAL (0) 0x600890
+ 30: SECTION LOCAL (0) 0x6008b0
+ 31: SECTION LOCAL (0) 0x6008c0
+ 32: NOTYPE WEAK _ITM_deregisterTMCloneTable (0) 0
+ 33: FUNC GLOBAL __libc_start_main (0) 0
+ 34: NOTYPE WEAK __gmon_start__ (0) 0
+ 35: NOTYPE WEAK _Jv_RegisterClasses (0) 0
+ 36: NOTYPE WEAK _ITM_registerTMCloneTable (0) 0
+ 37: FUNC WEAK __cxa_finalize (0) 0
+ 38: NOTYPE GLOBAL _edata (0) 0x20103c
+ 39: NOTYPE GLOBAL _end (0) 0x201040
+ 40: FUNC GLOBAL __libc_csu_init (137) 0x860
+ 41: NOTYPE GLOBAL __bss_start (0) 0x20103c
+ 42: FUNC GLOBAL main (35) 0x7f0
+ 43: FUNC GLOBAL __libc_csu_fini (2) 0x8f0
+ 44: FUNC GLOBAL _start (0) 0x400390
+ 45: FUNC GLOBAL bar (44) 0x4004aa
+ 46: FUNC GLOBAL _fini (0) 0x4005b8
+ 47: FUNC GLOBAL _init (0) 0x400358
+EOF
+
+cat testfile.symtab.in \
+ | testrun_compare ./dwflsyms -e testfilebaztab
+
+cat testfile.symtab.in \
+ | testrun_compare ./dwflsyms -e testfilebazdbg
+
+cat testfile.dynsym.in \
+ | testrun_compare ./dwflsyms -e testfilebazdyn
+
+cat testfile.symtab.in \
+ | testrun_compare ./dwflsyms -e testfilebazmdb
+
+cat testfile.minsym.in \
+ | testrun_compare ./dwflsyms -e testfilebazmin
+
+exit 0
diff --git a/tests/run-readelf-s.sh b/tests/run-readelf-s.sh
new file mode 100755
index 00000000..f14b3054
--- /dev/null
+++ b/tests/run-readelf-s.sh
@@ -0,0 +1,256 @@
+#! /bin/sh
+# Copyright (C) 2013 Red Hat, Inc.
+# This file is part of elfutils.
+#
+# This file 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; either version 3 of the License, or
+# (at your option) any later version.
+#
+# 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 this program. If not, see <http://www.gnu.org/licenses/>.
+
+. $srcdir/test-subr.sh
+
+# Tests readelf -s and readelf --elf-section -s
+# See also run-dwflsyms.sh
+#
+# - bar.c
+#
+# static int b1 = 1;
+# int b2 = 1;
+#
+# static int
+# foo (int a)
+# {
+# return a + b2;
+# }
+#
+# int bar (int b)
+# {
+# return b - foo (b - b1);
+# }
+#
+# - foo.c
+#
+# extern int bar (int b);
+# extern int b2;
+#
+# int
+# main (int argc, char ** argv)
+# {
+# return bar (argc + b2);
+# }
+#
+# gcc -pie -g -c foo.c
+# gcc -pie -g -c bar.c
+# gcc -pie -g -o baz foo.o bar.o
+#
+# - testfilebaztab (dynsym + symtab)
+# cp baz testfilebaztab
+#
+# - testfilebazdbg (dynsym + .debug file)
+# eu-strip --remove-comment -f testfilebazdbg.debug baz
+# cp baz testfilebazdbg
+#
+#- testfilebazdyn (dynsym only)
+# objcopy --remove-section=.gnu_debuglink baz testfilebazdyn
+#
+# - testfilebazmdb (dynsym + gnu_debugdata + .debug)
+# This is how rpmbuild does it:
+# nm -D baz --format=posix --defined-only | awk '{ print $1 }' | sort > dynsyms
+# nm baz.debug --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t") print $1 }' | sort > funcsyms
+# comm -13 dynsyms funcsyms > keep_symbols
+# objcopy -S --remove-section .gdb_index --remove-section .comment --keep-symbols=keep_symbols baz.debug mini_debuginfo
+# rm -f mini_debuginfo.xz
+# xz mini_debuginfo
+# objcopy --add-section .gnu_debugdata=mini_debuginfo.xz baz
+# cp baz testfilebazmdb
+#
+# - testfilebazmin (dynsym + gnu_debugdata)
+# objcopy --remove-section=.gnu_debuglink baz testfilebazmin
+
+testfiles testfilebaztab
+testfiles testfilebazdbg testfilebazdbg.debug
+testfiles testfilebazdyn
+testfiles testfilebazmdb
+testfiles testfilebazmin
+
+tempfiles testfile.dynsym.in testfile.symtab.in testfile.minsym.in
+
+cat > testfile.dynsym.in <<\EOF
+
+Symbol table [ 5] '.dynsym' contains 14 entries:
+ 2 local symbols String table: [ 6] '.dynstr'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1
+ 2: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_deregisterTMCloneTable
+ 3: 0000000000000000 0 FUNC GLOBAL DEFAULT UNDEF __libc_start_main@GLIBC_2.2.5 (2)
+ 4: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF __gmon_start__
+ 5: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _Jv_RegisterClasses
+ 6: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_registerTMCloneTable
+ 7: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF __cxa_finalize@GLIBC_2.2.5 (2)
+ 8: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 25 _edata
+ 9: 0000000000201040 0 NOTYPE GLOBAL DEFAULT 26 _end
+ 10: 0000000000000860 137 FUNC GLOBAL DEFAULT 13 __libc_csu_init
+ 11: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 26 __bss_start
+ 12: 00000000000007f0 35 FUNC GLOBAL DEFAULT 13 main
+ 13: 00000000000008f0 2 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
+EOF
+
+cat > testfile.symtab.in <<\EOF
+
+Symbol table [34] '.symtab' contains 76 entries:
+ 54 local symbols String table: [35] '.strtab'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 0000000000000238 0 SECTION LOCAL DEFAULT 1
+ 2: 0000000000000254 0 SECTION LOCAL DEFAULT 2
+ 3: 0000000000000274 0 SECTION LOCAL DEFAULT 3
+ 4: 0000000000000298 0 SECTION LOCAL DEFAULT 4
+ 5: 00000000000002d8 0 SECTION LOCAL DEFAULT 5
+ 6: 0000000000000428 0 SECTION LOCAL DEFAULT 6
+ 7: 00000000000004f2 0 SECTION LOCAL DEFAULT 7
+ 8: 0000000000000510 0 SECTION LOCAL DEFAULT 8
+ 9: 0000000000000530 0 SECTION LOCAL DEFAULT 9
+ 10: 0000000000000638 0 SECTION LOCAL DEFAULT 10
+ 11: 0000000000000680 0 SECTION LOCAL DEFAULT 11
+ 12: 00000000000006a0 0 SECTION LOCAL DEFAULT 12
+ 13: 00000000000006e0 0 SECTION LOCAL DEFAULT 13
+ 14: 00000000000008f4 0 SECTION LOCAL DEFAULT 14
+ 15: 0000000000000900 0 SECTION LOCAL DEFAULT 15
+ 16: 0000000000000904 0 SECTION LOCAL DEFAULT 16
+ 17: 0000000000000948 0 SECTION LOCAL DEFAULT 17
+ 18: 0000000000200dd0 0 SECTION LOCAL DEFAULT 18
+ 19: 0000000000200dd8 0 SECTION LOCAL DEFAULT 19
+ 20: 0000000000200de0 0 SECTION LOCAL DEFAULT 20
+ 21: 0000000000200de8 0 SECTION LOCAL DEFAULT 21
+ 22: 0000000000200df0 0 SECTION LOCAL DEFAULT 22
+ 23: 0000000000200fc0 0 SECTION LOCAL DEFAULT 23
+ 24: 0000000000201000 0 SECTION LOCAL DEFAULT 24
+ 25: 0000000000201030 0 SECTION LOCAL DEFAULT 25
+ 26: 000000000020103c 0 SECTION LOCAL DEFAULT 26
+ 27: 0000000000000000 0 SECTION LOCAL DEFAULT 27
+ 28: 0000000000000000 0 SECTION LOCAL DEFAULT 28
+ 29: 0000000000000000 0 SECTION LOCAL DEFAULT 29
+ 30: 0000000000000000 0 SECTION LOCAL DEFAULT 30
+ 31: 0000000000000000 0 SECTION LOCAL DEFAULT 31
+ 32: 0000000000000000 0 SECTION LOCAL DEFAULT 32
+ 33: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
+ 34: 0000000000200de0 0 OBJECT LOCAL DEFAULT 20 __JCR_LIST__
+ 35: 0000000000000710 0 FUNC LOCAL DEFAULT 13 deregister_tm_clones
+ 36: 0000000000000740 0 FUNC LOCAL DEFAULT 13 register_tm_clones
+ 37: 0000000000000780 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
+ 38: 000000000020103c 1 OBJECT LOCAL DEFAULT 26 completed.6137
+ 39: 0000000000200dd8 0 OBJECT LOCAL DEFAULT 19 __do_global_dtors_aux_fini_array_entry
+ 40: 00000000000007c0 0 FUNC LOCAL DEFAULT 13 frame_dummy
+ 41: 0000000000200dd0 0 OBJECT LOCAL DEFAULT 18 __frame_dummy_init_array_entry
+ 42: 0000000000000000 0 FILE LOCAL DEFAULT ABS foo.c
+ 43: 0000000000000000 0 FILE LOCAL DEFAULT ABS bar.c
+ 44: 0000000000201034 4 OBJECT LOCAL DEFAULT 25 b1
+ 45: 0000000000000814 20 FUNC LOCAL DEFAULT 13 foo
+ 46: 0000000000000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
+ 47: 0000000000000a58 0 OBJECT LOCAL DEFAULT 17 __FRAME_END__
+ 48: 0000000000200de0 0 OBJECT LOCAL DEFAULT 20 __JCR_END__
+ 49: 0000000000000000 0 FILE LOCAL DEFAULT ABS
+ 50: 0000000000200dd8 0 NOTYPE LOCAL DEFAULT 18 __init_array_end
+ 51: 0000000000200df0 0 OBJECT LOCAL DEFAULT 22 _DYNAMIC
+ 52: 0000000000200dd0 0 NOTYPE LOCAL DEFAULT 18 __init_array_start
+ 53: 0000000000201000 0 OBJECT LOCAL DEFAULT 24 _GLOBAL_OFFSET_TABLE_
+ 54: 00000000000008f0 2 FUNC GLOBAL DEFAULT 13 __libc_csu_fini
+ 55: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_deregisterTMCloneTable
+ 56: 0000000000201030 0 NOTYPE WEAK DEFAULT 25 data_start
+ 57: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 25 _edata
+ 58: 0000000000000828 44 FUNC GLOBAL DEFAULT 13 bar
+ 59: 00000000000008f4 0 FUNC GLOBAL DEFAULT 14 _fini
+ 60: 0000000000000000 0 FUNC GLOBAL DEFAULT UNDEF __libc_start_main@@GLIBC_2.2.5
+ 61: 0000000000201030 0 NOTYPE GLOBAL DEFAULT 25 __data_start
+ 62: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF __gmon_start__
+ 63: 0000000000200de8 0 OBJECT GLOBAL HIDDEN 21 __dso_handle
+ 64: 0000000000000900 4 OBJECT GLOBAL DEFAULT 15 _IO_stdin_used
+ 65: 0000000000201038 4 OBJECT GLOBAL DEFAULT 25 b2
+ 66: 0000000000000860 137 FUNC GLOBAL DEFAULT 13 __libc_csu_init
+ 67: 0000000000201040 0 NOTYPE GLOBAL DEFAULT 26 _end
+ 68: 00000000000006e0 0 FUNC GLOBAL DEFAULT 13 _start
+ 69: 000000000020103c 0 NOTYPE GLOBAL DEFAULT 26 __bss_start
+ 70: 00000000000007f0 35 FUNC GLOBAL DEFAULT 13 main
+ 71: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _Jv_RegisterClasses
+ 72: 0000000000201040 0 OBJECT GLOBAL HIDDEN 25 __TMC_END__
+ 73: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF _ITM_registerTMCloneTable
+ 74: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF __cxa_finalize@@GLIBC_2.2.5
+ 75: 0000000000000680 0 FUNC GLOBAL DEFAULT 11 _init
+EOF
+
+cat > testfile.minsym.in <<\EOF
+
+Symbol table [27] '.symtab' contains 35 entries:
+ 31 local symbols String table: [28] '.strtab'
+ Num: Value Size Type Bind Vis Ndx Name
+ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UNDEF
+ 1: 00000000004003bc 0 FUNC LOCAL DEFAULT 13 call_gmon_start
+ 2: 00000000004003e0 0 FUNC LOCAL DEFAULT 13 __do_global_dtors_aux
+ 3: 0000000000400450 0 FUNC LOCAL DEFAULT 13 frame_dummy
+ 4: 0000000000400580 0 FUNC LOCAL DEFAULT 13 __do_global_ctors_aux
+ 5: 0000000000400498 18 FUNC LOCAL DEFAULT 13 foo
+ 6: 0000000000400200 0 SECTION LOCAL DEFAULT 1
+ 7: 000000000040021c 0 SECTION LOCAL DEFAULT 2
+ 8: 000000000040023c 0 SECTION LOCAL DEFAULT 3
+ 9: 0000000000400260 0 SECTION LOCAL DEFAULT 4
+ 10: 0000000000400280 0 SECTION LOCAL DEFAULT 5
+ 11: 00000000004002c8 0 SECTION LOCAL DEFAULT 6
+ 12: 0000000000400300 0 SECTION LOCAL DEFAULT 7
+ 13: 0000000000400308 0 SECTION LOCAL DEFAULT 8
+ 14: 0000000000400328 0 SECTION LOCAL DEFAULT 9
+ 15: 0000000000400340 0 SECTION LOCAL DEFAULT 10
+ 16: 0000000000400358 0 SECTION LOCAL DEFAULT 11
+ 17: 0000000000400370 0 SECTION LOCAL DEFAULT 12
+ 18: 0000000000400390 0 SECTION LOCAL DEFAULT 13
+ 19: 00000000004005b8 0 SECTION LOCAL DEFAULT 14
+ 20: 00000000004005c8 0 SECTION LOCAL DEFAULT 15
+ 21: 00000000004005d8 0 SECTION LOCAL DEFAULT 16
+ 22: 0000000000400610 0 SECTION LOCAL DEFAULT 17
+ 23: 00000000006006d0 0 SECTION LOCAL DEFAULT 18
+ 24: 00000000006006e0 0 SECTION LOCAL DEFAULT 19
+ 25: 00000000006006f0 0 SECTION LOCAL DEFAULT 20
+ 26: 00000000006006f8 0 SECTION LOCAL DEFAULT 21
+ 27: 0000000000600888 0 SECTION LOCAL DEFAULT 22
+ 28: 0000000000600890 0 SECTION LOCAL DEFAULT 23
+ 29: 00000000006008b0 0 SECTION LOCAL DEFAULT 24
+ 30: 00000000006008c0 0 SECTION LOCAL DEFAULT 25
+ 31: 0000000000400390 0 FUNC GLOBAL DEFAULT 13 _start
+ 32: 00000000004004aa 44 FUNC GLOBAL DEFAULT 13 bar
+ 33: 00000000004005b8 0 FUNC GLOBAL DEFAULT 14 _fini
+ 34: 0000000000400358 0 FUNC GLOBAL DEFAULT 11 _init
+EOF
+
+cat testfile.dynsym.in testfile.symtab.in \
+ | testrun_compare ../src/readelf -s testfilebaztab
+
+cat testfile.dynsym.in \
+ | testrun_compare ../src/readelf -s testfilebazdbg
+
+cat testfile.symtab.in \
+ | testrun_compare ../src/readelf -s testfilebazdbg.debug
+
+cat testfile.dynsym.in \
+ | testrun_compare ../src/readelf -s testfilebazdyn
+
+cat testfile.dynsym.in \
+ | testrun_compare ../src/readelf -s testfilebazmdb
+
+cat testfile.minsym.in \
+ | testrun_compare ../src/readelf --elf-section -s testfilebazmdb
+
+cat testfile.dynsym.in \
+ | testrun_compare ../src/readelf -s testfilebazmin
+
+cat testfile.minsym.in \
+ | testrun_compare ../src/readelf --elf-section -s testfilebazmin
+
+exit 0
diff --git a/tests/testfilebazdbg.bz2 b/tests/testfilebazdbg.bz2
new file mode 100755
index 00000000..8e586361
--- /dev/null
+++ b/tests/testfilebazdbg.bz2
Binary files differ
diff --git a/tests/testfilebazdbg.debug.bz2 b/tests/testfilebazdbg.debug.bz2
new file mode 100755
index 00000000..3b011763
--- /dev/null
+++ b/tests/testfilebazdbg.debug.bz2
Binary files differ
diff --git a/tests/testfilebazdyn.bz2 b/tests/testfilebazdyn.bz2
new file mode 100755
index 00000000..bb623bb0
--- /dev/null
+++ b/tests/testfilebazdyn.bz2
Binary files differ
diff --git a/tests/testfilebazmdb.bz2 b/tests/testfilebazmdb.bz2
new file mode 100755
index 00000000..c486365c
--- /dev/null
+++ b/tests/testfilebazmdb.bz2
Binary files differ
diff --git a/tests/testfilebazmin.bz2 b/tests/testfilebazmin.bz2
new file mode 100755
index 00000000..f7286d62
--- /dev/null
+++ b/tests/testfilebazmin.bz2
Binary files differ
diff --git a/tests/testfilebaztab.bz2 b/tests/testfilebaztab.bz2
new file mode 100755
index 00000000..a99b7394
--- /dev/null
+++ b/tests/testfilebaztab.bz2
Binary files differ