summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2005-08-25 01:49:35 +0000
committerRoland McGrath <roland@redhat.com>2005-08-25 01:49:35 +0000
commit4c305da9de0ecfe9af64cb6787b2b4b8a6aa8dd5 (patch)
treeaeba7918420be8f6c080f902529a482993388e5f
parent6830bc40bb6a38dee917bebc856c7c1ba5126e24 (diff)
downloadelfutils-4c305da9de0ecfe9af64cb6787b2b4b8a6aa8dd5.tar.gz
2005-08-24 Roland McGrath <roland@redhat.com>
* line2addr.c (print_address): Omit () for DSOs.
-rw-r--r--ChangeLog4
-rw-r--r--NEWS8
-rw-r--r--TODO26
-rw-r--r--config/elfutils.spec.in6
-rw-r--r--configure.ac15
-rw-r--r--lib/ChangeLog4
-rw-r--r--lib/system.h8
-rw-r--r--libasm/ChangeLog6
-rw-r--r--libasm/Makefile.am15
-rw-r--r--libdw/ChangeLog6
-rw-r--r--libdw/Makefile.am15
-rw-r--r--libdwfl/ChangeLog5
-rw-r--r--libdwfl/Makefile.am5
-rw-r--r--libebl/ChangeLog4
-rw-r--r--libebl/Makefile.am56
-rw-r--r--libelf/ChangeLog24
-rw-r--r--libelf/Makefile.am13
-rw-r--r--libelf/elf32_getphdr.c9
-rw-r--r--libelf/elf32_getshdr.c11
-rw-r--r--libelf/elf32_updatefile.c30
-rw-r--r--libelf/elf_begin.c294
-rw-r--r--libelf/elf_getarsym.c5
-rw-r--r--libelf/elf_getdata.c13
-rw-r--r--libelf/elf_getshstrndx.c18
-rw-r--r--libelf/elf_readall.c10
-rw-r--r--libelf/gelf_rawchunk.c15
-rw-r--r--po/ChangeLog6
-rw-r--r--po/POTFILES.in1
-rw-r--r--src/ChangeLog15
-rw-r--r--src/Makefile.am8
-rw-r--r--src/ranlib.c5
-rw-r--r--src/strings.c720
-rw-r--r--tests/ChangeLog10
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/line2addr.c2
-rwxr-xr-xtests/run-strings-test.sh475
36 files changed, 300 insertions, 1575 deletions
diff --git a/ChangeLog b/ChangeLog
index b390eeda..9a7850aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * configure.ac: Add --enable-gcov option.
-
2005-08-06 Ulrich Drepper <drepper@redhat.com>
* configure.ac: Add --enable-gprof option.
diff --git a/NEWS b/NEWS
index 7d5d4afc..a15e1f12 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,3 @@
-Version 0.115:
-
-libelf: speed-ups of non-mmap reading.
-
-strings: New program.
-
-Implement --enable-gcov option for configure.
-
Version 0.114:
libelf: new function elf_getaroff
diff --git a/TODO b/TODO
index 9eb7b6ca..318da823 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
ToDo list for elfutils -*-outline-*-
----------------------
-Time-stamp: <2005-08-29 08:58:24 drepper>
+Time-stamp: <2005-08-03 20:38:01 drepper>
* mkinstalldirs
@@ -23,7 +23,15 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
remains maintainable.
-* libdw
+* libdwarf
+
+** Should we do more error checking?
+
+ Most functions don't check whether they get a NULL value passed for
+ a pointer argument. It could be argued that this is OK since it's
+ a bug inthe program. But perhaps one could catch the case and return
+ an error which would allow the program using libdwarf to have fewer
+ places with error checking.
** More memory access checks needed
@@ -37,6 +45,12 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
** Rename dwarf_getabbrev
+** dwarf_loclist()
+
+ This function and its interface seem to be misdesigned. The specification
+ is unclear and its changed between v2 and v2.1. Other implementation
+ implement even different behavior.
+
* nm:
@@ -102,14 +116,6 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
prelink generated files
-* elfcmp
-
-** treat relocation sections special
-
- Differences in the relocation sections can be ignored if all
- the same symbols with the same targets are present and the order
- of overlapping relocations doesn't change. There really never
- should be overlapping relocations but who knows.
* mcs
diff --git a/config/elfutils.spec.in b/config/elfutils.spec.in
index 9ec79eb7..bfeda144 100644
--- a/config/elfutils.spec.in
+++ b/config/elfutils.spec.in
@@ -143,8 +143,6 @@ rm -rf ${RPM_BUILD_ROOT}
%{_bindir}/eu-findtextrel
%{_bindir}/eu-addr2line
%{_bindir}/eu-elfcmp
-%{_bindir}/eu-ranlib
-%{_bindir}/eu-strings
%if !%{fake}
#%{_bindir}/eu-ld
#%{_libdir}/libasm-%{version}.so
@@ -199,13 +197,13 @@ ss, dwfl_linux_kernel_report_offline.
* Wed Aug 10 2005 Ulrich Drepper <@redhat.com> 0.113-1
- elflint: relax a bit. Allow version definitions for defined symbols ag
-ainstDSO versions also for symbols in nobits sections. Allow .rodata
+ainstDSO versions also for symbols in nobits sections. Allow .rodata
sectionto have STRINGS and MERGE flag set.
- strip: add some more compatibility with binutils.
* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1
- elflint: relax a bit. Allow version definitions for defined symbols ag
-ainstDSO versions also for symbols in nobits sections. Allow .rodata
+ainstDSO versions also for symbols in nobits sections. Allow .rodata
sectionto have STRINGS and MERGE flag set.
* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1
diff --git a/configure.ac b/configure.ac
index f721310d..f8d4ef35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software Foundation,
dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dnl
-AC_INIT([Red Hat elfutils],[0.115],[http://bugzilla.redhat.com/bugzilla/],
+AC_INIT([Red Hat elfutils],[0.114],[http://bugzilla.redhat.com/bugzilla/],
[elfutils])
AC_CONFIG_AUX_DIR([config])
@@ -138,19 +138,8 @@ if test "$use_gprof" = yes; then
LDFLAGS="$LDFLAGS -pg"
fi
AM_CONDITIONAL(GPROF, test "$use_gprof" = yes)
-
-# Enable gcov suport.
-AC_ARG_ENABLE([gcov],
-AC_HELP_STRING([--enable-gcov],
-[build binaries with gcov support]), [use_gcov=yes], [use_gcov=no])
-if test "$use_gcov" = yes; then
- CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
- LDFLAGS="$LDFLAGS -fprofile-arcs"
-fi
-AM_CONDITIONAL(GPROF, test "$use_gprof" = yes)
-
AM_CONDITIONAL(BUILD_STATIC, [dnl
-test "$use_mudflap" = yes -o "$use_gprof" = yes -o "$use_gcov" = yes])
+test "$use_mudflap" = yes -o "$use_gprof" = yes])
LIBEBL_SUBDIR="$PACKAGE"
AC_ARG_ENABLE([libebl-subdir],
diff --git a/lib/ChangeLog b/lib/ChangeLog
index f7760f13..5b79d096 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,7 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * system.h: Define pwrite_retry, write_retry, and pread_retry.
-
2005-08-06 Ulrich Drepper <drepper@redhat.com>
* Makefile.am (xmalloc_CFLAGS): Define only if !GPROF.
diff --git a/lib/system.h b/lib/system.h
index 998bf729..e29c2dbb 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -37,12 +37,4 @@ extern int crc32_file (int fd, uint32_t *resp);
#define gettext_noop(Str) Str
-
-#define pwrite_retry(fd, buf, len, off) \
- TEMP_FAILURE_RETRY (pwrite (fd, buf, len, off))
-#define write_retry(fd, buf, n) \
- TEMP_FAILURE_RETRY (write (fd, buf, n))
-#define pread_retry(fd, buf, len, off) \
- TEMP_FAILURE_RETRY (pread (fd, buf, len, off))
-
#endif /* system.h */
diff --git a/libasm/ChangeLog b/libasm/ChangeLog
index d4c06348..6adeef1e 100644
--- a/libasm/ChangeLog
+++ b/libasm/ChangeLog
@@ -1,9 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * Makefile.am: Use $(LINK) not $(CC) when creating DSO.
- (%.os): Use COMPILE.os.
- (COMPILE.os): Filter out gconv options.
-
2005-08-02 Ulrich Drepper <drepper@redhat.com>
* Makefile.am (AM_CFLAGS): Add -std=gnu99.
diff --git a/libasm/Makefile.am b/libasm/Makefile.am
index e9b99397..7802a5c0 100644
--- a/libasm/Makefile.am
+++ b/libasm/Makefile.am
@@ -24,9 +24,6 @@ INCLUDES = -I. -I$(srcdir) -I.. -I$(top_srcdir)/libelf -I$(top_srcdir)/libebl \
GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
VERSION = 1
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
- $(COMPILE)))
-
lib_LIBRARIES = libasm.a
if !MUDFLAP
noinst_LIBRARIES = libasm_pic.a
@@ -54,16 +51,16 @@ am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os)
libasm_so_SOURCES =
libasm.so: libasm_pic.a libasm.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
- -Wl,--soname,$@.$(VERSION) \
- ../libebl/libebl.a ../libelf/libelf.so
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
+ -Wl,--soname,$@.$(VERSION) \
+ ../libebl/libebl.a ../libelf/libelf.so
if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
ln -fs $@ $@.$(VERSION)
%.os: %.c %.o
- if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
rm -f "$(DEPDIR)/$*.Tpo"; \
@@ -86,4 +83,4 @@ endif
noinst_HEADERS = libasmP.h symbolhash.h
EXTRA_DIST = libasm.map
-CLEANFILES = $(am_libasm_pic_a_OBJECTS) *.gcno *.gcda
+CLEANFILES = $(am_libasm_pic_a_OBJECTS)
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index a6bd2784..3b84ab9e 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,9 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * Makefile.am: Use $(LINK) not $(CC) when creating DSO.
- (%.os): Use COMPILE.os.
- (COMPILE.os): Filter out gconv options.
-
2005-08-23 Roland McGrath <roland@redhat.com>
* dwarf_attr_integrate.c (dwarf_attr_integrate): Treat
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index ee4eccf5..ad6b28a1 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -22,9 +22,6 @@ AM_CFLAGS += -Wall -Werror -Wshadow -Wunused -Wformat=2 -Wextra -std=gnu99
INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
VERSION = 1
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
- $(COMPILE)))
-
lib_LIBRARIES = libdw.a
if !MUDFLAP
noinst_LIBRARIES = libdw_pic.a
@@ -79,15 +76,15 @@ libdw_so_SOURCES =
libdw.so: $(srcdir)/libdw.map libdw_pic.a \
../libdwfl/libdwfl_pic.a ../libebl/libebl.a \
../libelf/libelf.so
- $(LINK) -shared -o $@ -Wl,--soname,$@.$(VERSION),-z,defs \
- -Wl,--version-script,$<,--no-undefined \
- -Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\
- -ldl
+ $(CC) -shared -o $@ -Wl,--soname,$@.$(VERSION),-z,defs \
+ -Wl,--version-script,$<,--no-undefined \
+ -Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive \
+ -ldl
if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
ln -fs $@ $@.$(VERSION)
%.os: %.c %.o
- if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
rm -f "$(DEPDIR)/$*.Tpo"; \
@@ -113,4 +110,4 @@ noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h
EXTRA_DIST = libdw.map
-CLEANFILES = $(am_libdw_pic_a_OBJECTS) *.gcno *.gcda
+CLEANFILES = $(am_libdw_pic_a_OBJECTS)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index aedc6da7..139ab47b 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,8 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * Makefile.am (%.os): Use COMPILE.os.
- (COMPILE.os): Filter out gconv options.
-
2005-08-24 Roland McGrath <roland@redhat.com>
* argp-std.c [_MUDFLAP] (__libdwfl_argp_mudflap_options): New function,
diff --git a/libdwfl/Makefile.am b/libdwfl/Makefile.am
index 510e7599..a0735ff0 100644
--- a/libdwfl/Makefile.am
+++ b/libdwfl/Makefile.am
@@ -25,9 +25,6 @@ INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
-I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib
VERSION = 1
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
- $(COMPILE)))
-
noinst_LIBRARIES = libdwfl.a
if !MUDFLAP
noinst_LIBRARIES += libdwfl_pic.a
@@ -74,7 +71,7 @@ libdwfl_pic_a_SOURCES =
am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
%.os: %.c %.o
- if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
rm -f "$(DEPDIR)/$*.Tpo"; \
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index d5248293..cb0d0095 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,7 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * Makefile.am: Use $(LINK) not $(CC) when creating DSOs.
-
2005-08-13 Roland McGrath <roland@redhat.com>
* ia64_symbol.c (ia64_machine_flag_check): New function.
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index 93271e52..ead129bd 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -69,9 +69,9 @@ textrel_check = if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
libebl_i386_so_SOURCES =
libebl_i386.so: libebl_i386_pic.a libebl_i386.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_i386.map \
- -Wl,-z,defs $(libelf) $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_i386.map \
+ -Wl,-z,defs $(libelf) $(libmudflap)
$(textrel_check)
@@ -81,9 +81,9 @@ am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os)
libebl_sh_so_SOURCES =
libebl_sh.so: libebl_sh_pic.a libebl_sh.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_sh.map \
- -Wl,-z,defs $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_sh.map \
+ -Wl,-z,defs $(libmudflap)
$(textrel_check)
@@ -93,9 +93,9 @@ am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os)
libebl_x86_64_so_SOURCES =
libebl_x86_64.so: libebl_x86_64_pic.a libebl_x86_64.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_x86_64.map \
- -Wl,-z,defs $(libelf) $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_x86_64.map \
+ -Wl,-z,defs $(libelf) $(libmudflap)
$(textrel_check)
@@ -105,9 +105,9 @@ am_libebl_ia64_pic_a_OBJECTS = $(ia64_SRCS:.c=.os)
libebl_ia64_so_SOURCES =
libebl_ia64.so: libebl_ia64_pic.a libebl_ia64.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_ia64.map \
- -Wl,-z,defs $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_ia64.map \
+ -Wl,-z,defs $(libmudflap)
$(textrel_check)
@@ -117,9 +117,9 @@ am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os)
libebl_alpha_so_SOURCES =
libebl_alpha.so: libebl_alpha_pic.a libebl_alpha.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_alpha.map \
- -Wl,-z,defs $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_alpha.map \
+ -Wl,-z,defs $(libmudflap)
$(textrel_check)
@@ -129,9 +129,9 @@ am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os)
libebl_arm_so_SOURCES =
libebl_arm.so: libebl_arm_pic.a libebl_arm.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_arm.map \
- -Wl,-z,defs $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_arm.map \
+ -Wl,-z,defs $(libmudflap)
$(textrel_check)
@@ -141,9 +141,9 @@ am_libebl_sparc_pic_a_OBJECTS = $(sparc_SRCS:.c=.os)
libebl_sparc_so_SOURCES =
libebl_sparc.so: libebl_sparc_pic.a libebl_sparc.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_sparc.map \
- -Wl,-z,defs $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_sparc.map \
+ -Wl,-z,defs $(libmudflap)
$(textrel_check)
@@ -153,9 +153,9 @@ am_libebl_ppc_pic_a_OBJECTS = $(ppc_SRCS:.c=.os)
libebl_ppc_so_SOURCES =
libebl_ppc.so: libebl_ppc_pic.a libebl_ppc.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_ppc.map \
- -Wl,-z,defs $(libelf) $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_ppc.map \
+ -Wl,-z,defs $(libelf) $(libmudflap)
$(textrel_check)
@@ -165,9 +165,9 @@ am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os)
libebl_ppc64_so_SOURCES =
libebl_ppc64.so: libebl_ppc64_pic.a libebl_ppc64.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libebl_ppc64.map \
- -Wl,-z,defs $(libelf) $(libmudflap)
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libebl_ppc64.map \
+ -Wl,-z,defs $(libelf) $(libmudflap)
$(textrel_check)
@@ -199,5 +199,5 @@ noinst_HEADERS = libeblP.h $(noinst_LIBRARIES:%_pic.a=%.h)
EXTRA_DIST = $(noinst_LIBRARIES:%_pic.a=%.map) \
$(foreach m,$(modules),$($(m)_SRCS))
-CLEANFILES = $(am_libebl_pic_a_OBJECTS) *.gcno *.gcda \
+CLEANFILES = $(am_libebl_pic_a_OBJECTS) \
$(foreach m,$(modules),$(am_libebl_$(m)_pic_a_OBJECTS))
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index bd710aee..5c68569e 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,27 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * elf32_getphdr.c: Include <system.h>. Use pread_retry instead of
- pread. And branch prediction where useful.
- * elf_begin.c: Likewise.
- * elf_getdata.c: Likewise.
- * elf_getshstrndx.c: Likewise.
- * elf_readall.c: Likewise.
- * gelf_rawchunk.c: Likewise.
- * elf32_updatefile.c: Include <system.h>. Use pread_retry instead of
- pread. And branch prediction where useful.
- * elf_getarsym.c: Don't define pread_retry here.
-
- * Makefile.am: Use $(LINK) not $(CC) when creating DSO.
- (%.os): Use COMPILE.os.
- (COMPILE.os): Filter out gconv options.
-
-2005-08-27 Ulrich Drepper <drepper@redhat.com>
-
- * elf_begin.c (file_read_elf): Avoid reading ELF header from file
- again. Instead accept additional parameter which points to it if we
- don't use mmap.
- (get_shnum): Use passed in e_ident value as source of ELF header.
-
2005-08-15 Ulrich Drepper <drepper@redhat.com>
* elf_begin.c (__libelf_next_arhdr): Use TEMP_FAILURE_RETRY.
diff --git a/libelf/Makefile.am b/libelf/Makefile.am
index 37683d85..28d0d6ed 100644
--- a/libelf/Makefile.am
+++ b/libelf/Makefile.am
@@ -31,9 +31,6 @@ GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
VERSION = 1
PACKAGE_VERSION = @PACKAGE_VERSION@
-COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
- $(COMPILE)))
-
lib_LIBRARIES = libelf.a
if !MUDFLAP
noinst_LIBRARIES = libelf_pic.a
@@ -95,14 +92,14 @@ am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
libelf_so_SOURCES =
libelf.so: libelf_pic.a libelf.map
- $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
- -Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
- -Wl,--soname,$@.$(VERSION),-z,-defs
+ $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
+ -Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
+ -Wl,--soname,$@.$(VERSION),-z,-defs
if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
ln -fs $@ $@.$(VERSION)
%.os: %.c %.o
- if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
+ if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
-MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
rm -f "$(DEPDIR)/$*.Tpo"; \
@@ -125,4 +122,4 @@ noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
version_xlate.h dl-hash.h
EXTRA_DIST = libelf.map
-CLEANFILES = $(am_libelf_pic_a_OBJECTS) *.gcno *.gcda
+CLEANFILES = $(am_libelf_pic_a_OBJECTS)
diff --git a/libelf/elf32_getphdr.c b/libelf/elf32_getphdr.c
index 341acf09..25693687 100644
--- a/libelf/elf32_getphdr.c
+++ b/libelf/elf32_getphdr.c
@@ -19,11 +19,9 @@
# include <config.h>
#endif
-#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -150,10 +148,9 @@ elfw2(LIBELFBITS,getphdr) (elf)
elf->state.ELFW(elf,LIBELFBITS).phdr_flags |= ELF_F_MALLOCED;
/* Read the header. */
- ssize_t n = pread_retry (elf->fildes,
- elf->state.ELFW(elf,LIBELFBITS).phdr, size,
- elf->start_offset + ehdr->e_phoff);
- if (unlikely ((size_t) n != size))
+ if ((size_t) pread (elf->fildes,
+ elf->state.ELFW(elf,LIBELFBITS).phdr, size,
+ (elf->start_offset + ehdr->e_phoff)) != size)
{
/* Severe problems. We cannot read the data. */
__libelf_seterrno (ELF_E_READ_ERROR);
diff --git a/libelf/elf32_getshdr.c b/libelf/elf32_getshdr.c
index cf7a41fd..1e26e854 100644
--- a/libelf/elf32_getshdr.c
+++ b/libelf/elf32_getshdr.c
@@ -20,10 +20,8 @@
#endif
#include <assert.h>
-#include <errno.h>
#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -124,13 +122,12 @@ elfw2(LIBELFBITS,getshdr) (scn)
CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize);
}
}
- else if (likely (elf->fildes != -1))
+ else if (elf->fildes != -1)
{
/* Read the header. */
- ssize_t n = pread_retry (elf->fildes,
- elf->state.ELFW(elf,LIBELFBITS).shdr, size,
- elf->start_offset + ehdr->e_shoff);
- if (unlikely ((size_t) n != size))
+ if ((size_t) pread (elf->fildes,
+ elf->state.ELFW(elf,LIBELFBITS).shdr, size,
+ elf->start_offset + ehdr->e_shoff) != size)
{
/* Severe problems. We cannot read the data. */
__libelf_seterrno (ELF_E_READ_ERROR);
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 260fb346..14893def 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -20,7 +20,6 @@
#endif
#include <assert.h>
-#include <errno.h>
#include <libelf.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -28,7 +27,6 @@
#include <unistd.h>
#include <sys/param.h>
-#include <system.h>
#include "libelfP.h"
@@ -328,7 +326,7 @@ fill (int fd, off_t pos, size_t len, char *fillbuf, size_t *filledp)
/* This many bytes we want to write in this round. */
size_t n = MIN (filled, len);
- if (unlikely ((size_t) pwrite_retry (fd, fillbuf, n, pos) != n))
+ if (unlikely ((size_t) pwrite (fd, fillbuf, n, pos) != n))
{
__libelf_seterrno (ELF_E_WRITE_ERROR);
return 1;
@@ -383,8 +381,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
}
/* Write out the ELF header. */
- if (unlikely (pwrite_retry (elf->fildes, out_ehdr,
- sizeof (ElfW2(LIBELFBITS,Ehdr)), 0)
+ if (unlikely (pwrite (elf->fildes, out_ehdr,
+ sizeof (ElfW2(LIBELFBITS,Ehdr)), 0)
!= sizeof (ElfW2(LIBELFBITS,Ehdr))))
{
__libelf_seterrno (ELF_E_WRITE_ERROR);
@@ -443,10 +441,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
}
/* Write out the ELF header. */
- size_t phdr_size = sizeof (ElfW2(LIBELFBITS,Phdr)) * ehdr->e_phnum;
- if (unlikely ((size_t) pwrite_retry (elf->fildes, out_phdr,
- phdr_size, ehdr->e_phoff)
- != phdr_size))
+ if (unlikely ((size_t) pwrite (elf->fildes, out_phdr,
+ sizeof (ElfW2(LIBELFBITS,Phdr))
+ * ehdr->e_phnum, ehdr->e_phoff)
+ != sizeof (ElfW2(LIBELFBITS,Phdr)) * ehdr->e_phnum))
{
__libelf_seterrno (ELF_E_WRITE_ERROR);
return 1;
@@ -546,10 +544,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
(*fctp) (buf, dl->data.d.d_buf, dl->data.d.d_size, 1);
}
- ssize_t n = pwrite_retry (elf->fildes, buf,
- dl->data.d.d_size,
- last_offset);
- if (unlikely ((size_t) n != dl->data.d.d_size))
+ if (unlikely ((size_t) pwrite (elf->fildes, buf,
+ dl->data.d.d_size,
+ last_offset)
+ != dl->data.d.d_size))
{
if (buf != dl->data.d.d_buf && buf != tmpbuf)
free (buf);
@@ -595,9 +593,9 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
/* Write out the section header table. */
if (shdr_flags & ELF_F_DIRTY
- && unlikely ((size_t) pwrite_retry (elf->fildes, shdr_data,
- sizeof (ElfW2(LIBELFBITS,Shdr))
- * shnum, shdr_offset)
+ && unlikely ((size_t) pwrite (elf->fildes, shdr_data,
+ sizeof (ElfW2(LIBELFBITS,Shdr))
+ * shnum, shdr_offset)
!= sizeof (ElfW2(LIBELFBITS,Shdr)) * shnum))
{
__libelf_seterrno (ELF_E_WRITE_ERROR);
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index c21a52b5..c4b33595 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -31,7 +31,6 @@
#include <sys/param.h>
#include <sys/stat.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -78,40 +77,41 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
bool is32 = e_ident[EI_CLASS] == ELFCLASS32;
/* Make the ELF header available. */
- if (e_ident[EI_DATA] == MY_ELFDATA)
- ehdr.p = e_ident;
+ if (likely (map_address != NULL) && e_ident[EI_DATA] == MY_ELFDATA
+ && (ALLOW_UNALIGNED
+ || (((size_t) ((char *) map_address + offset))
+ & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr))
+ - 1)) == 0))
+ ehdr.p = (char *) map_address + offset;
else
{
- /* We already read the ELF header. We have to copy the header
- since we possibly modify the data here and the caller
- expects the memory it passes in to be preserved. */
- ehdr.p = &ehdr_mem;
+ /* We have to read the data from the file. */
+ size_t len = is32 ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr);
- if (is32)
+ if (likely (map_address != NULL))
+ ehdr.p = memcpy (&ehdr_mem, (char *) map_address + offset, len);
+ else
{
- if (ALLOW_UNALIGNED)
- {
- ehdr_mem.e32.e_shnum = ((Elf32_Ehdr *) e_ident)->e_shnum;
- ehdr_mem.e32.e_shoff = ((Elf32_Ehdr *) e_ident)->e_shoff;
- }
- else
- memcpy (&ehdr_mem, e_ident, sizeof (Elf32_Ehdr));
-
- CONVERT (ehdr_mem.e32.e_shnum);
- CONVERT (ehdr_mem.e32.e_shoff);
+ /* Fill it. */
+ if ((size_t) TEMP_FAILURE_RETRY (pread (fildes, &ehdr_mem, len,
+ offset)) != len)
+ /* Failed reading. */
+ return (size_t) -1l;
+ ehdr.p = &ehdr_mem;
}
- else
+
+ if (e_ident[EI_DATA] != MY_ELFDATA)
{
- if (ALLOW_UNALIGNED)
+ if (is32)
{
- ehdr_mem.e64.e_shnum = ((Elf64_Ehdr *) e_ident)->e_shnum;
- ehdr_mem.e64.e_shoff = ((Elf64_Ehdr *) e_ident)->e_shoff;
+ CONVERT (ehdr.e32->e_shnum);
+ CONVERT (ehdr.e32->e_shoff);
}
else
- memcpy (&ehdr_mem, e_ident, sizeof (Elf64_Ehdr));
-
- CONVERT (ehdr_mem.e64.e_shnum);
- CONVERT (ehdr_mem.e64.e_shoff);
+ {
+ CONVERT (ehdr.e64->e_shnum);
+ CONVERT (ehdr.e64->e_shoff);
+ }
}
}
@@ -145,10 +145,12 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
+ offset))->sh_size,
sizeof (Elf32_Word));
else
- if (unlikely (pread_retry (fildes, &size, sizeof (Elf32_Word),
- offset + ehdr.e32->e_shoff
- + offsetof (Elf32_Shdr, sh_size))
- != sizeof (Elf32_Word)))
+ if (TEMP_FAILURE_RETRY (pread (fildes, &size,
+ sizeof (Elf32_Word),
+ offset + ehdr.e32->e_shoff
+ + offsetof (Elf32_Shdr,
+ sh_size)))
+ != sizeof (Elf32_Word))
return (size_t) -1l;
if (e_ident[EI_DATA] != MY_ELFDATA)
@@ -187,10 +189,12 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
+ offset))->sh_size,
sizeof (Elf64_Xword));
else
- if (unlikely (pread_retry (fildes, &size, sizeof (Elf64_Word),
- offset + ehdr.e64->e_shoff
- + offsetof (Elf64_Shdr, sh_size))
- != sizeof (Elf64_Xword)))
+ if (TEMP_FAILURE_RETRY (pread (fildes, &size,
+ sizeof (Elf64_Word),
+ offset + ehdr.e64->e_shoff
+ + offsetof (Elf64_Shdr,
+ sh_size)))
+ != sizeof (Elf64_Xword))
return (size_t) -1l;
if (e_ident[EI_DATA] != MY_ELFDATA)
@@ -211,15 +215,37 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
/* Create descriptor for ELF file in memory. */
static Elf *
-file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
- off_t offset, size_t maxsize, Elf_Cmd cmd, Elf *parent)
+file_read_elf (int fildes, void *map_address, off_t offset, size_t maxsize,
+ Elf_Cmd cmd, Elf *parent)
{
+ /* We only read the ELF header now. */
+ unsigned char *e_ident;
+ unsigned char e_ident_mem[EI_NIDENT];
+ size_t scncnt;
+ Elf *elf;
+
+ if (map_address != NULL)
+ /* It's right at the beginning of the file. No word access
+ required, just bytes. */
+ e_ident = (unsigned char *) map_address + offset;
+ else
+ {
+ e_ident = e_ident_mem;
+
+ if (TEMP_FAILURE_RETRY (pread (fildes, e_ident, EI_NIDENT, offset))
+ != EI_NIDENT)
+ {
+ __libelf_seterrno (ELF_E_READ_ERROR);
+ return NULL;
+ }
+ }
+
/* Verify the binary is of the class we can handle. */
- if (unlikely ((e_ident[EI_CLASS] != ELFCLASS32
- && e_ident[EI_CLASS] != ELFCLASS64)
- /* We also can only handle two encodings. */
- || (e_ident[EI_DATA] != ELFDATA2LSB
- && e_ident[EI_DATA] != ELFDATA2MSB)))
+ if ((e_ident[EI_CLASS] != ELFCLASS32
+ && e_ident[EI_CLASS] != ELFCLASS64)
+ /* We also can only handle two encodings. */
+ || (e_ident[EI_DATA] != ELFDATA2LSB
+ && e_ident[EI_DATA] != ELFDATA2MSB))
{
/* Cannot handle this. */
__libelf_seterrno (ELF_E_INVALID_FILE);
@@ -227,14 +253,14 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
}
/* Determine the number of sections. */
- size_t scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize);
+ scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize);
if (scncnt == (size_t) -1l)
/* Could not determine the number of sections. */
return NULL;
/* We can now allocate the memory. */
- Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent,
- ELF_K_ELF, scncnt * sizeof (Elf_Scn));
+ elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent,
+ ELF_K_ELF, scncnt * sizeof (Elf_Scn));
if (elf == NULL)
/* Not enough memory. */
return NULL;
@@ -242,9 +268,6 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
/* Some more or less arbitrary value. */
elf->state.elf.scnincr = 10;
- /* Make the class easily available. */
- elf->class = e_ident[EI_CLASS];
-
if (e_ident[EI_CLASS] == ELFCLASS32)
{
/* This pointer might not be directly usable if the alignment is
@@ -264,14 +287,17 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
& (__alignof__ (Elf32_Phdr) - 1)) == 0)))
{
/* We can use the mmapped memory. */
- elf->state.elf32.ehdr = ehdr;
- elf->state.elf32.shdr
- = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff);
- if (ehdr->e_phnum > 0)
+ elf->state.elf32.ehdr =
+ (Elf32_Ehdr *) ((char *) map_address + offset);
+ elf->state.elf32.shdr =
+ (Elf32_Shdr *) ((char *) map_address + offset
+ + elf->state.elf32.ehdr->e_shoff);
+ if (elf->state.elf32.ehdr->e_phnum)
/* Assign a value only if there really is a program
header. Otherwise the value remains NULL. */
elf->state.elf32.phdr
- = (Elf32_Phdr *) ((char *) ehdr + ehdr->e_phoff);
+ = (Elf32_Phdr *) ((char *) map_address + offset
+ + elf->state.elf32.ehdr->e_phoff);
for (size_t cnt = 0; cnt < scncnt; ++cnt)
{
@@ -288,9 +314,21 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
}
else
{
- /* Copy the ELF header. */
- elf->state.elf32.ehdr = memcpy (&elf->state.elf32.ehdr_mem, e_ident,
- sizeof (Elf32_Ehdr));
+ if (likely (map_address != NULL))
+ /* Copy the data. */
+ memcpy (&elf->state.elf32.ehdr_mem,
+ (char *) map_address + offset, sizeof (Elf32_Ehdr));
+ else
+ /* Read the data. */
+ if (TEMP_FAILURE_RETRY (pread (elf->fildes,
+ &elf->state.elf32.ehdr_mem,
+ sizeof (Elf32_Ehdr), offset))
+ != sizeof (Elf32_Ehdr))
+ {
+ /* We must be able to read the ELF header. */
+ __libelf_seterrno (ELF_E_INVALID_FILE);
+ return NULL;
+ }
if (e_ident[EI_DATA] != MY_ELFDATA)
{
@@ -309,6 +347,8 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
CONVERT (elf->state.elf32.ehdr_mem.e_shstrndx);
}
+ elf->state.elf32.ehdr = &elf->state.elf32.ehdr_mem;
+
for (size_t cnt = 0; cnt < scncnt; ++cnt)
{
elf->state.elf32.scns.data[cnt].index = cnt;
@@ -339,14 +379,17 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
& (__alignof__ (Elf64_Phdr) - 1)) == 0)))
{
/* We can use the mmapped memory. */
- elf->state.elf64.ehdr = ehdr;
- elf->state.elf64.shdr
- = (Elf64_Shdr *) ((char *) ehdr + ehdr->e_shoff);
- if (ehdr->e_phnum > 0)
+ elf->state.elf64.ehdr =
+ (Elf64_Ehdr *) ((char *) map_address + offset);
+ elf->state.elf64.shdr =
+ (Elf64_Shdr *) ((char *) map_address + offset
+ + elf->state.elf64.ehdr->e_shoff);
+ if (elf->state.elf64.ehdr->e_phnum)
/* Assign a value only if there really is a program
header. Otherwise the value remains NULL. */
elf->state.elf64.phdr
- = (Elf64_Phdr *) ((char *) ehdr + ehdr->e_phoff);
+ = (Elf64_Phdr *) ((char *) map_address + offset
+ + elf->state.elf64.ehdr->e_phoff);
for (size_t cnt = 0; cnt < scncnt; ++cnt)
{
@@ -363,9 +406,21 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
}
else
{
- /* Copy the ELF header. */
- elf->state.elf64.ehdr = memcpy (&elf->state.elf64.ehdr_mem, e_ident,
- sizeof (Elf64_Ehdr));
+ if (likely (map_address != NULL))
+ /* Copy the data. */
+ memcpy (&elf->state.elf64.ehdr_mem,
+ (char *) map_address + offset, sizeof (Elf64_Ehdr));
+ else
+ /* Read the data. */
+ if (TEMP_FAILURE_RETRY (pread (elf->fildes,
+ &elf->state.elf64.ehdr_mem,
+ sizeof (Elf64_Ehdr), offset))
+ != sizeof (Elf64_Ehdr))
+ {
+ /* We must be able to read the ELF header. */
+ __libelf_seterrno (ELF_E_INVALID_FILE);
+ return NULL;
+ }
if (e_ident[EI_DATA] != MY_ELFDATA)
{
@@ -384,6 +439,8 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
CONVERT (elf->state.elf64.ehdr_mem.e_shstrndx);
}
+ elf->state.elf64.ehdr = &elf->state.elf64.ehdr_mem;
+
for (size_t cnt = 0; cnt < scncnt; ++cnt)
{
elf->state.elf64.scns.data[cnt].index = cnt;
@@ -396,6 +453,9 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
elf->state.elf64.scns_last = &elf->state.elf64.scns;
}
+ /* Make the class easily available. */
+ elf->class = e_ident[EI_CLASS];
+
return elf;
}
@@ -409,16 +469,15 @@ __libelf_read_mmaped_file (int fildes, void *map_address, off_t offset,
files and archives. To find out what we have we must look at the
header. The header for an ELF file is EI_NIDENT bytes in size,
the header for an archive file SARMAG bytes long. */
- unsigned char *e_ident = (unsigned char *) map_address + offset;
+ Elf_Kind kind;
/* See what kind of object we have here. */
- Elf_Kind kind = determine_kind (e_ident, maxsize);
+ kind = determine_kind (map_address + offset, maxsize);
switch (kind)
{
case ELF_K_ELF:
- return file_read_elf (fildes, map_address, e_ident, offset, maxsize,
- cmd, parent);
+ return file_read_elf (fildes, map_address, offset, maxsize, cmd, parent);
case ELF_K_AR:
return file_read_ar (fildes, map_address, offset, maxsize, cmd, parent);
@@ -440,33 +499,25 @@ read_unmmaped_file (int fildes, off_t offset, size_t maxsize, Elf_Cmd cmd,
{
/* We have to find out what kind of file this is. We handle ELF
files and archives. To find out what we have we must read the
- header. The identification header for an ELF file is EI_NIDENT
- bytes in size, but we read the whole ELF header since we will
- need it anyway later. For archives the header in SARMAG bytes
- long. Read the maximum of these numbers.
-
- XXX We have to change this for the extended `ar' format some day.
+ header. The header for an ELF file is EI_NIDENT bytes in size,
+ the header for an archive file SARMAG bytes long. Read the
+ maximum of these numbers.
- Use a union to ensure alignment. We might later access the
- memory as a ElfXX_Ehdr. */
- union
- {
- Elf64_Ehdr ehdr;
- unsigned char header[MAX (sizeof (Elf64_Ehdr), SARMAG)];
- } mem;
+ XXX We have to change this for the extended `ar' format some day. */
+ unsigned char header[MAX (EI_NIDENT, SARMAG)];
+ ssize_t nread;
+ Elf_Kind kind;
/* Read the head of the file. */
- ssize_t nread = pread_retry (fildes, mem.header,
- MIN (MAX (sizeof (Elf64_Ehdr), SARMAG),
- maxsize),
- offset);
- if (unlikely (nread == -1))
+ nread = pread (fildes, header, MIN (MAX (EI_NIDENT, SARMAG), maxsize),
+ offset);
+ if (nread == -1)
/* We cannot even read the head of the file. Maybe FILDES is associated
with an unseekable device. This is nothing we can handle. */
return NULL;
/* See what kind of object we have here. */
- Elf_Kind kind = determine_kind (mem.header, nread);
+ kind = determine_kind (header, nread);
switch (kind)
{
@@ -475,10 +526,9 @@ read_unmmaped_file (int fildes, off_t offset, size_t maxsize, Elf_Cmd cmd,
case ELF_K_ELF:
/* Make sure at least the ELF header is contained in the file. */
- if ((size_t) nread >= (mem.header[EI_CLASS] == ELFCLASS32
- ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr)))
- return file_read_elf (fildes, NULL, mem.header, offset, maxsize, cmd,
- parent);
+ if (maxsize >= (header[EI_CLASS] == ELFCLASS32
+ ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr)))
+ return file_read_elf (fildes, NULL, offset, maxsize, cmd, parent);
/* FALLTHROUGH */
default:
@@ -546,11 +596,10 @@ read_file (int fildes, off_t offset, size_t maxsize,
/* If we have the file in memory optimize the access. */
if (map_address != NULL)
{
- assert (map_address != MAP_FAILED);
+ struct Elf *result;
- struct Elf *result = __libelf_read_mmaped_file (fildes, map_address,
- offset, maxsize, cmd,
- parent);
+ result = __libelf_read_mmaped_file (fildes, map_address, offset, maxsize,
+ cmd, parent);
/* If something went wrong during the initialization unmap the
memory if we mmaped here. */
@@ -594,9 +643,8 @@ read_long_names (Elf *elf)
else
{
/* Read the header from the file. */
- if (unlikely (pread_retry (elf->fildes, &hdrm, sizeof (hdrm),
- elf->start_offset + offset)
- != sizeof (hdrm)))
+ if (pread (elf->fildes, &hdrm, sizeof (hdrm),
+ elf->start_offset + offset) != sizeof (hdrm))
return NULL;
hdr = &hdrm;
@@ -626,10 +674,10 @@ read_long_names (Elf *elf)
len);
else
{
- if (unlikely ((size_t) pread_retry (elf->fildes, newp, len,
- elf->start_offset + offset
- + sizeof (struct ar_hdr))
- != len))
+ if ((size_t) pread (elf->fildes, newp, len,
+ elf->start_offset + offset
+ + sizeof (struct ar_hdr))
+ != len)
{
/* We were not able to read all data. */
free (newp);
@@ -679,8 +727,8 @@ __libelf_next_arhdr (elf)
if (elf->map_address != NULL)
{
/* See whether this entry is in the file. */
- if (unlikely (elf->state.ar.offset + sizeof (struct ar_hdr)
- > elf->start_offset + elf->maximum_size))
+ if (elf->state.ar.offset + sizeof (struct ar_hdr)
+ > elf->start_offset + elf->maximum_size)
{
/* This record is not anymore in the file. */
__libelf_seterrno (ELF_E_RANGE);
@@ -692,9 +740,10 @@ __libelf_next_arhdr (elf)
{
ar_hdr = &elf->state.ar.ar_hdr;
- if (unlikely (pread_retry (elf->fildes, ar_hdr, sizeof (struct ar_hdr),
- elf->state.ar.offset)
- != sizeof (struct ar_hdr)))
+ if (TEMP_FAILURE_RETRY (pread (elf->fildes, ar_hdr,
+ sizeof (struct ar_hdr),
+ elf->state.ar.offset))
+ != sizeof (struct ar_hdr))
{
/* Something went wrong while reading the file. */
__libelf_seterrno (ELF_E_RANGE);
@@ -703,7 +752,7 @@ __libelf_next_arhdr (elf)
}
/* One little consistency check. */
- if (unlikely (memcmp (ar_hdr->ar_fmag, ARFMAG, 2) != 0))
+ if (memcmp (ar_hdr->ar_fmag, ARFMAG, 2) != 0)
{
/* This is no valid archive. */
__libelf_seterrno (ELF_E_ARCHIVE_FMAG);
@@ -727,14 +776,14 @@ __libelf_next_arhdr (elf)
&& memcmp (ar_hdr->ar_name, "// ", 16) == 0)
/* This is the array with the long names. */
elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "//", 3);
- else if (likely (isdigit (ar_hdr->ar_name[1])))
+ else if (isdigit (ar_hdr->ar_name[1]))
{
size_t offset;
/* This is a long name. First we have to read the long name
table, if this hasn't happened already. */
- if (unlikely (elf->state.ar.long_names == NULL
- && read_long_names (elf) == NULL))
+ if (elf->state.ar.long_names == NULL
+ && read_long_names (elf) == NULL)
{
/* No long name table although it is reference. The archive is
broken. */
@@ -743,7 +792,7 @@ __libelf_next_arhdr (elf)
}
offset = atol (ar_hdr->ar_name + 1);
- if (unlikely (offset >= elf->state.ar.long_names_len))
+ if (offset >= elf->state.ar.long_names_len)
{
/* The index in the long name table is larger than the table. */
__libelf_seterrno (ELF_E_INVALID_ARCHIVE);
@@ -857,7 +906,7 @@ __libelf_next_arhdr (elf)
if (ar_hdr->ar_size[sizeof (ar_hdr->ar_size) - 1] == ' ')
{
- if (unlikely (ar_hdr->ar_size[0] == ' '))
+ if (ar_hdr->ar_size[0] == ' ')
/* Something is really wrong. We cannot live without a size for
the member since it will not be possible to find the next
archive member. */
@@ -897,7 +946,7 @@ dup_elf (int fildes, Elf_Cmd cmd, Elf *ref)
fildes = ref->fildes;
/* The file descriptor better should be the same. If it was disconnected
already (using `elf_cntl') we do not test it. */
- else if (unlikely (ref->fildes != -1 && fildes != ref->fildes))
+ else if (ref->fildes != -1 && fildes != ref->fildes)
{
__libelf_seterrno (ELF_E_FD_MISMATCH);
return NULL;
@@ -906,10 +955,10 @@ dup_elf (int fildes, Elf_Cmd cmd, Elf *ref)
/* The mode must allow reading. I.e., a descriptor creating with a
command different then ELF_C_READ, ELF_C_WRITE and ELF_C_RDWR is
not allowed. */
- if (unlikely (ref->cmd != ELF_C_READ && ref->cmd != ELF_C_READ_MMAP
- && ref->cmd != ELF_C_WRITE && ref->cmd != ELF_C_WRITE_MMAP
- && ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP
- && ref->cmd != ELF_C_READ_MMAP_PRIVATE))
+ if (ref->cmd != ELF_C_READ && ref->cmd != ELF_C_READ_MMAP
+ && ref->cmd != ELF_C_WRITE && ref->cmd != ELF_C_WRITE_MMAP
+ && ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP
+ && ref->cmd != ELF_C_READ_MMAP_PRIVATE)
{
__libelf_seterrno (ELF_E_INVALID_OP);
return NULL;
@@ -986,7 +1035,7 @@ elf_begin (fildes, cmd, ref)
{
Elf *retval;
- if (unlikely (! __libelf_version_initialized))
+ if (! __libelf_version_initialized)
{
/* Version wasn't set so far. */
__libelf_seterrno (ELF_E_NO_VERSION);
@@ -996,7 +1045,7 @@ elf_begin (fildes, cmd, ref)
if (ref != NULL)
/* Make sure the descriptor is not suddenly going away. */
rwlock_rdlock (ref->lock);
- else if (unlikely (fcntl (fildes, F_GETFL) == -1 && errno == EBADF))
+ else if (fcntl (fildes, F_GETFL) == -1 && errno == EBADF)
{
/* We cannot do anything productive without a file descriptor. */
__libelf_seterrno (ELF_E_INVALID_FILE);
@@ -1012,7 +1061,7 @@ elf_begin (fildes, cmd, ref)
case ELF_C_READ_MMAP_PRIVATE:
/* If we have a reference it must also be opened this way. */
- if (unlikely (ref != NULL && ref->cmd != ELF_C_READ_MMAP_PRIVATE))
+ if (ref != NULL && ref->cmd != ELF_C_READ_MMAP_PRIVATE)
{
__libelf_seterrno (ELF_E_INVALID_CMD);
retval = NULL;
@@ -1036,9 +1085,8 @@ elf_begin (fildes, cmd, ref)
command. */
if (ref != NULL)
{
- if (unlikely (ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP
- && ref->cmd != ELF_C_WRITE
- && ref->cmd != ELF_C_WRITE_MMAP))
+ if (ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP
+ && ref->cmd != ELF_C_WRITE && ref->cmd != ELF_C_WRITE_MMAP)
{
/* This is not ok. REF must also be opened for writing. */
__libelf_seterrno (ELF_E_INVALID_CMD);
diff --git a/libelf/elf_getarsym.c b/libelf/elf_getarsym.c
index 1af1b1dc..67b2697c 100644
--- a/libelf/elf_getarsym.c
+++ b/libelf/elf_getarsym.c
@@ -28,11 +28,14 @@
#include <string.h>
#include <unistd.h>
-#include <system.h>
#include <dl-hash.h>
#include "libelfP.h"
+#define pread_retry(fd, buf, len, off) \
+ TEMP_FAILURE_RETRY (pread (fd, buf, len, off))
+
+
Elf_Arsym *
elf_getarsym (elf, ptr)
Elf *elf;
diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c
index a21d1f9b..20e8e624 100644
--- a/libelf/elf_getdata.c
+++ b/libelf/elf_getdata.c
@@ -19,13 +19,11 @@
# include <config.h>
#endif
-#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <unistd.h>
#include "libelfP.h"
-#include <system.h>
#include "common.h"
#include "elf-knowledge.h"
@@ -241,7 +239,7 @@ __libelf_set_rawdata (Elf_Scn *scn)
if (entsize == 0)
entsize = 1;
- if (unlikely (size % entsize != 0))
+ if (size % entsize != 0)
{
__libelf_seterrno (ELF_E_INVALID_DATA);
return 1;
@@ -252,7 +250,7 @@ __libelf_set_rawdata (Elf_Scn *scn)
{
/* First see whether the information in the section header is
valid and it does not ask for too much. */
- if (unlikely (offset + size > elf->maximum_size))
+ if (offset + size > elf->maximum_size)
{
/* Something is wrong. */
__libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
@@ -262,7 +260,7 @@ __libelf_set_rawdata (Elf_Scn *scn)
scn->rawdata_base = scn->rawdata.d.d_buf
= (char *) elf->map_address + elf->start_offset + offset;
}
- else if (likely (elf->fildes != -1))
+ else if (elf->fildes != -1)
{
/* We have to read the data from the file. Allocate the needed
memory. */
@@ -274,9 +272,8 @@ __libelf_set_rawdata (Elf_Scn *scn)
return 1;
}
- ssize_t n = pread_retry (elf->fildes, scn->rawdata.d.d_buf, size,
- elf->start_offset + offset);
- if (unlikely ((size_t) n != size))
+ if ((size_t) pread (elf->fildes, scn->rawdata.d.d_buf, size,
+ elf->start_offset + offset) != size)
{
/* Cannot read the data. */
free (scn->rawdata.d.d_buf);
diff --git a/libelf/elf_getshstrndx.c b/libelf/elf_getshstrndx.c
index a765f4e3..706092b7 100644
--- a/libelf/elf_getshstrndx.c
+++ b/libelf/elf_getshstrndx.c
@@ -1,5 +1,5 @@
/* Return section index of section header string table.
- Copyright (C) 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2002 Red Hat, Inc.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
@@ -20,12 +20,10 @@
#endif
#include <assert.h>
-#include <errno.h>
#include <gelf.h>
#include <stddef.h>
#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -102,9 +100,8 @@ elf_getshstrndx (elf, dst)
the first one. */
Elf32_Shdr shdr_mem;
- if (unlikely (pread_retry (elf->fildes, &shdr_mem,
- sizeof (Elf32_Shdr), offset)
- != sizeof (Elf32_Shdr)))
+ if (pread (elf->fildes, &shdr_mem, sizeof (Elf32_Shdr),
+ offset) != sizeof (Elf32_Shdr))
{
/* We must be able to read this ELF section header. */
__libelf_seterrno (ELF_E_INVALID_FILE);
@@ -119,13 +116,15 @@ elf_getshstrndx (elf, dst)
}
else
{
+ size_t offset;
+
if (elf->state.elf64.scns.data[0].shdr.e64 != NULL)
{
num = elf->state.elf64.scns.data[0].shdr.e64->sh_link;
goto success;
}
- size_t offset = elf->state.elf64.ehdr->e_shoff;
+ offset = elf->state.elf64.ehdr->e_shoff;
if (elf->map_address != NULL
&& elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
@@ -140,9 +139,8 @@ elf_getshstrndx (elf, dst)
the first one. */
Elf64_Shdr shdr_mem;
- if (unlikely (pread_retry (elf->fildes, &shdr_mem,
- sizeof (Elf64_Shdr), offset)
- != sizeof (Elf64_Shdr)))
+ if (pread (elf->fildes, &shdr_mem, sizeof (Elf64_Shdr),
+ offset) != sizeof (Elf64_Shdr))
{
/* We must be able to read this ELF section header. */
__libelf_seterrno (ELF_E_INVALID_FILE);
diff --git a/libelf/elf_readall.c b/libelf/elf_readall.c
index efe44bf8..d36da270 100644
--- a/libelf/elf_readall.c
+++ b/libelf/elf_readall.c
@@ -1,5 +1,5 @@
/* Read all of the file associated with the descriptor.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
This program is free software; you can redistribute it and/or modify
@@ -19,10 +19,8 @@
# include <config.h>
#endif
-#include <errno.h>
#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
#include "common.h"
@@ -80,10 +78,8 @@ __libelf_readall (elf)
if (mem != NULL)
{
/* Read the file content. */
- if (unlikely ((size_t) pread_retry (elf->fildes, mem,
- elf->maximum_size,
- elf->start_offset)
- != elf->maximum_size))
+ if ((size_t) pread (elf->fildes, mem, elf->maximum_size,
+ elf->start_offset) != elf->maximum_size)
{
/* Something went wrong. */
__libelf_seterrno (ELF_E_READ_ERROR);
diff --git a/libelf/gelf_rawchunk.c b/libelf/gelf_rawchunk.c
index 6e05c0d4..667f3013 100644
--- a/libelf/gelf_rawchunk.c
+++ b/libelf/gelf_rawchunk.c
@@ -1,5 +1,5 @@
/* Retrieve uninterpreted chunk of the file contents.
- Copyright (C) 2002, 2005 Red Hat, Inc.
+ Copyright (C) 2002 Red Hat, Inc.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
This program is free software; you can redistribute it and/or modify
@@ -19,13 +19,11 @@
# include <config.h>
#endif
-#include <errno.h>
#include <libelf.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
-#include <system.h>
#include "libelfP.h"
@@ -42,9 +40,9 @@ gelf_rawchunk (elf, offset, size)
return NULL;
}
- if (unlikely (offset >= elf->maximum_size
- || offset + size >= elf->maximum_size
- || offset + size < offset))
+ if (offset >= elf->maximum_size
+ || offset + size >= elf->maximum_size
+ || offset + size < offset)
{
/* Invalid request. */
__libelf_seterrno (ELF_E_INVALID_OP);
@@ -61,9 +59,8 @@ gelf_rawchunk (elf, offset, size)
__libelf_seterrno (ELF_E_NOMEM);
else
/* Read the file content. */
- if (unlikely ((size_t) pread_retry (elf->fildes, result, size,
- elf->start_offset + offset)
- != size))
+ if ((size_t) pread (elf->fildes, result, size, elf->start_offset + offset)
+ != size)
{
/* Something went wrong. */
__libelf_seterrno (ELF_E_READ_ERROR);
diff --git a/po/ChangeLog b/po/ChangeLog
index 118952bf..cea77df8 100644
--- a/po/ChangeLog
+++ b/po/ChangeLog
@@ -1,10 +1,6 @@
-2005-08-27 Ulrich Drepper <drepper@redhat.com>
-
- * POTFILES.in: Add src/strings.c.
-
2005-08-15 Ulrich Drepper <drepper@redhat.com>
- * POTFILES.in: Add src/ranlib.c.
+ * POTFILES.in: Add src/ranlib.
2005-08-05 Ulrich Drepper <drepper@redhat.com>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0e74aeb1..c45ee76d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -23,4 +23,3 @@ src/addr2line.c
src/findtextrel.c
src/elfcmp.c
src/ranlib.c
-src/strings.c
diff --git a/src/ChangeLog b/src/ChangeLog
index 5ae77c42..7707ac17 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,18 +1,3 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * ranlib.c: Don't define pread_retry and write_retry here.
-
- * Makefile.an [BUILD_STATIC] (libdw): Add -ldl.
- (CLEANFILES): Add *.gcno *.gcda *.gconv.
-
- * strings.c (process_chunk): Reorder expressions in conditional
- (process_chunk_mb): Likewise.
-
- * strings.c: New file.
- * Makefile.am (bin_PROGRAMS): Add strings.
- (strings_no_Wstring): Define.
- (strings_LDADD): Define.
-
2005-08-24 Ulrich Drepper <drepper@redhat.com>
* elflint.c (check_versym): Versioned symbols should not have
diff --git a/src/Makefile.am b/src/Makefile.am
index 1a489497..234d1b6f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,7 +38,7 @@ native_ld = @native_ld@
base_cpu = @base_cpu@
bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \
- elfcmp objdump ranlib strings
+ elfcmp objdump ranlib
ld_dsos = libld_elf_i386_pic.a
@@ -67,7 +67,7 @@ libmudflap = -lmudflap
endif
if BUILD_STATIC
-libdw = ../libdw/libdw.a $(libelf) $(libebl) -ldl
+libdw = ../libdw/libdw.a $(libelf) $(libebl)
libelf = ../libelf/libelf.a
else
libdw = ../libdw/libdw.so
@@ -78,7 +78,6 @@ libeu = ../lib/libeu.a
nm_no_Wformat = yes
size_no_Wformat = yes
-strings_no_Wformat = yes
# XXX While the file is not finished, don't warn about this
ldgeneric_no_Wunused = yes
@@ -97,7 +96,6 @@ addr2line_LDADD = $(libdw) $(libmudflap)
elfcmp_LDADD = $(libebl) $(libelf) $(libmudflap) -ldl
objdump_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
ranlib_LDADD = $(libelf) $(libeu) $(libmudflap)
-strings_LDADD = $(libelf) $(libeu) $(libmudflap)
ldlex.o: ldscript.c
ldlex_no_Werror = yes
@@ -148,4 +146,4 @@ installcheck-binPROGRAMS: $(bin_PROGRAMS)
done; \
done; rm -f c$${pid}_.???; exit $$bad
-CLEANFILES = none_ld.os $(ld_modules:.c=.os) *.gcno *.gcda *.gconv
+CLEANFILES = none_ld.os $(ld_modules:.c=.os)
diff --git a/src/ranlib.c b/src/ranlib.c
index 1914a178..ce2e6820 100644
--- a/src/ranlib.c
+++ b/src/ranlib.c
@@ -40,6 +40,11 @@
#include <system.h>
+#define pread_retry(fd, buf, n, off) \
+ TEMP_FAILURE_RETRY (pread (fd, buf, n, off))
+#define write_retry(fd, buf, n) \
+ TEMP_FAILURE_RETRY (write (fd, buf, n))
+
#if __BYTE_ORDER == __LITTLE_ENDIAN
# define le_bswap_32(val) bswap_32 (val)
#else
diff --git a/src/strings.c b/src/strings.c
deleted file mode 100644
index 1898ac74..00000000
--- a/src/strings.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/* Print the strings of printable characters in files.
- Copyright (C) 2005 Red Hat, Inc.
- Written by Ulrich Drepper <drepper@redhat.com>, 2005.
-
- This program is Open Source software; you can redistribute it and/or
- modify it under the terms of the Open Software License version 1.0 as
- published by the Open Source Initiative.
-
- You should have received a copy of the Open Software License along
- with this program; if not, you may obtain a copy of the Open Software
- License version 1.0 from http://www.opensource.org/licenses/osl.php or
- by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
- 3001 King Ranch Road, Ukiah, CA 95482. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <argp.h>
-#include <assert.h>
-#include <ctype.h>
-#include <endian.h>
-#include <errno.h>
-#include <error.h>
-#include <fcntl.h>
-#include <gelf.h>
-#include <inttypes.h>
-#include <libintl.h>
-#include <locale.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <stdio_ext.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/mman.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <system.h>
-
-
-/* Prototypes of local functions. */
-static int read_fd (int fd, const char *fname, off64_t fdlen);
-static int read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen);
-
-
-/* Name and version of program. */
-static void print_version (FILE *stream, struct argp_state *state);
-void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
-
-/* Bug report address. */
-const char *argp_program_bug_address = PACKAGE_BUGREPORT;
-
-/* Definitions of arguments for argp functions. */
-static const struct argp_option options[] =
-{
- { NULL, 0, NULL, 0, N_("Output Selection:"), 0 },
- { "all", 'a', NULL, 0, N_("Scan entire file, not only loaded sections"), 0 },
- { "bytes", 'n', "MIN-LEN", 0,
- N_("Only NUL-terminated sequences of MIN-LEN characters or more are printed"), 0 },
- { "encoding", 'e', "SELECTOR", 0, N_("\
-Select character size and endianess: s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit"),
- 0},
- { "print-file-name", 'f', NULL, 0,
- N_("Print name of the file before each string."), 0 },
- { "radix", 't', "{o,d,x}", 0,
- N_("Print location of the string in base 8, 10, or 16 respectively."), 0 },
- { NULL, 'o', NULL, 0, N_("Alias for --radix=o"), 0 },
-
- { NULL, 0, NULL, 0, N_("Miscellaneous:"), 0 },
- { NULL, 0, NULL, 0, NULL, 0 }
-};
-
-/* Short description of program. */
-static const char doc[] = N_("\
-Print the strings of printable characters in files.");
-
-/* Strings for arguments in help texts. */
-static const char args_doc[] = N_("[FILE...]");
-
-/* Prototype for option handler. */
-static error_t parse_opt (int key, char *arg, struct argp_state *state);
-
-/* Data structure to communicate with argp functions. */
-static struct argp argp =
-{
- options, parse_opt, args_doc, doc, NULL, NULL, NULL
-};
-
-
-/* Global variables. */
-
-/* True if whole file and not only loaded sections are looked at. */
-static bool entire_file;
-
-/* Minimum length of any sequence reported. */
-static size_t min_len = 4;
-
-/* Number of bytes per character. */
-static size_t bytes_per_char = 1;
-
-/* Minimum length of any sequence reported in bytes. */
-static size_t min_len_bytes;
-
-/* True if multibyte characters are in big-endian order. */
-static bool big_endian;
-
-/* True unless 7-bit ASCII are expected. */
-static bool char_7bit;
-
-/* True if file names should be printed before strings. */
-static bool print_file_name;
-
-/* Location print format string. */
-static const char *locfmt;
-
-/* Page size in use. */
-static size_t ps;
-
-
-/* Mapped parts of the ELF file. */
-static unsigned char *elfmap;
-static unsigned char *elfmap_base;
-static size_t elfmap_size;
-static off64_t elfmap_off;
-
-
-int
-main (int argc, char *argv[])
-{
- /* We use no threads. */
- __fsetlocking (stdin, FSETLOCKING_BYCALLER);
- __fsetlocking (stdout, FSETLOCKING_BYCALLER);
-
- /* Set locale. */
- (void) setlocale (LC_ALL, "");
-
- /* Make sure the message catalog can be found. */
- (void) bindtextdomain (PACKAGE, LOCALEDIR);
-
- /* Initialize the message catalog. */
- (void) textdomain (PACKAGE);
-
- /* Parse and process arguments. */
- int remaining;
- (void) argp_parse (&argp, argc, argv, 0, &remaining, NULL);
-
- /* Tell the library which version we are expecting. */
- elf_version (EV_CURRENT);
-
- /* Determine the page size. We will likely need it a couple of times. */
- ps = sysconf (_SC_PAGESIZE);
-
- struct stat64 st;
- int result = 0;
- if (remaining == argc)
- /* We read from standard input. This we cannot do for a
- structured file. */
- result = read_fd (STDOUT_FILENO,
- print_file_name ? "{standard input}" : NULL,
- fstat64 (STDOUT_FILENO, &st) == 0
- ? st.st_size : INT64_C (0x7fffffffffffffff));
- else
- do
- {
- int fd = (strcmp (argv[remaining], "-") == 0
- ? STDIN_FILENO : open (argv[remaining], O_RDONLY));
- if (unlikely (fd == -1))
- {
- error (0, errno, gettext ("cannot open '%s'"), argv[remaining]);
- result = 1;
- }
- else
- {
- const char *fname = print_file_name ? argv[remaining] : NULL;
- int fstat_fail = fstat64 (fd, &st);
- off64_t fdlen = (fstat_fail
- ? INT64_C (0x7fffffffffffffff) : st.st_size);
- if (fdlen > (off64_t) min_len_bytes)
- {
- Elf *elf = NULL;
- if (entire_file
- || fstat_fail
- || !S_ISREG (st.st_mode)
- || (elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL
- || elf_kind (elf) != ELF_K_ELF)
- result |= read_fd (fd, fname, fdlen);
- else
- result |= read_elf (elf, fd, fname, fdlen);
-
- /* This call will succeed even if ELF is NULL. */
- elf_end (elf);
- }
-
- if (strcmp (argv[remaining], "-") != 0)
- close (fd);
- }
-
- if (elfmap != NULL && elfmap != MAP_FAILED)
- munmap (elfmap, elfmap_size);
- }
- while (++remaining < argc);
-
- return result;
-}
-
-
-/* Print the version information. */
-static void
-print_version (FILE *stream, struct argp_state *state __attribute__ ((unused)))
-{
- fprintf (stream, "strings (%s) %s\n", PACKAGE_NAME, VERSION);
- fprintf (stream, gettext ("\
-Copyright (C) %s Red Hat, Inc.\n\
-This is free software; see the source for copying conditions. There is NO\n\
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-"), "2005");
- fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper");
-}
-
-
-/* Handle program arguments. */
-static error_t
-parse_opt (int key, char *arg,
- struct argp_state *state __attribute__ ((unused)))
-{
- switch (key)
- {
- case 'a':
- entire_file = true;
- break;
-
- case 'e':
- /* We expect a string of one character. */
- switch (arg[1] != '\0' ? '\0' : arg[0])
- {
- case 's':
- case 'S':
- char_7bit = arg[0] == 's';
- bytes_per_char = 1;
- break;
-
- case 'b':
- case 'B':
- big_endian = true;
- /* FALLTHROUGH */
-
- case 'l':
- case 'L':
- bytes_per_char = isupper (arg[0]) ? 4 : 2;
- break;
-
- default:
- error (0, 0, gettext ("invalid value '%s' for %s parameter"),
- arg, "-e");
- argp_help (&argp, stderr, ARGP_HELP_SEE, "strings");
- return ARGP_ERR_UNKNOWN;
- }
- break;
-
- case 'f':
- print_file_name = true;
- break;
-
- case 'n':
- min_len = atoi (arg);
- break;
-
- case 'o':
- goto octfmt;
-
- case 't':
- switch (arg[0])
- {
- case 'd':
- locfmt = "%7" PRId64 " ";
- break;
-
- case 'o':
- octfmt:
- locfmt = "%7" PRIo64 " ";
- break;
-
- case 'x':
- locfmt = "%7" PRIx64 " ";
- break;
-
- default:
- error (0, 0, gettext ("invalid value '%s' for %s parameter"),
- arg, "-t");
- argp_help (&argp, stderr, ARGP_HELP_SEE, "strings");
- return ARGP_ERR_UNKNOWN;
- }
- break;
-
- case ARGP_KEY_FINI:
- /* Compute the length in bytes of any match. */
- if (min_len <= 0 || min_len > INT_MAX / bytes_per_char)
- error (EXIT_FAILURE, 0,
- gettext ("invalid minimum length of matched string size"));
- min_len_bytes = min_len * bytes_per_char;
- break;
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
-}
-
-
-static void
-process_chunk_mb (const char *fname, const unsigned char *buf, off64_t to,
- size_t len, char **unprinted)
-{
- size_t curlen = *unprinted == NULL ? 0 : strlen (*unprinted);
- const unsigned char *start = buf;
- while (len >= bytes_per_char)
- {
- uint32_t ch;
-
- if (bytes_per_char == 2)
- {
- if (big_endian)
- ch = buf[0] << 8 | buf[1];
- else
- ch = buf[1] << 8 | buf[0];
- }
- else
- {
- if (big_endian)
- ch = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
- else
- ch = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
- }
-
- if (ch <= 255 && (isprint (ch) || ch == '\t'))
- {
- ++buf;
- ++curlen;
- }
- else
- {
- if (curlen >= min_len)
- {
- /* We found a match. */
- if (unlikely (fname != NULL))
- {
- fputs_unlocked (fname, stdout);
- fputs_unlocked (": ", stdout);
- }
-
- if (unlikely (locfmt != NULL))
- printf (locfmt, (int64_t) to - len - (buf - start));
-
- if (unlikely (*unprinted != NULL))
- {
- fputs_unlocked (*unprinted, stdout);
- free (*unprinted);
- *unprinted = NULL;
- }
-
- /* There is no sane way of printing the string. If we
- assume the file data is encoded in UCS-2/UTF-16 or
- UCS-4/UTF-32 respectively we could covert the string.
- But there is no such guarantee. */
- fwrite_unlocked (start, 1, buf - start, stdout);
- putc_unlocked ('\n', stdout);
- }
-
- start = ++buf;
- curlen = 0;
-
- if (len <= min_len)
- break;
- }
-
- --len;
- }
-
- if (curlen != 0)
- *unprinted = xstrndup ((const char *) start, curlen);
-}
-
-
-static void
-process_chunk (const char *fname, const unsigned char *buf, off64_t to,
- size_t len, char **unprinted)
-{
- /* We are not going to slow the check down for the 2- and 4-byte
- encodings. Handle them special. */
- if (unlikely (bytes_per_char != 1))
- {
- process_chunk_mb (fname, buf, to, len, unprinted);
- return;
- }
-
- size_t curlen = *unprinted == NULL ? 0 : strlen (*unprinted);
- const unsigned char *start = buf;
- while (len > 0)
- {
- if ((isprint (*buf) || *buf == '\t') && (! char_7bit || *buf <= 127))
- {
- ++buf;
- ++curlen;
- }
- else
- {
- if (curlen >= min_len)
- {
- /* We found a match. */
- if (unlikely (fname != NULL))
- {
- fputs_unlocked (fname, stdout);
- fputs_unlocked (": ", stdout);
- }
-
- if (unlikely (locfmt != NULL))
- printf (locfmt, (int64_t) to - len - (buf - start));
-
- if (unlikely (*unprinted != NULL))
- {
- fputs_unlocked (*unprinted, stdout);
- free (*unprinted);
- *unprinted = NULL;
- }
- fwrite_unlocked (start, 1, buf - start, stdout);
- putc_unlocked ('\n', stdout);
- }
-
- start = ++buf;
- curlen = 0;
-
- if (len <= min_len)
- break;
- }
-
- --len;
- }
-
- if (curlen != 0)
- *unprinted = xstrndup ((const char *) start, curlen);
-}
-
-
-/* Map a file in as large chunks as possible. */
-static void *
-map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep)
-{
- /* Maximum size we mmap. We use an #ifdef to avoid overflows on
- 32-bit machines. 64-bit machines these days do not have usable
- address spaces larger than about 43 bits. Not that any file
- should be that large. */
-#if SIZE_MAX > 0xffffffff
- const size_t mmap_max = 0x4000000000lu;
-#else
- const size_t mmap_max = 0x40000000lu;
-#endif
-
- /* Try to mmap the file. */
- size_t map_size = MIN ((off64_t) mmap_max, fdlen);
- const size_t map_size_min = MAX (MAX (SIZE_MAX / 16, 2 * ps),
- roundup (2 * min_len_bytes + 1, ps));
- void *mem;
- while (1)
- {
- /* We map the memory for reading only here. Since we will
- always look at every byte of the file it makes sense to
- use MAP_POPULATE. */
- mem = mmap64 (NULL, map_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
- fd, start_off);
- if (mem != MAP_FAILED)
- {
- /* We will go through the mapping sequentially. */
- (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
- break;
- }
- if (errno != EINVAL && errno != ENOMEM)
- /* This is an error other than the lack of address space. */
- break;
-
- /* Maybe the size of the mapping is too big. Try again. */
- map_size /= 2;
- if (map_size < map_size_min)
- /* That size should have fit. */
- break;
- }
-
- *map_sizep = map_size;
- return mem;
-}
-
-
-/* Read the file without mapping. */
-static int
-read_block_no_mmap (int fd, const char *fname, off64_t from, off64_t fdlen)
-{
- char *unprinted = NULL;
-#define CHUNKSIZE 65536
- unsigned char *buf = xmalloc (CHUNKSIZE + min_len_bytes
- + bytes_per_char - 1);
- size_t ntrailer = 0;
- int result = 0;
- while (fdlen > 0)
- {
- ssize_t n = TEMP_FAILURE_RETRY (read (fd, buf + ntrailer,
- MIN (fdlen, CHUNKSIZE)));
- if (n == 0)
- {
- /* There are less than MIN_LEN+1 bytes left so there cannot be
- another match. */
- assert (unprinted == NULL || ntrailer == 0);
- break;
- }
- if (unlikely (n < 0))
- {
- /* Something went wrong. */
- result = 1;
- break;
- }
-
- /* Account for the number of bytes read in this round. */
- fdlen -= n;
-
- /* Do not use the signed N value. Note that the addition cannot
- overflow. */
- size_t nb = (size_t) n + ntrailer;
- if (nb >= min_len_bytes)
- {
- /* We only use complete charactesr. */
- nb &= ~(bytes_per_char - 1);
-
- process_chunk (fname, buf, from + nb, nb, &unprinted);
-
- /* If the last bytes of the buffer (module the character
- size) have been printed we are not copying them. */
- size_t to_keep = unprinted != NULL ? 0 : min_len_bytes;
-
- memmove (buf, buf + nb - to_keep, to_keep + nb);
- ntrailer = to_keep + nb;
- from += nb;
- }
- else
- ntrailer = nb;
- }
-
- free (buf);
-
- /* Don't print anything we collected so far. There is no
- terminating NUL byte. */
- free (unprinted);
-
- return result;
-}
-
-
-static int
-read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to)
-{
- assert ((off64_t) min_len_bytes < fdlen);
-
- if (elfmap == NULL)
- {
- /* We need a completely new mapping. */
- elfmap_off = from & ~(ps - 1);
- elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
-
- if (unlikely (elfmap == MAP_FAILED))
- /* Let the kernel know we are going to read everything in sequence. */
- (void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
- }
-
- if (unlikely (elfmap == MAP_FAILED))
- {
- /* Read from the file descriptor. For this we must position the
- read pointer. */
- // XXX Eventually add flag which avoids this if the position
- // XXX is known to match.
- if (lseek64 (fd, from, SEEK_SET) != from)
- error (EXIT_FAILURE, errno, gettext ("lseek64 failed"));
-
- return read_block_no_mmap (fd, fname, from, to - from);
- }
-
- if (to < (off64_t) elfmap_off || from > (off64_t) (elfmap_off + elfmap_size))
- {
- /* The existing mapping cannot fit at all. Map the new area.
- We always map the full range of ELFMAP_SIZE bytes even if
- this extend beyond the end of the file. The Linux kernel
- handles this OK if the access pages are not touched. */
- elfmap_off = from & ~(ps - 1);
- if (mmap64 (elfmap, elfmap_size, PROT_READ,
- MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, from)
- == MAP_FAILED)
- error (EXIT_FAILURE, errno, gettext ("re-mmap failed"));
- elfmap_base = elfmap;
- }
-
- char *unprinted = NULL;
-
- /* Use the existing mapping as much as possible. If necessary, map
- new pages. */
- if (from >= (off64_t) elfmap_off
- && from < (off64_t) (elfmap_off + elfmap_size))
- /* There are at least a few bytes in this mapping which we can
- use. */
- process_chunk (fname, elfmap_base + (from - elfmap_off),
- MIN (to, (off64_t) (elfmap_off + elfmap_size)),
- MIN (to, (off64_t) (elfmap_off + elfmap_size)) - from,
- &unprinted);
-
- if (to > (off64_t) (elfmap_off + elfmap_size))
- {
- unsigned char *remap_base = elfmap_base;
- size_t read_now = elfmap_size - (elfmap_base - elfmap);
-
- assert (from >= (off64_t) elfmap_off
- && from < (off64_t) (elfmap_off + elfmap_size));
- off64_t handled_to = elfmap_off + elfmap_size;
- assert (elfmap == elfmap_base
- || (elfmap_base - elfmap
- == (ptrdiff_t) ((min_len_bytes + ps - 1) & ~(ps - 1))));
- if (elfmap == elfmap_base)
- {
- size_t keep_area = (min_len_bytes + ps - 1) & ~(ps - 1);
- assert (elfmap_size >= keep_area + ps);
- /* The keep area is used for the content of the previous
- buffer we have to keep. This means copying those bytes
- and for this we have to make the data writable. */
- if (unlikely (mprotect (elfmap, keep_area, PROT_READ | PROT_WRITE)
- != 0))
- error (EXIT_FAILURE, errno, gettext ("mprotect failed"));
-
- elfmap_base = elfmap + keep_area;
- }
-
- while (1)
- {
- /* Map the rest of the file, eventually again in pieces.
- We speed things up with a nice Linux feature. Note
- that we have at least two pages mapped. */
- size_t to_keep = unprinted != NULL ? 0 : min_len_bytes;
-
- assert (read_now >= to_keep);
- memmove (elfmap_base - to_keep,
- remap_base + read_now - to_keep, to_keep);
- remap_base = elfmap_base;
-
- assert ((elfmap_size - (elfmap_base - elfmap)) % bytes_per_char
- == 0);
- read_now = MIN (to - handled_to,
- (ptrdiff_t) elfmap_size - (elfmap_base - elfmap));
-
- assert (handled_to % ps == 0);
- assert (handled_to % bytes_per_char == 0);
- if (mmap64 (remap_base, read_now, PROT_READ,
- MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, handled_to)
- == MAP_FAILED)
- error (EXIT_FAILURE, errno, gettext ("re=mmap failed"));
- elfmap_off = handled_to;
-
- process_chunk (fname, remap_base - to_keep,
- elfmap_off + (read_now & ~(bytes_per_char - 1)),
- to_keep + (read_now & ~(bytes_per_char - 1)),
- &unprinted);
- handled_to += read_now;
- if (handled_to >= to)
- break;
- }
- }
-
- /* Don't print anything we collected so far. There is no
- terminating NUL byte. */
- free (unprinted);
-
- return 0;
-}
-
-
-static int
-read_fd (int fd, const char *fname, off64_t fdlen)
-{
- return read_block (fd, fname, fdlen, 0, fdlen);
-}
-
-
-static int
-read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen)
-{
- assert (fdlen >= 0);
-
- /* We will look at each section separately. The ELF file is not
- mmapped. The libelf implementation will load the needed parts on
- demand. Since we only interate over the section header table the
- memory consumption at this stage is kept minimal. */
- Elf_Scn *scn = elf_nextscn (elf, NULL);
- if (scn == NULL)
- return read_fd (fd, fname, fdlen);
-
- int result = 0;
- do
- {
- GElf_Shdr shdr_mem;
- GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
-
- /* Only look in sections which are loaded at runtime and
- actually have content. */
- if (shdr != NULL && shdr->sh_type != SHT_NOBITS
- && (shdr->sh_flags & SHF_ALLOC) != 0)
- result |= read_block (fd, fname, fdlen, shdr->sh_offset,
- shdr->sh_offset + shdr->sh_size);
- }
- while ((scn = elf_nextscn (elf, scn)) != NULL);
-
- if (elfmap != NULL && elfmap != MAP_FAILED)
- munmap (elfmap, elfmap_size);
- elfmap = NULL;
-
- return result;
-}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 81f8d1d6..bf58cb5a 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,12 +1,6 @@
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
+2005-08-24 Roland McGrath <roland@redhat.com>
- * Makefile.an [BUILD_STATIC] (libdw): Add -ldl.
- (CLEANFILES): Add *.gcno *.gcda *.gconv.
-
-2005-08-28 Ulrich Drepper <drepper@redhat.com>
-
- * run-strings-test.sh: New file.
- * Makefile.am (TESTS, EXTRA_DIST): Add it.
+ * line2addr.c (print_address): Omit () for DSOs.
2005-08-24 Ulrich Drepper <drepper@redhat.com>
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1fb0c1c9..b4cc1b04 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,7 +47,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-strip-test6.sh run-ecp-test.sh run-ecp-test2.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-addrscopes.sh
# run-show-ciefde.sh
EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
@@ -63,7 +63,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-strip-test4.sh run-strip-test5.sh run-strip-test6.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-addrscopes.sh \
testfile15.bz2 testfile15.debug.bz2 \
testfile16.bz2 testfile16.debug.bz2 \
testfile17.bz2 testfile17.debug.bz2 \
@@ -78,7 +78,7 @@ libmudflap = -lmudflap
endif
if BUILD_STATIC
-libdw = ../libdw/libdw.a $(libelf) $(libebl) -ldl
+libdw = ../libdw/libdw.a $(libelf) $(libebl)
libelf = ../libelf/libelf.a
libasm = ../libasm/libasm.a
else
@@ -126,4 +126,4 @@ asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
-CLEANFILES = xxx *.gcno *.gcda *gconv
+CLEANFILES = xxx
diff --git a/tests/line2addr.c b/tests/line2addr.c
index 73c57f49..4c3b6045 100644
--- a/tests/line2addr.c
+++ b/tests/line2addr.c
@@ -28,7 +28,7 @@ print_address (Dwfl_Module *mod, Dwarf_Addr address)
if (n > 1 || secname[0] != '\0')
printf ("%s(%s)+%#" PRIx64, modname, secname, address);
else
- printf ("%s(%s)+%#" PRIx64, modname, secname, address);
+ printf ("%s+%#" PRIx64, modname, address);
return;
}
}
diff --git a/tests/run-strings-test.sh b/tests/run-strings-test.sh
deleted file mode 100755
index 9c744afe..00000000
--- a/tests/run-strings-test.sh
+++ /dev/null
@@ -1,475 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2005 Red Hat, Inc.
-# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
-#
-# This program is Open Source software; you can redistribute it and/or
-# modify it under the terms of the Open Software License version 1.0 as
-# published by the Open Source Initiative.
-#
-# You should have received a copy of the Open Software License along
-# with this program; if not, you may obtain a copy of the Open Software
-# License version 1.0 from http://www.opensource.org/licenses/osl.php or
-# by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
-# 3001 King Ranch Road, Ukiah, CA 95482.
-set -e
-
-# Don't fail if we cannot decompress the file.
-bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 0
-
-# Don't fail if we cannot decompress the file.
-for n in $(seq 2 9); do
-bunzip2 -c $srcdir/testfile$n.bz2 > testfile$n 2>/dev/null || exit 0
-done
-
-LD_LIBRARY_PATH=../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
- ../src/strings -tx -f testfile testfile[23456789] > strings.out
-
-diff -u strings.out - <<"EOF"
-testfile: f4 /lib/ld-linux.so.2
-testfile: 1c9 __gmon_start__
-testfile: 1d8 libc.so.6
-testfile: 1e2 __cxa_finalize
-testfile: 1f1 __deregister_frame_info
-testfile: 209 _IO_stdin_used
-testfile: 218 __libc_start_main
-testfile: 22a __register_frame_info
-testfile: 240 GLIBC_2.1.3
-testfile: 24c GLIBC_2.0
-testfile: 338 PTRh
-testfile: 345 QVh,
-testfile2: 114 /lib/ld.so.1
-testfile2: 1f1 __gmon_start__
-testfile2: 200 __deregister_frame_info
-testfile2: 218 __register_frame_info
-testfile2: 22e libc.so.6
-testfile2: 238 __cxa_finalize
-testfile2: 247 _IO_stdin_used
-testfile2: 256 __libc_start_main
-testfile2: 268 GLIBC_2.1.3
-testfile2: 274 GLIBC_2.0
-testfile2: 488 }a[xN
-testfile2: 4a8 }a[xN
-testfile2: 50c }a[xN
-testfile2: 540 }?Kx
-testfile3: f4 /lib/ld-linux.so.2
-testfile3: 1c9 __gmon_start__
-testfile3: 1d8 libc.so.6
-testfile3: 1e2 __cxa_finalize
-testfile3: 1f1 __deregister_frame_info
-testfile3: 209 _IO_stdin_used
-testfile3: 218 __libc_start_main
-testfile3: 22a __register_frame_info
-testfile3: 240 GLIBC_2.1.3
-testfile3: 24c GLIBC_2.0
-testfile3: 338 PTRh
-testfile3: 345 QVh,
-testfile4: f4 /lib/ld-linux.so.2
-testfile4: 8e1 __gmon_start__
-testfile4: 8f0 __terminate_func
-testfile4: 901 stderr
-testfile4: 908 __tf9type_info
-testfile4: 917 __tf16__user_type_info
-testfile4: 92e __tf19__pointer_type_info
-testfile4: 948 __tf16__attr_type_info
-testfile4: 95f __tf16__func_type_info
-testfile4: 976 __vt_9type_info
-testfile4: 986 __vt_19__pointer_type_info
-testfile4: 9a1 __vt_16__attr_type_info
-testfile4: 9b9 __vt_16__func_type_info
-testfile4: 9d1 __vt_16__ptmf_type_info
-testfile4: 9e9 __vt_16__ptmd_type_info
-testfile4: a01 __vt_17__array_type_info
-testfile4: a1a __tiv
-testfile4: a20 __vt_19__builtin_type_info
-testfile4: a3b __tix
-testfile4: a41 __til
-testfile4: a47 __tii
-testfile4: a4d __tis
-testfile4: a53 __tib
-testfile4: a59 __tic
-testfile4: a5f __tiw
-testfile4: a65 __tir
-testfile4: a6b __tid
-testfile4: a71 __tif
-testfile4: a77 __tiUi
-testfile4: a7e __tiUl
-testfile4: a85 __tiUx
-testfile4: a8c __tiUs
-testfile4: a93 __tiUc
-testfile4: a9a __tiSc
-testfile4: aa1 __ti19__pointer_type_info
-testfile4: abb __ti9type_info
-testfile4: aca __ti16__attr_type_info
-testfile4: ae1 __ti19__builtin_type_info
-testfile4: afb __ti16__func_type_info
-testfile4: b12 __ti16__ptmf_type_info
-testfile4: b29 __ti16__ptmd_type_info
-testfile4: b40 __ti17__array_type_info
-testfile4: b58 __cplus_type_matcher
-testfile4: b6d __vt_13bad_exception
-testfile4: b82 __vt_9exception
-testfile4: b92 _._13bad_exception
-testfile4: ba5 __vt_8bad_cast
-testfile4: bb4 _._8bad_cast
-testfile4: bc1 __vt_10bad_typeid
-testfile4: bd3 _._10bad_typeid
-testfile4: be3 __ti9exception
-testfile4: bf2 __ti13bad_exception
-testfile4: c06 __vt_16__user_type_info
-testfile4: c1e __vt_17__class_type_info
-testfile4: c37 __vt_14__si_type_info
-testfile4: c4d __ti8bad_cast
-testfile4: c5b __ti10bad_typeid
-testfile4: c6c __ti16__user_type_info
-testfile4: c83 __ti14__si_type_info
-testfile4: c98 __ti17__class_type_info
-testfile4: cb0 libc.so.6
-testfile4: cba __register_frame
-testfile4: ccb pthread_create
-testfile4: cda pthread_getspecific
-testfile4: cee pthread_key_delete
-testfile4: d01 __cxa_finalize
-testfile4: d10 malloc
-testfile4: d17 __frame_state_for
-testfile4: d29 abort
-testfile4: d2f __register_frame_table
-testfile4: d46 fprintf
-testfile4: d4e pthread_once
-testfile4: d5b __deregister_frame_info
-testfile4: d73 pthread_key_create
-testfile4: d86 memset
-testfile4: d8d strcmp
-testfile4: d94 pthread_mutex_unlock
-testfile4: da9 __deregister_frame
-testfile4: dbc pthread_mutex_lock
-testfile4: dcf _IO_stdin_used
-testfile4: dde __libc_start_main
-testfile4: df0 strlen
-testfile4: df7 __register_frame_info_table
-testfile4: e13 __register_frame_info
-testfile4: e29 pthread_setspecific
-testfile4: e3d free
-testfile4: e42 GLIBC_2.1.3
-testfile4: e4e GLIBC_2.0
-testfile4: 1308 PTRh<
-testfile4: 194b [^_]
-testfile4: 19bf [^_]
-testfile4: 1dd9 wT9L>
-testfile4: 1f3b [^_]
-testfile4: 1fae [^_]
-testfile4: 21c1 BZQRP
-testfile4: 237f [^_]
-testfile4: 2431 JWRV
-testfile4: 2454 [^_]
-testfile4: 2506 JWRV
-testfile4: 2529 [^_]
-testfile4: 2b6c [^_]
-testfile4: 2b9d ZYPV
-testfile4: 2c28 [^_]
-testfile4: 2c4d ZYPV
-testfile4: 2ce2 [^_]
-testfile4: 2dfb X^_]
-testfile4: 2fc8 [^_]
-testfile4: 307d tq;F
-testfile4: 315a [^_]
-testfile4: 31a5 :zt 1
-testfile4: 3238 [^_]
-testfile4: 32f8 AXY_VR
-testfile4: 334a [^_]
-testfile4: 37ab [^_]
-testfile4: 38b8 sU;E
-testfile4: 38f2 QRPV
-testfile4: 3926 [^_]
-testfile4: 3bfe QRWP
-testfile4: 3e65 [^_]
-testfile4: 4136 [^_]
-testfile4: 472d [^_]
-testfile4: 47a5 0[^_]
-testfile4: 48ab [^_]
-testfile4: 4ab1 _ZPV
-testfile4: 4b53 _ZPV
-testfile4: 4bd3 _ZPV
-testfile4: 4e05 PQWj
-testfile4: 4f75 [^_]
-testfile4: 4f9b u$;E u
-testfile4: 4feb [^_]
-testfile4: 5080 [^_]
-testfile4: 50a8 }$9u
-testfile4: 5149 [^_]
-testfile4: 51b0 [^_]
-testfile4: 539b [^_]
-testfile4: 53b5 E 9E
-testfile4: 540d x!)E
-testfile4: 5598 U$ B
-testfile4: 571c [^_]
-testfile4: 5819 [^_]
-testfile4: 5922 [^_]
-testfile4: 59c2 [^_]
-testfile4: 5a62 [^_]
-testfile4: 5b02 [^_]
-testfile4: 5ba2 [^_]
-testfile4: 5c42 [^_]
-testfile4: 5ce2 [^_]
-testfile4: 6112 [^_]
-testfile4: 62bb [^_]
-testfile4: 639b [^_]
-testfile4: 6436 [^_]
-testfile4: 6468 val is zero
-testfile4: 6480 Internal Compiler Bug: No runtime type matcher.
-testfile4: 64dc 19__pointer_type_info
-testfile4: 64f2 16__attr_type_info
-testfile4: 6505 19__builtin_type_info
-testfile4: 651b 16__func_type_info
-testfile4: 652e 16__ptmf_type_info
-testfile4: 6541 16__ptmd_type_info
-testfile4: 6554 17__array_type_info
-testfile4: 6568 9exception
-testfile4: 6573 13bad_exception
-testfile4: 6583 9type_info
-testfile4: 658e 8bad_cast
-testfile4: 6598 10bad_typeid
-testfile4: 65a5 16__user_type_info
-testfile4: 65b8 14__si_type_info
-testfile4: 65c9 17__class_type_info
-testfile4: 6fc1 H. $
-testfile5: f4 /lib/ld-linux.so.2
-testfile5: 1c9 __gmon_start__
-testfile5: 1d8 libc.so.6
-testfile5: 1e2 __cxa_finalize
-testfile5: 1f1 __deregister_frame_info
-testfile5: 209 _IO_stdin_used
-testfile5: 218 __libc_start_main
-testfile5: 22a __register_frame_info
-testfile5: 240 GLIBC_2.1.3
-testfile5: 24c GLIBC_2.0
-testfile5: 338 PTRh
-testfile5: 345 QVhD
-testfile6: 114 /lib/ld-linux.so.2
-testfile6: 3d9 libstdc++.so.5
-testfile6: 3e8 _ZTVSt16invalid_argument
-testfile6: 401 _ZNSaIcEC1Ev
-testfile6: 40e _ZTSSt16invalid_argument
-testfile6: 427 _ZTVN10__cxxabiv120__si_class_type_infoE
-testfile6: 450 _ZNSsD1Ev
-testfile6: 45a _ZdlPv
-testfile6: 461 __cxa_end_catch
-testfile6: 471 __gxx_personality_v0
-testfile6: 486 _ZTISt9exception
-testfile6: 497 _ZNSaIcED1Ev
-testfile6: 4a4 _ZTISt11logic_error
-testfile6: 4b8 _ZNSt16invalid_argumentD1Ev
-testfile6: 4d4 _ZTVN10__cxxabiv117__class_type_infoE
-testfile6: 4fa __cxa_throw
-testfile6: 506 _ZNSt16invalid_argumentC1ERKSs
-testfile6: 525 _ZNSsC1EPKcRKSaIcE
-testfile6: 538 _ZNSt11logic_errorD2Ev
-testfile6: 54f _ZTVN10__cxxabiv121__vmi_class_type_infoE
-testfile6: 579 _ZNSt16invalid_argumentD0Ev
-testfile6: 595 __cxa_begin_catch
-testfile6: 5a7 __cxa_allocate_exception
-testfile6: 5c0 _ZNKSt11logic_error4whatEv
-testfile6: 5db _Jv_RegisterClasses
-testfile6: 5ef _ZTISt16invalid_argument
-testfile6: 608 __gmon_start__
-testfile6: 617 libm.so.6
-testfile6: 621 _IO_stdin_used
-testfile6: 630 libgcc_s.so.1
-testfile6: 63e _Unwind_Resume
-testfile6: 64d libc.so.6
-testfile6: 657 __libc_start_main
-testfile6: 669 GCC_3.0
-testfile6: 671 GLIBC_2.0
-testfile6: 67b GLIBCPP_3.2
-testfile6: 687 CXXABI_1.2
-testfile6: 908 PTRh
-testfile6: e48 gdb.1
-testfile6: ec8 N10__gnu_test9gnu_obj_1E
-testfile6: ee1 N10__gnu_test9gnu_obj_2IiEE
-testfile6: efd N10__gnu_test9gnu_obj_2IlEE
-testfile6: f19 St16invalid_argument
-testfile7: 114 /lib/ld-linux.so.2
-testfile7: 3d9 libstdc++.so.5
-testfile7: 3e8 _ZTVSt16invalid_argument
-testfile7: 401 _ZNSaIcEC1Ev
-testfile7: 40e _ZTSSt16invalid_argument
-testfile7: 427 _ZTVN10__cxxabiv120__si_class_type_infoE
-testfile7: 450 _ZNSsD1Ev
-testfile7: 45a _ZdlPv
-testfile7: 461 __cxa_end_catch
-testfile7: 471 __gxx_personality_v0
-testfile7: 486 _ZTISt9exception
-testfile7: 497 _ZNSaIcED1Ev
-testfile7: 4a4 _ZTISt11logic_error
-testfile7: 4b8 _ZNSt16invalid_argumentD1Ev
-testfile7: 4d4 _ZTVN10__cxxabiv117__class_type_infoE
-testfile7: 4fa __cxa_throw
-testfile7: 506 _ZNSt16invalid_argumentC1ERKSs
-testfile7: 525 _ZNSsC1EPKcRKSaIcE
-testfile7: 538 _ZNSt11logic_errorD2Ev
-testfile7: 54f _ZTVN10__cxxabiv121__vmi_class_type_infoE
-testfile7: 579 _ZNSt16invalid_argumentD0Ev
-testfile7: 595 __cxa_begin_catch
-testfile7: 5a7 __cxa_allocate_exception
-testfile7: 5c0 _ZNKSt11logic_error4whatEv
-testfile7: 5db _Jv_RegisterClasses
-testfile7: 5ef _ZTISt16invalid_argument
-testfile7: 608 __gmon_start__
-testfile7: 617 libm.so.6
-testfile7: 621 _IO_stdin_used
-testfile7: 630 libgcc_s.so.1
-testfile7: 63e _Unwind_Resume
-testfile7: 64d libc.so.6
-testfile7: 657 __libc_start_main
-testfile7: 669 GCC_3.0
-testfile7: 671 GLIBC_2.0
-testfile7: 67b GLIBCPP_3.2
-testfile7: 687 CXXABI_1.2
-testfile7: 908 PTRh
-testfile7: e48 gdb.1
-testfile7: ec8 N10__gnu_test9gnu_obj_1E
-testfile7: ee1 N10__gnu_test9gnu_obj_2IiEE
-testfile7: efd N10__gnu_test9gnu_obj_2IlEE
-testfile7: f19 St16invalid_argument
-testfile8: 79 XZh;
-testfile8: 87 YXh<
-testfile8: 14f SQh[
-testfile8: 259 t5Wj
-testfile8: 502 WRVQ
-testfile8: 1fe7 ZYPj
-testfile8: 2115 u'Pj
-testfile8: 7bba FILE
-testfile8: 7bbf preserve-dates
-testfile8: 7bce remove-comment
-testfile8: 7bdd Remove .comment section
-testfile8: 7bf6 ${prefix}/share
-testfile8: 7c06 elfutils
-testfile8: 7c0f a.out
-testfile8: 7c15 0.58
-testfile8: 7c1a strip (Red Hat %s) %s
-testfile8: 7c31 2002
-testfile8: 7c36 Ulrich Drepper
-testfile8: 7c45 Written by %s.
-testfile8: 7c55 cannot stat input file "%s"
-testfile8: 7c71 %s: INTERNAL ERROR: %s
-testfile8: 7c88 while opening "%s"
-testfile8: 7c9b handle_elf
-testfile8: 7ca6 ../../src/strip.c
-testfile8: 7cb8 shdr_info[cnt].group_idx != 0
-testfile8: 7cd6 illformed file `%s'
-testfile8: 7cea elf_ndxscn (scn) == cnt
-testfile8: 7d02 .shstrtab
-testfile8: 7d0c while writing `%s': %s
-testfile8: 7d23 ((sym->st_info) & 0xf) == 3
-testfile8: 7d3f shndxdata != ((void *)0)
-testfile8: 7d58 scn != ((void *)0)
-testfile8: 7d6b .gnu_debuglink
-testfile8: 7d7a .comment
-testfile8: 7d83 cannot open `%s'
-testfile8: 7da0 Place stripped output into FILE
-testfile8: 7dc0 Extract the removed sections into FILE
-testfile8: 7e00 Copy modified/access timestamps to the output
-testfile8: 7e40 Only one input file allowed together with '-o' and '-f'
-testfile8: 7e80 Copyright (C) %s Red Hat, Inc.
-testfile8: 7e9f This is free software; see the source for copying conditions. There is NO
-testfile8: 7eea warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-testfile8: 7f40 Report bugs to <drepper@redhat.com>.
-testfile8: 7f80 %s: File format not recognized
-testfile8: 7fa0 cannot set access and modification date of "%s"
-testfile8: 7fe0 cannot create new file `%s': %s
-testfile8: 8000 error while finishing `%s': %s
-testfile8: 8020 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0
-testfile8: 8060 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0
-testfile8: 80a0 %s: error while creating ELF header: %s
-testfile8: 80e0 %s: error while reading the file: %s
-testfile8: 8120 sec < 0xff00 || shndxdata != ((void *)0)
-testfile8: 8160 (versiondata->d_size / sizeof (GElf_Versym)) >= shdr_info[cnt].data->d_size / elsize
-testfile8: 81c0 shdr_info[cnt].shdr.sh_type == 11
-testfile8: 8200 (versiondata->d_size / sizeof (Elf32_Word)) >= shdr_info[cnt].data->d_size / elsize
-testfile8: 8260 shdr_info[cnt].shdr.sh_type == 18
-testfile8: 82a0 shdr_info[cnt].data != ((void *)0)
-testfile8: 82e0 elf_ndxscn (shdr_info[cnt].newscn) == idx
-testfile8: 8320 while create section header section: %s
-testfile8: 8360 cannot allocate section data: %s
-testfile8: 83a0 elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx
-testfile8: 83e0 while generating output file: %s
-testfile8: 8420 while preparing output for `%s'
-testfile8: 8440 shdr_info[cnt].shdr.sh_type == 2
-testfile8: 8480 shdr_info[idx].data != ((void *)0)
-testfile8: 84c0 cannot determine number of sections: %s
-testfile8: 8500 cannot get section header string table index
-testfile8: 85c0 Discard symbols from object files.
-testfile8: 85e3 [FILE...]
-testfile9: 79 XZh;
-testfile9: 87 YXh<
-testfile9: 14f SQh[
-testfile9: 259 t5Wj
-testfile9: 502 WRVQ
-testfile9: 1fe7 ZYPj
-testfile9: 2115 u'Pj
-testfile9: 3414 FILE
-testfile9: 3419 preserve-dates
-testfile9: 3428 remove-comment
-testfile9: 3437 Remove .comment section
-testfile9: 3450 ${prefix}/share
-testfile9: 3460 elfutils
-testfile9: 3469 a.out
-testfile9: 346f 0.58
-testfile9: 3474 strip (Red Hat %s) %s
-testfile9: 348b 2002
-testfile9: 3490 Ulrich Drepper
-testfile9: 349f Written by %s.
-testfile9: 34af cannot stat input file "%s"
-testfile9: 34cb %s: INTERNAL ERROR: %s
-testfile9: 34e2 while opening "%s"
-testfile9: 34f5 handle_elf
-testfile9: 3500 ../../src/strip.c
-testfile9: 3512 shdr_info[cnt].group_idx != 0
-testfile9: 3530 illformed file `%s'
-testfile9: 3544 elf_ndxscn (scn) == cnt
-testfile9: 355c .shstrtab
-testfile9: 3566 while writing `%s': %s
-testfile9: 357d ((sym->st_info) & 0xf) == 3
-testfile9: 3599 shndxdata != ((void *)0)
-testfile9: 35b2 scn != ((void *)0)
-testfile9: 35c5 .gnu_debuglink
-testfile9: 35d4 .comment
-testfile9: 35dd cannot open `%s'
-testfile9: 3600 Place stripped output into FILE
-testfile9: 3620 Extract the removed sections into FILE
-testfile9: 3660 Copy modified/access timestamps to the output
-testfile9: 36a0 Only one input file allowed together with '-o' and '-f'
-testfile9: 36e0 Copyright (C) %s Red Hat, Inc.
-testfile9: 36ff This is free software; see the source for copying conditions. There is NO
-testfile9: 374a warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-testfile9: 37a0 Report bugs to <drepper@redhat.com>.
-testfile9: 37e0 %s: File format not recognized
-testfile9: 3800 cannot set access and modification date of "%s"
-testfile9: 3840 cannot create new file `%s': %s
-testfile9: 3860 error while finishing `%s': %s
-testfile9: 3880 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0
-testfile9: 38c0 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0
-testfile9: 3900 %s: error while creating ELF header: %s
-testfile9: 3940 %s: error while reading the file: %s
-testfile9: 3980 sec < 0xff00 || shndxdata != ((void *)0)
-testfile9: 39c0 (versiondata->d_size / sizeof (GElf_Versym)) >= shdr_info[cnt].data->d_size / elsize
-testfile9: 3a20 shdr_info[cnt].shdr.sh_type == 11
-testfile9: 3a60 (versiondata->d_size / sizeof (Elf32_Word)) >= shdr_info[cnt].data->d_size / elsize
-testfile9: 3ac0 shdr_info[cnt].shdr.sh_type == 18
-testfile9: 3b00 shdr_info[cnt].data != ((void *)0)
-testfile9: 3b40 elf_ndxscn (shdr_info[cnt].newscn) == idx
-testfile9: 3b80 while create section header section: %s
-testfile9: 3bc0 cannot allocate section data: %s
-testfile9: 3c00 elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx
-testfile9: 3c40 while generating output file: %s
-testfile9: 3c80 while preparing output for `%s'
-testfile9: 3ca0 shdr_info[cnt].shdr.sh_type == 2
-testfile9: 3ce0 shdr_info[idx].data != ((void *)0)
-testfile9: 3d20 cannot determine number of sections: %s
-testfile9: 3d60 cannot get section header string table index
-testfile9: 3e20 Discard symbols from object files.
-testfile9: 3e43 [FILE...]
-EOF
-
-rm -f testfile testfile[23456789]
-
-exit 0