summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * configure.ac: Add --enable-gcov option.
4
52005-08-06 Ulrich Drepper <drepper@redhat.com> 12005-08-06 Ulrich Drepper <drepper@redhat.com>
6 2
7 * configure.ac: Add --enable-gprof option. 3 * configure.ac: Add --enable-gprof option.
diff --git a/NEWS b/NEWS
index 7d5d4afc..a15e1f12 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,3 @@
1Version 0.115:
2
3libelf: speed-ups of non-mmap reading.
4
5strings: New program.
6
7Implement --enable-gcov option for configure.
8
9Version 0.114: 1Version 0.114:
10 2
11libelf: new function elf_getaroff 3libelf: new function elf_getaroff
diff --git a/TODO b/TODO
index 9eb7b6ca..318da823 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,7 @@
1 ToDo list for elfutils -*-outline-*- 1 ToDo list for elfutils -*-outline-*-
2 ---------------------- 2 ----------------------
3 3
4Time-stamp: <2005-08-29 08:58:24 drepper> 4Time-stamp: <2005-08-03 20:38:01 drepper>
5 5
6* mkinstalldirs 6* mkinstalldirs
7 7
@@ -23,7 +23,15 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
23 remains maintainable. 23 remains maintainable.
24 24
25 25
26* libdw 26* libdwarf
27
28** Should we do more error checking?
29
30 Most functions don't check whether they get a NULL value passed for
31 a pointer argument. It could be argued that this is OK since it's
32 a bug inthe program. But perhaps one could catch the case and return
33 an error which would allow the program using libdwarf to have fewer
34 places with error checking.
27 35
28** More memory access checks needed 36** More memory access checks needed
29 37
@@ -37,6 +45,12 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
37 45
38** Rename dwarf_getabbrev 46** Rename dwarf_getabbrev
39 47
48** dwarf_loclist()
49
50 This function and its interface seem to be misdesigned. The specification
51 is unclear and its changed between v2 and v2.1. Other implementation
52 implement even different behavior.
53
40 54
41* nm: 55* nm:
42 56
@@ -102,14 +116,6 @@ Time-stamp: <2005-08-29 08:58:24 drepper>
102 116
103 prelink generated files 117 prelink generated files
104 118
105* elfcmp
106
107** treat relocation sections special
108
109 Differences in the relocation sections can be ignored if all
110 the same symbols with the same targets are present and the order
111 of overlapping relocations doesn't change. There really never
112 should be overlapping relocations but who knows.
113 119
114* mcs 120* mcs
115 121
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}
143%{_bindir}/eu-findtextrel 143%{_bindir}/eu-findtextrel
144%{_bindir}/eu-addr2line 144%{_bindir}/eu-addr2line
145%{_bindir}/eu-elfcmp 145%{_bindir}/eu-elfcmp
146%{_bindir}/eu-ranlib
147%{_bindir}/eu-strings
148%if !%{fake} 146%if !%{fake}
149#%{_bindir}/eu-ld 147#%{_bindir}/eu-ld
150#%{_libdir}/libasm-%{version}.so 148#%{_libdir}/libasm-%{version}.so
@@ -199,13 +197,13 @@ ss, dwfl_linux_kernel_report_offline.
199 197
200* Wed Aug 10 2005 Ulrich Drepper <@redhat.com> 0.113-1 198* Wed Aug 10 2005 Ulrich Drepper <@redhat.com> 0.113-1
201- elflint: relax a bit. Allow version definitions for defined symbols ag 199- elflint: relax a bit. Allow version definitions for defined symbols ag
202ainstDSO versions also for symbols in nobits sections. Allow .rodata 200ainstDSO versions also for symbols in nobits sections. Allow .rodata
203sectionto have STRINGS and MERGE flag set. 201sectionto have STRINGS and MERGE flag set.
204- strip: add some more compatibility with binutils. 202- strip: add some more compatibility with binutils.
205 203
206* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1 204* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1
207- elflint: relax a bit. Allow version definitions for defined symbols ag 205- elflint: relax a bit. Allow version definitions for defined symbols ag
208ainstDSO versions also for symbols in nobits sections. Allow .rodata 206ainstDSO versions also for symbols in nobits sections. Allow .rodata
209sectionto have STRINGS and MERGE flag set. 207sectionto have STRINGS and MERGE flag set.
210 208
211* Sat Aug 6 2005 Ulrich Drepper <@redhat.com> 0.113-1 209* 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
16dnl along with this program; if not, write to the Free Software Foundation, 16dnl along with this program; if not, write to the Free Software Foundation,
17dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18dnl 18dnl
19AC_INIT([Red Hat elfutils],[0.115],[http://bugzilla.redhat.com/bugzilla/], 19AC_INIT([Red Hat elfutils],[0.114],[http://bugzilla.redhat.com/bugzilla/],
20 [elfutils]) 20 [elfutils])
21 21
22AC_CONFIG_AUX_DIR([config]) 22AC_CONFIG_AUX_DIR([config])
@@ -138,19 +138,8 @@ if test "$use_gprof" = yes; then
138 LDFLAGS="$LDFLAGS -pg" 138 LDFLAGS="$LDFLAGS -pg"
139fi 139fi
140AM_CONDITIONAL(GPROF, test "$use_gprof" = yes) 140AM_CONDITIONAL(GPROF, test "$use_gprof" = yes)
141
142# Enable gcov suport.
143AC_ARG_ENABLE([gcov],
144AC_HELP_STRING([--enable-gcov],
145[build binaries with gcov support]), [use_gcov=yes], [use_gcov=no])
146if test "$use_gcov" = yes; then
147 CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
148 LDFLAGS="$LDFLAGS -fprofile-arcs"
149fi
150AM_CONDITIONAL(GPROF, test "$use_gprof" = yes)
151
152AM_CONDITIONAL(BUILD_STATIC, [dnl 141AM_CONDITIONAL(BUILD_STATIC, [dnl
153test "$use_mudflap" = yes -o "$use_gprof" = yes -o "$use_gcov" = yes]) 142test "$use_mudflap" = yes -o "$use_gprof" = yes])
154 143
155LIBEBL_SUBDIR="$PACKAGE" 144LIBEBL_SUBDIR="$PACKAGE"
156AC_ARG_ENABLE([libebl-subdir], 145AC_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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * system.h: Define pwrite_retry, write_retry, and pread_retry.
4
52005-08-06 Ulrich Drepper <drepper@redhat.com> 12005-08-06 Ulrich Drepper <drepper@redhat.com>
6 2
7 * Makefile.am (xmalloc_CFLAGS): Define only if !GPROF. 3 * 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);
37 37
38#define gettext_noop(Str) Str 38#define gettext_noop(Str) Str
39 39
40
41#define pwrite_retry(fd, buf, len, off) \
42 TEMP_FAILURE_RETRY (pwrite (fd, buf, len, off))
43#define write_retry(fd, buf, n) \
44 TEMP_FAILURE_RETRY (write (fd, buf, n))
45#define pread_retry(fd, buf, len, off) \
46 TEMP_FAILURE_RETRY (pread (fd, buf, len, off))
47
48#endif /* system.h */ 40#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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * Makefile.am: Use $(LINK) not $(CC) when creating DSO.
4 (%.os): Use COMPILE.os.
5 (COMPILE.os): Filter out gconv options.
6
72005-08-02 Ulrich Drepper <drepper@redhat.com> 12005-08-02 Ulrich Drepper <drepper@redhat.com>
8 2
9 * Makefile.am (AM_CFLAGS): Add -std=gnu99. 3 * 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 \
24GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include) 24GCC_INCLUDE = -I$(shell $(CC) -print-file-name=include)
25VERSION = 1 25VERSION = 1
26 26
27COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
28 $(COMPILE)))
29
30lib_LIBRARIES = libasm.a 27lib_LIBRARIES = libasm.a
31if !MUDFLAP 28if !MUDFLAP
32noinst_LIBRARIES = libasm_pic.a 29noinst_LIBRARIES = libasm_pic.a
@@ -54,16 +51,16 @@ am_libasm_pic_a_OBJECTS = $(libasm_a_SOURCES:.c=.os)
54 51
55libasm_so_SOURCES = 52libasm_so_SOURCES =
56libasm.so: libasm_pic.a libasm.map 53libasm.so: libasm_pic.a libasm.map
57 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 54 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
58 -Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \ 55 -Wl,--version-script,$(srcdir)/libasm.map,--no-undefined \
59 -Wl,--soname,$@.$(VERSION) \ 56 -Wl,--soname,$@.$(VERSION) \
60 ../libebl/libebl.a ../libelf/libelf.so 57 ../libebl/libebl.a ../libelf/libelf.so
61 if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi 58 if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
62 ln -fs $@ $@.$(VERSION) 59 ln -fs $@ $@.$(VERSION)
63 60
64 61
65%.os: %.c %.o 62%.os: %.c %.o
66 if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ 63 if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
67 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ 64 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
68 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ 65 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
69 rm -f "$(DEPDIR)/$*.Tpo"; \ 66 rm -f "$(DEPDIR)/$*.Tpo"; \
@@ -86,4 +83,4 @@ endif
86noinst_HEADERS = libasmP.h symbolhash.h 83noinst_HEADERS = libasmP.h symbolhash.h
87EXTRA_DIST = libasm.map 84EXTRA_DIST = libasm.map
88 85
89CLEANFILES = $(am_libasm_pic_a_OBJECTS) *.gcno *.gcda 86CLEANFILES = $(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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * Makefile.am: Use $(LINK) not $(CC) when creating DSO.
4 (%.os): Use COMPILE.os.
5 (COMPILE.os): Filter out gconv options.
6
72005-08-23 Roland McGrath <roland@redhat.com> 12005-08-23 Roland McGrath <roland@redhat.com>
8 2
9 * dwarf_attr_integrate.c (dwarf_attr_integrate): Treat 3 * 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
22INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib 22INCLUDES = -I. -I$(srcdir) -I$(srcdir)/../libelf -I.. -I$(srcdir)/../lib
23VERSION = 1 23VERSION = 1
24 24
25COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
26 $(COMPILE)))
27
28lib_LIBRARIES = libdw.a 25lib_LIBRARIES = libdw.a
29if !MUDFLAP 26if !MUDFLAP
30noinst_LIBRARIES = libdw_pic.a 27noinst_LIBRARIES = libdw_pic.a
@@ -79,15 +76,15 @@ libdw_so_SOURCES =
79libdw.so: $(srcdir)/libdw.map libdw_pic.a \ 76libdw.so: $(srcdir)/libdw.map libdw_pic.a \
80 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a \ 77 ../libdwfl/libdwfl_pic.a ../libebl/libebl.a \
81 ../libelf/libelf.so 78 ../libelf/libelf.so
82 $(LINK) -shared -o $@ -Wl,--soname,$@.$(VERSION),-z,defs \ 79 $(CC) -shared -o $@ -Wl,--soname,$@.$(VERSION),-z,defs \
83 -Wl,--version-script,$<,--no-undefined \ 80 -Wl,--version-script,$<,--no-undefined \
84 -Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive\ 81 -Wl,--whole-archive $(filter-out $<,$^) -Wl,--no-whole-archive \
85 -ldl 82 -ldl
86 if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi 83 if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
87 ln -fs $@ $@.$(VERSION) 84 ln -fs $@ $@.$(VERSION)
88 85
89%.os: %.c %.o 86%.os: %.c %.o
90 if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ 87 if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
91 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ 88 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
92 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ 89 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
93 rm -f "$(DEPDIR)/$*.Tpo"; \ 90 rm -f "$(DEPDIR)/$*.Tpo"; \
@@ -113,4 +110,4 @@ noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h
113 110
114EXTRA_DIST = libdw.map 111EXTRA_DIST = libdw.map
115 112
116CLEANFILES = $(am_libdw_pic_a_OBJECTS) *.gcno *.gcda 113CLEANFILES = $(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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * Makefile.am (%.os): Use COMPILE.os.
4 (COMPILE.os): Filter out gconv options.
5
62005-08-24 Roland McGrath <roland@redhat.com> 12005-08-24 Roland McGrath <roland@redhat.com>
7 2
8 * argp-std.c [_MUDFLAP] (__libdwfl_argp_mudflap_options): New function, 3 * 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 \
25 -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib 25 -I$(srcdir)/../libdw -I.. -I$(srcdir)/../lib
26VERSION = 1 26VERSION = 1
27 27
28COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
29 $(COMPILE)))
30
31noinst_LIBRARIES = libdwfl.a 28noinst_LIBRARIES = libdwfl.a
32if !MUDFLAP 29if !MUDFLAP
33noinst_LIBRARIES += libdwfl_pic.a 30noinst_LIBRARIES += libdwfl_pic.a
@@ -74,7 +71,7 @@ libdwfl_pic_a_SOURCES =
74am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os) 71am_libdwfl_pic_a_OBJECTS = $(libdwfl_a_SOURCES:.c=.os)
75 72
76%.os: %.c %.o 73%.os: %.c %.o
77 if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ 74 if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
78 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ 75 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
79 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ 76 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
80 rm -f "$(DEPDIR)/$*.Tpo"; \ 77 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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * Makefile.am: Use $(LINK) not $(CC) when creating DSOs.
4
52005-08-13 Roland McGrath <roland@redhat.com> 12005-08-13 Roland McGrath <roland@redhat.com>
6 2
7 * ia64_symbol.c (ia64_machine_flag_check): New function. 3 * 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
69 69
70libebl_i386_so_SOURCES = 70libebl_i386_so_SOURCES =
71libebl_i386.so: libebl_i386_pic.a libebl_i386.map 71libebl_i386.so: libebl_i386_pic.a libebl_i386.map
72 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 72 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
73 -Wl,--version-script,$(srcdir)/libebl_i386.map \ 73 -Wl,--version-script,$(srcdir)/libebl_i386.map \
74 -Wl,-z,defs $(libelf) $(libmudflap) 74 -Wl,-z,defs $(libelf) $(libmudflap)
75 $(textrel_check) 75 $(textrel_check)
76 76
77 77
@@ -81,9 +81,9 @@ am_libebl_sh_pic_a_OBJECTS = $(sh_SRCS:.c=.os)
81 81
82libebl_sh_so_SOURCES = 82libebl_sh_so_SOURCES =
83libebl_sh.so: libebl_sh_pic.a libebl_sh.map 83libebl_sh.so: libebl_sh_pic.a libebl_sh.map
84 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 84 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
85 -Wl,--version-script,$(srcdir)/libebl_sh.map \ 85 -Wl,--version-script,$(srcdir)/libebl_sh.map \
86 -Wl,-z,defs $(libmudflap) 86 -Wl,-z,defs $(libmudflap)
87 $(textrel_check) 87 $(textrel_check)
88 88
89 89
@@ -93,9 +93,9 @@ am_libebl_x86_64_pic_a_OBJECTS = $(x86_64_SRCS:.c=.os)
93 93
94libebl_x86_64_so_SOURCES = 94libebl_x86_64_so_SOURCES =
95libebl_x86_64.so: libebl_x86_64_pic.a libebl_x86_64.map 95libebl_x86_64.so: libebl_x86_64_pic.a libebl_x86_64.map
96 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 96 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
97 -Wl,--version-script,$(srcdir)/libebl_x86_64.map \ 97 -Wl,--version-script,$(srcdir)/libebl_x86_64.map \
98 -Wl,-z,defs $(libelf) $(libmudflap) 98 -Wl,-z,defs $(libelf) $(libmudflap)
99 $(textrel_check) 99 $(textrel_check)
100 100
101 101
@@ -105,9 +105,9 @@ am_libebl_ia64_pic_a_OBJECTS = $(ia64_SRCS:.c=.os)
105 105
106libebl_ia64_so_SOURCES = 106libebl_ia64_so_SOURCES =
107libebl_ia64.so: libebl_ia64_pic.a libebl_ia64.map 107libebl_ia64.so: libebl_ia64_pic.a libebl_ia64.map
108 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 108 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
109 -Wl,--version-script,$(srcdir)/libebl_ia64.map \ 109 -Wl,--version-script,$(srcdir)/libebl_ia64.map \
110 -Wl,-z,defs $(libmudflap) 110 -Wl,-z,defs $(libmudflap)
111 $(textrel_check) 111 $(textrel_check)
112 112
113 113
@@ -117,9 +117,9 @@ am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os)
117 117
118libebl_alpha_so_SOURCES = 118libebl_alpha_so_SOURCES =
119libebl_alpha.so: libebl_alpha_pic.a libebl_alpha.map 119libebl_alpha.so: libebl_alpha_pic.a libebl_alpha.map
120 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 120 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
121 -Wl,--version-script,$(srcdir)/libebl_alpha.map \ 121 -Wl,--version-script,$(srcdir)/libebl_alpha.map \
122 -Wl,-z,defs $(libmudflap) 122 -Wl,-z,defs $(libmudflap)
123 $(textrel_check) 123 $(textrel_check)
124 124
125 125
@@ -129,9 +129,9 @@ am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os)
129 129
130libebl_arm_so_SOURCES = 130libebl_arm_so_SOURCES =
131libebl_arm.so: libebl_arm_pic.a libebl_arm.map 131libebl_arm.so: libebl_arm_pic.a libebl_arm.map
132 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 132 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
133 -Wl,--version-script,$(srcdir)/libebl_arm.map \ 133 -Wl,--version-script,$(srcdir)/libebl_arm.map \
134 -Wl,-z,defs $(libmudflap) 134 -Wl,-z,defs $(libmudflap)
135 $(textrel_check) 135 $(textrel_check)
136 136
137 137
@@ -141,9 +141,9 @@ am_libebl_sparc_pic_a_OBJECTS = $(sparc_SRCS:.c=.os)
141 141
142libebl_sparc_so_SOURCES = 142libebl_sparc_so_SOURCES =
143libebl_sparc.so: libebl_sparc_pic.a libebl_sparc.map 143libebl_sparc.so: libebl_sparc_pic.a libebl_sparc.map
144 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 144 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
145 -Wl,--version-script,$(srcdir)/libebl_sparc.map \ 145 -Wl,--version-script,$(srcdir)/libebl_sparc.map \
146 -Wl,-z,defs $(libmudflap) 146 -Wl,-z,defs $(libmudflap)
147 $(textrel_check) 147 $(textrel_check)
148 148
149 149
@@ -153,9 +153,9 @@ am_libebl_ppc_pic_a_OBJECTS = $(ppc_SRCS:.c=.os)
153 153
154libebl_ppc_so_SOURCES = 154libebl_ppc_so_SOURCES =
155libebl_ppc.so: libebl_ppc_pic.a libebl_ppc.map 155libebl_ppc.so: libebl_ppc_pic.a libebl_ppc.map
156 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 156 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
157 -Wl,--version-script,$(srcdir)/libebl_ppc.map \ 157 -Wl,--version-script,$(srcdir)/libebl_ppc.map \
158 -Wl,-z,defs $(libelf) $(libmudflap) 158 -Wl,-z,defs $(libelf) $(libmudflap)
159 $(textrel_check) 159 $(textrel_check)
160 160
161 161
@@ -165,9 +165,9 @@ am_libebl_ppc64_pic_a_OBJECTS = $(ppc64_SRCS:.c=.os)
165 165
166libebl_ppc64_so_SOURCES = 166libebl_ppc64_so_SOURCES =
167libebl_ppc64.so: libebl_ppc64_pic.a libebl_ppc64.map 167libebl_ppc64.so: libebl_ppc64_pic.a libebl_ppc64.map
168 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 168 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
169 -Wl,--version-script,$(srcdir)/libebl_ppc64.map \ 169 -Wl,--version-script,$(srcdir)/libebl_ppc64.map \
170 -Wl,-z,defs $(libelf) $(libmudflap) 170 -Wl,-z,defs $(libelf) $(libmudflap)
171 $(textrel_check) 171 $(textrel_check)
172 172
173 173
@@ -199,5 +199,5 @@ noinst_HEADERS = libeblP.h $(noinst_LIBRARIES:%_pic.a=%.h)
199EXTRA_DIST = $(noinst_LIBRARIES:%_pic.a=%.map) \ 199EXTRA_DIST = $(noinst_LIBRARIES:%_pic.a=%.map) \
200 $(foreach m,$(modules),$($(m)_SRCS)) 200 $(foreach m,$(modules),$($(m)_SRCS))
201 201
202CLEANFILES = $(am_libebl_pic_a_OBJECTS) *.gcno *.gcda \ 202CLEANFILES = $(am_libebl_pic_a_OBJECTS) \
203 $(foreach m,$(modules),$(am_libebl_$(m)_pic_a_OBJECTS)) 203 $(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 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * elf32_getphdr.c: Include <system.h>. Use pread_retry instead of
4 pread. And branch prediction where useful.
5 * elf_begin.c: Likewise.
6 * elf_getdata.c: Likewise.
7 * elf_getshstrndx.c: Likewise.
8 * elf_readall.c: Likewise.
9 * gelf_rawchunk.c: Likewise.
10 * elf32_updatefile.c: Include <system.h>. Use pread_retry instead of
11 pread. And branch prediction where useful.
12 * elf_getarsym.c: Don't define pread_retry here.
13
14 * Makefile.am: Use $(LINK) not $(CC) when creating DSO.
15 (%.os): Use COMPILE.os.
16 (COMPILE.os): Filter out gconv options.
17
182005-08-27 Ulrich Drepper <drepper@redhat.com>
19
20 * elf_begin.c (file_read_elf): Avoid reading ELF header from file
21 again. Instead accept additional parameter which points to it if we
22 don't use mmap.
23 (get_shnum): Use passed in e_ident value as source of ELF header.
24
252005-08-15 Ulrich Drepper <drepper@redhat.com> 12005-08-15 Ulrich Drepper <drepper@redhat.com>
26 2
27 * elf_begin.c (__libelf_next_arhdr): Use TEMP_FAILURE_RETRY. 3 * 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)
31VERSION = 1 31VERSION = 1
32PACKAGE_VERSION = @PACKAGE_VERSION@ 32PACKAGE_VERSION = @PACKAGE_VERSION@
33 33
34COMPILE.os = $(filter-out -fprofile-arcs, $(filter-out -ftest-coverage, \
35 $(COMPILE)))
36
37lib_LIBRARIES = libelf.a 34lib_LIBRARIES = libelf.a
38if !MUDFLAP 35if !MUDFLAP
39noinst_LIBRARIES = libelf_pic.a 36noinst_LIBRARIES = libelf_pic.a
@@ -95,14 +92,14 @@ am_libelf_pic_a_OBJECTS = $(libelf_a_SOURCES:.c=.os)
95 92
96libelf_so_SOURCES = 93libelf_so_SOURCES =
97libelf.so: libelf_pic.a libelf.map 94libelf.so: libelf_pic.a libelf.map
98 $(LINK) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \ 95 $(CC) -shared -o $@ -Wl,--whole-archive,$<,--no-whole-archive \
99 -Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \ 96 -Wl,--version-script,$(srcdir)/libelf.map,--no-undefined \
100 -Wl,--soname,$@.$(VERSION),-z,-defs 97 -Wl,--soname,$@.$(VERSION),-z,-defs
101 if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi 98 if readelf -d $@ | fgrep -q TEXTREL; then exit 1; fi
102 ln -fs $@ $@.$(VERSION) 99 ln -fs $@ $@.$(VERSION)
103 100
104%.os: %.c %.o 101%.os: %.c %.o
105 if $(COMPILE.os) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \ 102 if $(COMPILE) -c -o $@ -fpic -DPIC -DSHARED -MT $@ -MD -MP \
106 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \ 103 -MF "$(DEPDIR)/$*.Tpo" `test -f '$<' || echo '$(srcdir)/'`$<; \
107 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \ 104 then cat "$(DEPDIR)/$*.Tpo" >> "$(DEPDIR)/$*.Po"; \
108 rm -f "$(DEPDIR)/$*.Tpo"; \ 105 rm -f "$(DEPDIR)/$*.Tpo"; \
@@ -125,4 +122,4 @@ noinst_HEADERS = elf.h abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \
125 version_xlate.h dl-hash.h 122 version_xlate.h dl-hash.h
126EXTRA_DIST = libelf.map 123EXTRA_DIST = libelf.map
127 124
128CLEANFILES = $(am_libelf_pic_a_OBJECTS) *.gcno *.gcda 125CLEANFILES = $(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 @@
19# include <config.h> 19# include <config.h>
20#endif 20#endif
21 21
22#include <errno.h>
23#include <stdlib.h> 22#include <stdlib.h>
24#include <unistd.h> 23#include <unistd.h>
25 24
26#include <system.h>
27#include "libelfP.h" 25#include "libelfP.h"
28#include "common.h" 26#include "common.h"
29 27
@@ -150,10 +148,9 @@ elfw2(LIBELFBITS,getphdr) (elf)
150 elf->state.ELFW(elf,LIBELFBITS).phdr_flags |= ELF_F_MALLOCED; 148 elf->state.ELFW(elf,LIBELFBITS).phdr_flags |= ELF_F_MALLOCED;
151 149
152 /* Read the header. */ 150 /* Read the header. */
153 ssize_t n = pread_retry (elf->fildes, 151 if ((size_t) pread (elf->fildes,
154 elf->state.ELFW(elf,LIBELFBITS).phdr, size, 152 elf->state.ELFW(elf,LIBELFBITS).phdr, size,
155 elf->start_offset + ehdr->e_phoff); 153 (elf->start_offset + ehdr->e_phoff)) != size)
156 if (unlikely ((size_t) n != size))
157 { 154 {
158 /* Severe problems. We cannot read the data. */ 155 /* Severe problems. We cannot read the data. */
159 __libelf_seterrno (ELF_E_READ_ERROR); 156 __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 @@
20#endif 20#endif
21 21
22#include <assert.h> 22#include <assert.h>
23#include <errno.h>
24#include <unistd.h> 23#include <unistd.h>
25 24
26#include <system.h>
27#include "libelfP.h" 25#include "libelfP.h"
28#include "common.h" 26#include "common.h"
29 27
@@ -124,13 +122,12 @@ elfw2(LIBELFBITS,getshdr) (scn)
124 CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize); 122 CONVERT_TO (shdr[cnt].sh_entsize, notcvt[cnt].sh_entsize);
125 } 123 }
126 } 124 }
127 else if (likely (elf->fildes != -1)) 125 else if (elf->fildes != -1)
128 { 126 {
129 /* Read the header. */ 127 /* Read the header. */
130 ssize_t n = pread_retry (elf->fildes, 128 if ((size_t) pread (elf->fildes,
131 elf->state.ELFW(elf,LIBELFBITS).shdr, size, 129 elf->state.ELFW(elf,LIBELFBITS).shdr, size,
132 elf->start_offset + ehdr->e_shoff); 130 elf->start_offset + ehdr->e_shoff) != size)
133 if (unlikely ((size_t) n != size))
134 { 131 {
135 /* Severe problems. We cannot read the data. */ 132 /* Severe problems. We cannot read the data. */
136 __libelf_seterrno (ELF_E_READ_ERROR); 133 __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 @@
20#endif 20#endif
21 21
22#include <assert.h> 22#include <assert.h>
23#include <errno.h>
24#include <libelf.h> 23#include <libelf.h>
25#include <stdbool.h> 24#include <stdbool.h>
26#include <stdlib.h> 25#include <stdlib.h>
@@ -28,7 +27,6 @@
28#include <unistd.h> 27#include <unistd.h>
29#include <sys/param.h> 28#include <sys/param.h>
30 29
31#include <system.h>
32#include "libelfP.h" 30#include "libelfP.h"
33 31
34 32
@@ -328,7 +326,7 @@ fill (int fd, off_t pos, size_t len, char *fillbuf, size_t *filledp)
328 /* This many bytes we want to write in this round. */ 326 /* This many bytes we want to write in this round. */
329 size_t n = MIN (filled, len); 327 size_t n = MIN (filled, len);
330 328
331 if (unlikely ((size_t) pwrite_retry (fd, fillbuf, n, pos) != n)) 329 if (unlikely ((size_t) pwrite (fd, fillbuf, n, pos) != n))
332 { 330 {
333 __libelf_seterrno (ELF_E_WRITE_ERROR); 331 __libelf_seterrno (ELF_E_WRITE_ERROR);
334 return 1; 332 return 1;
@@ -383,8 +381,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
383 } 381 }
384 382
385 /* Write out the ELF header. */ 383 /* Write out the ELF header. */
386 if (unlikely (pwrite_retry (elf->fildes, out_ehdr, 384 if (unlikely (pwrite (elf->fildes, out_ehdr,
387 sizeof (ElfW2(LIBELFBITS,Ehdr)), 0) 385 sizeof (ElfW2(LIBELFBITS,Ehdr)), 0)
388 != sizeof (ElfW2(LIBELFBITS,Ehdr)))) 386 != sizeof (ElfW2(LIBELFBITS,Ehdr))))
389 { 387 {
390 __libelf_seterrno (ELF_E_WRITE_ERROR); 388 __libelf_seterrno (ELF_E_WRITE_ERROR);
@@ -443,10 +441,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
443 } 441 }
444 442
445 /* Write out the ELF header. */ 443 /* Write out the ELF header. */
446 size_t phdr_size = sizeof (ElfW2(LIBELFBITS,Phdr)) * ehdr->e_phnum; 444 if (unlikely ((size_t) pwrite (elf->fildes, out_phdr,
447 if (unlikely ((size_t) pwrite_retry (elf->fildes, out_phdr, 445 sizeof (ElfW2(LIBELFBITS,Phdr))
448 phdr_size, ehdr->e_phoff) 446 * ehdr->e_phnum, ehdr->e_phoff)
449 != phdr_size)) 447 != sizeof (ElfW2(LIBELFBITS,Phdr)) * ehdr->e_phnum))
450 { 448 {
451 __libelf_seterrno (ELF_E_WRITE_ERROR); 449 __libelf_seterrno (ELF_E_WRITE_ERROR);
452 return 1; 450 return 1;
@@ -546,10 +544,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
546 (*fctp) (buf, dl->data.d.d_buf, dl->data.d.d_size, 1); 544 (*fctp) (buf, dl->data.d.d_buf, dl->data.d.d_size, 1);
547 } 545 }
548 546
549 ssize_t n = pwrite_retry (elf->fildes, buf, 547 if (unlikely ((size_t) pwrite (elf->fildes, buf,
550 dl->data.d.d_size, 548 dl->data.d.d_size,
551 last_offset); 549 last_offset)
552 if (unlikely ((size_t) n != dl->data.d.d_size)) 550 != dl->data.d.d_size))
553 { 551 {
554 if (buf != dl->data.d.d_buf && buf != tmpbuf) 552 if (buf != dl->data.d.d_buf && buf != tmpbuf)
555 free (buf); 553 free (buf);
@@ -595,9 +593,9 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum)
595 593
596 /* Write out the section header table. */ 594 /* Write out the section header table. */
597 if (shdr_flags & ELF_F_DIRTY 595 if (shdr_flags & ELF_F_DIRTY
598 && unlikely ((size_t) pwrite_retry (elf->fildes, shdr_data, 596 && unlikely ((size_t) pwrite (elf->fildes, shdr_data,
599 sizeof (ElfW2(LIBELFBITS,Shdr)) 597 sizeof (ElfW2(LIBELFBITS,Shdr))
600 * shnum, shdr_offset) 598 * shnum, shdr_offset)
601 != sizeof (ElfW2(LIBELFBITS,Shdr)) * shnum)) 599 != sizeof (ElfW2(LIBELFBITS,Shdr)) * shnum))
602 { 600 {
603 __libelf_seterrno (ELF_E_WRITE_ERROR); 601 __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 @@
31#include <sys/param.h> 31#include <sys/param.h>
32#include <sys/stat.h> 32#include <sys/stat.h>
33 33
34#include <system.h>
35#include "libelfP.h" 34#include "libelfP.h"
36#include "common.h" 35#include "common.h"
37 36
@@ -78,40 +77,41 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
78 bool is32 = e_ident[EI_CLASS] == ELFCLASS32; 77 bool is32 = e_ident[EI_CLASS] == ELFCLASS32;
79 78
80 /* Make the ELF header available. */ 79 /* Make the ELF header available. */
81 if (e_ident[EI_DATA] == MY_ELFDATA) 80 if (likely (map_address != NULL) && e_ident[EI_DATA] == MY_ELFDATA
82 ehdr.p = e_ident; 81 && (ALLOW_UNALIGNED
82 || (((size_t) ((char *) map_address + offset))
83 & ((is32 ? __alignof__ (Elf32_Ehdr) : __alignof__ (Elf64_Ehdr))
84 - 1)) == 0))
85 ehdr.p = (char *) map_address + offset;
83 else 86 else
84 { 87 {
85 /* We already read the ELF header. We have to copy the header 88 /* We have to read the data from the file. */
86 since we possibly modify the data here and the caller 89 size_t len = is32 ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr);
87 expects the memory it passes in to be preserved. */
88 ehdr.p = &ehdr_mem;
89 90
90 if (is32) 91 if (likely (map_address != NULL))
92 ehdr.p = memcpy (&ehdr_mem, (char *) map_address + offset, len);
93 else
91 { 94 {
92 if (ALLOW_UNALIGNED) 95 /* Fill it. */
93 { 96 if ((size_t) TEMP_FAILURE_RETRY (pread (fildes, &ehdr_mem, len,
94 ehdr_mem.e32.e_shnum = ((Elf32_Ehdr *) e_ident)->e_shnum; 97 offset)) != len)
95 ehdr_mem.e32.e_shoff = ((Elf32_Ehdr *) e_ident)->e_shoff; 98 /* Failed reading. */
96 } 99 return (size_t) -1l;
97 else 100 ehdr.p = &ehdr_mem;
98 memcpy (&ehdr_mem, e_ident, sizeof (Elf32_Ehdr));
99
100 CONVERT (ehdr_mem.e32.e_shnum);
101 CONVERT (ehdr_mem.e32.e_shoff);
102 } 101 }
103 else 102
103 if (e_ident[EI_DATA] != MY_ELFDATA)
104 { 104 {
105 if (ALLOW_UNALIGNED) 105 if (is32)
106 { 106 {
107 ehdr_mem.e64.e_shnum = ((Elf64_Ehdr *) e_ident)->e_shnum; 107 CONVERT (ehdr.e32->e_shnum);
108 ehdr_mem.e64.e_shoff = ((Elf64_Ehdr *) e_ident)->e_shoff; 108 CONVERT (ehdr.e32->e_shoff);
109 } 109 }
110 else 110 else
111 memcpy (&ehdr_mem, e_ident, sizeof (Elf64_Ehdr)); 111 {
112 112 CONVERT (ehdr.e64->e_shnum);
113 CONVERT (ehdr_mem.e64.e_shnum); 113 CONVERT (ehdr.e64->e_shoff);
114 CONVERT (ehdr_mem.e64.e_shoff); 114 }
115 } 115 }
116 } 116 }
117 117
@@ -145,10 +145,12 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
145 + offset))->sh_size, 145 + offset))->sh_size,
146 sizeof (Elf32_Word)); 146 sizeof (Elf32_Word));
147 else 147 else
148 if (unlikely (pread_retry (fildes, &size, sizeof (Elf32_Word), 148 if (TEMP_FAILURE_RETRY (pread (fildes, &size,
149 offset + ehdr.e32->e_shoff 149 sizeof (Elf32_Word),
150 + offsetof (Elf32_Shdr, sh_size)) 150 offset + ehdr.e32->e_shoff
151 != sizeof (Elf32_Word))) 151 + offsetof (Elf32_Shdr,
152 sh_size)))
153 != sizeof (Elf32_Word))
152 return (size_t) -1l; 154 return (size_t) -1l;
153 155
154 if (e_ident[EI_DATA] != MY_ELFDATA) 156 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,
187 + offset))->sh_size, 189 + offset))->sh_size,
188 sizeof (Elf64_Xword)); 190 sizeof (Elf64_Xword));
189 else 191 else
190 if (unlikely (pread_retry (fildes, &size, sizeof (Elf64_Word), 192 if (TEMP_FAILURE_RETRY (pread (fildes, &size,
191 offset + ehdr.e64->e_shoff 193 sizeof (Elf64_Word),
192 + offsetof (Elf64_Shdr, sh_size)) 194 offset + ehdr.e64->e_shoff
193 != sizeof (Elf64_Xword))) 195 + offsetof (Elf64_Shdr,
196 sh_size)))
197 != sizeof (Elf64_Xword))
194 return (size_t) -1l; 198 return (size_t) -1l;
195 199
196 if (e_ident[EI_DATA] != MY_ELFDATA) 200 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,
211 215
212/* Create descriptor for ELF file in memory. */ 216/* Create descriptor for ELF file in memory. */
213static Elf * 217static Elf *
214file_read_elf (int fildes, void *map_address, unsigned char *e_ident, 218file_read_elf (int fildes, void *map_address, off_t offset, size_t maxsize,
215 off_t offset, size_t maxsize, Elf_Cmd cmd, Elf *parent) 219 Elf_Cmd cmd, Elf *parent)
216{ 220{
221 /* We only read the ELF header now. */
222 unsigned char *e_ident;
223 unsigned char e_ident_mem[EI_NIDENT];
224 size_t scncnt;
225 Elf *elf;
226
227 if (map_address != NULL)
228 /* It's right at the beginning of the file. No word access
229 required, just bytes. */
230 e_ident = (unsigned char *) map_address + offset;
231 else
232 {
233 e_ident = e_ident_mem;
234
235 if (TEMP_FAILURE_RETRY (pread (fildes, e_ident, EI_NIDENT, offset))
236 != EI_NIDENT)
237 {
238 __libelf_seterrno (ELF_E_READ_ERROR);
239 return NULL;
240 }
241 }
242
217 /* Verify the binary is of the class we can handle. */ 243 /* Verify the binary is of the class we can handle. */
218 if (unlikely ((e_ident[EI_CLASS] != ELFCLASS32 244 if ((e_ident[EI_CLASS] != ELFCLASS32
219 && e_ident[EI_CLASS] != ELFCLASS64) 245 && e_ident[EI_CLASS] != ELFCLASS64)
220 /* We also can only handle two encodings. */ 246 /* We also can only handle two encodings. */
221 || (e_ident[EI_DATA] != ELFDATA2LSB 247 || (e_ident[EI_DATA] != ELFDATA2LSB
222 && e_ident[EI_DATA] != ELFDATA2MSB))) 248 && e_ident[EI_DATA] != ELFDATA2MSB))
223 { 249 {
224 /* Cannot handle this. */ 250 /* Cannot handle this. */
225 __libelf_seterrno (ELF_E_INVALID_FILE); 251 __libelf_seterrno (ELF_E_INVALID_FILE);
@@ -227,14 +253,14 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
227 } 253 }
228 254
229 /* Determine the number of sections. */ 255 /* Determine the number of sections. */
230 size_t scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize); 256 scncnt = get_shnum (map_address, e_ident, fildes, offset, maxsize);
231 if (scncnt == (size_t) -1l) 257 if (scncnt == (size_t) -1l)
232 /* Could not determine the number of sections. */ 258 /* Could not determine the number of sections. */
233 return NULL; 259 return NULL;
234 260
235 /* We can now allocate the memory. */ 261 /* We can now allocate the memory. */
236 Elf *elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent, 262 elf = allocate_elf (fildes, map_address, offset, maxsize, cmd, parent,
237 ELF_K_ELF, scncnt * sizeof (Elf_Scn)); 263 ELF_K_ELF, scncnt * sizeof (Elf_Scn));
238 if (elf == NULL) 264 if (elf == NULL)
239 /* Not enough memory. */ 265 /* Not enough memory. */
240 return NULL; 266 return NULL;
@@ -242,9 +268,6 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
242 /* Some more or less arbitrary value. */ 268 /* Some more or less arbitrary value. */
243 elf->state.elf.scnincr = 10; 269 elf->state.elf.scnincr = 10;
244 270
245 /* Make the class easily available. */
246 elf->class = e_ident[EI_CLASS];
247
248 if (e_ident[EI_CLASS] == ELFCLASS32) 271 if (e_ident[EI_CLASS] == ELFCLASS32)
249 { 272 {
250 /* This pointer might not be directly usable if the alignment is 273 /* 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,
264 & (__alignof__ (Elf32_Phdr) - 1)) == 0))) 287 & (__alignof__ (Elf32_Phdr) - 1)) == 0)))
265 { 288 {
266 /* We can use the mmapped memory. */ 289 /* We can use the mmapped memory. */
267 elf->state.elf32.ehdr = ehdr; 290 elf->state.elf32.ehdr =
268 elf->state.elf32.shdr 291 (Elf32_Ehdr *) ((char *) map_address + offset);
269 = (Elf32_Shdr *) ((char *) ehdr + ehdr->e_shoff); 292 elf->state.elf32.shdr =
270 if (ehdr->e_phnum > 0) 293 (Elf32_Shdr *) ((char *) map_address + offset
294 + elf->state.elf32.ehdr->e_shoff);
295 if (elf->state.elf32.ehdr->e_phnum)
271 /* Assign a value only if there really is a program 296 /* Assign a value only if there really is a program
272 header. Otherwise the value remains NULL. */ 297 header. Otherwise the value remains NULL. */
273 elf->state.elf32.phdr 298 elf->state.elf32.phdr
274 = (Elf32_Phdr *) ((char *) ehdr + ehdr->e_phoff); 299 = (Elf32_Phdr *) ((char *) map_address + offset
300 + elf->state.elf32.ehdr->e_phoff);
275 301
276 for (size_t cnt = 0; cnt < scncnt; ++cnt) 302 for (size_t cnt = 0; cnt < scncnt; ++cnt)
277 { 303 {
@@ -288,9 +314,21 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
288 } 314 }
289 else 315 else
290 { 316 {
291 /* Copy the ELF header. */ 317 if (likely (map_address != NULL))
292 elf->state.elf32.ehdr = memcpy (&elf->state.elf32.ehdr_mem, e_ident, 318 /* Copy the data. */
293 sizeof (Elf32_Ehdr)); 319 memcpy (&elf->state.elf32.ehdr_mem,
320 (char *) map_address + offset, sizeof (Elf32_Ehdr));
321 else
322 /* Read the data. */
323 if (TEMP_FAILURE_RETRY (pread (elf->fildes,
324 &elf->state.elf32.ehdr_mem,
325 sizeof (Elf32_Ehdr), offset))
326 != sizeof (Elf32_Ehdr))
327 {
328 /* We must be able to read the ELF header. */
329 __libelf_seterrno (ELF_E_INVALID_FILE);
330 return NULL;
331 }
294 332
295 if (e_ident[EI_DATA] != MY_ELFDATA) 333 if (e_ident[EI_DATA] != MY_ELFDATA)
296 { 334 {
@@ -309,6 +347,8 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
309 CONVERT (elf->state.elf32.ehdr_mem.e_shstrndx); 347 CONVERT (elf->state.elf32.ehdr_mem.e_shstrndx);
310 } 348 }
311 349
350 elf->state.elf32.ehdr = &elf->state.elf32.ehdr_mem;
351
312 for (size_t cnt = 0; cnt < scncnt; ++cnt) 352 for (size_t cnt = 0; cnt < scncnt; ++cnt)
313 { 353 {
314 elf->state.elf32.scns.data[cnt].index = cnt; 354 elf->state.elf32.scns.data[cnt].index = cnt;
@@ -339,14 +379,17 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
339 & (__alignof__ (Elf64_Phdr) - 1)) == 0))) 379 & (__alignof__ (Elf64_Phdr) - 1)) == 0)))
340 { 380 {
341 /* We can use the mmapped memory. */ 381 /* We can use the mmapped memory. */
342 elf->state.elf64.ehdr = ehdr; 382 elf->state.elf64.ehdr =
343 elf->state.elf64.shdr 383 (Elf64_Ehdr *) ((char *) map_address + offset);
344 = (Elf64_Shdr *) ((char *) ehdr + ehdr->e_shoff); 384 elf->state.elf64.shdr =
345 if (ehdr->e_phnum > 0) 385 (Elf64_Shdr *) ((char *) map_address + offset
386 + elf->state.elf64.ehdr->e_shoff);
387 if (elf->state.elf64.ehdr->e_phnum)
346 /* Assign a value only if there really is a program 388 /* Assign a value only if there really is a program
347 header. Otherwise the value remains NULL. */ 389 header. Otherwise the value remains NULL. */
348 elf->state.elf64.phdr 390 elf->state.elf64.phdr
349 = (Elf64_Phdr *) ((char *) ehdr + ehdr->e_phoff); 391 = (Elf64_Phdr *) ((char *) map_address + offset
392 + elf->state.elf64.ehdr->e_phoff);
350 393
351 for (size_t cnt = 0; cnt < scncnt; ++cnt) 394 for (size_t cnt = 0; cnt < scncnt; ++cnt)
352 { 395 {
@@ -363,9 +406,21 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
363 } 406 }
364 else 407 else
365 { 408 {
366 /* Copy the ELF header. */ 409 if (likely (map_address != NULL))
367 elf->state.elf64.ehdr = memcpy (&elf->state.elf64.ehdr_mem, e_ident, 410 /* Copy the data. */
368 sizeof (Elf64_Ehdr)); 411 memcpy (&elf->state.elf64.ehdr_mem,
412 (char *) map_address + offset, sizeof (Elf64_Ehdr));
413 else
414 /* Read the data. */
415 if (TEMP_FAILURE_RETRY (pread (elf->fildes,
416 &elf->state.elf64.ehdr_mem,
417 sizeof (Elf64_Ehdr), offset))
418 != sizeof (Elf64_Ehdr))
419 {
420 /* We must be able to read the ELF header. */
421 __libelf_seterrno (ELF_E_INVALID_FILE);
422 return NULL;
423 }
369 424
370 if (e_ident[EI_DATA] != MY_ELFDATA) 425 if (e_ident[EI_DATA] != MY_ELFDATA)
371 { 426 {
@@ -384,6 +439,8 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
384 CONVERT (elf->state.elf64.ehdr_mem.e_shstrndx); 439 CONVERT (elf->state.elf64.ehdr_mem.e_shstrndx);
385 } 440 }
386 441
442 elf->state.elf64.ehdr = &elf->state.elf64.ehdr_mem;
443
387 for (size_t cnt = 0; cnt < scncnt; ++cnt) 444 for (size_t cnt = 0; cnt < scncnt; ++cnt)
388 { 445 {
389 elf->state.elf64.scns.data[cnt].index = cnt; 446 elf->state.elf64.scns.data[cnt].index = cnt;
@@ -396,6 +453,9 @@ file_read_elf (int fildes, void *map_address, unsigned char *e_ident,
396 elf->state.elf64.scns_last = &elf->state.elf64.scns; 453 elf->state.elf64.scns_last = &elf->state.elf64.scns;
397 } 454 }
398 455
456 /* Make the class easily available. */
457 elf->class = e_ident[EI_CLASS];
458
399 return elf; 459 return elf;
400} 460}
401 461
@@ -409,16 +469,15 @@ __libelf_read_mmaped_file (int fildes, void *map_address, off_t offset,
409 files and archives. To find out what we have we must look at the 469 files and archives. To find out what we have we must look at the
410 header. The header for an ELF file is EI_NIDENT bytes in size, 470 header. The header for an ELF file is EI_NIDENT bytes in size,
411 the header for an archive file SARMAG bytes long. */ 471 the header for an archive file SARMAG bytes long. */
412 unsigned char *e_ident = (unsigned char *) map_address + offset; 472 Elf_Kind kind;
413 473
414 /* See what kind of object we have here. */ 474 /* See what kind of object we have here. */
415 Elf_Kind kind = determine_kind (e_ident, maxsize); 475 kind = determine_kind (map_address + offset, maxsize);
416 476
417 switch (kind) 477 switch (kind)
418 { 478 {
419 case ELF_K_ELF: 479 case ELF_K_ELF:
420 return file_read_elf (fildes, map_address, e_ident, offset, maxsize, 480 return file_read_elf (fildes, map_address, offset, maxsize, cmd, parent);
421 cmd, parent);
422 481
423 case ELF_K_AR: 482 case ELF_K_AR:
424 return file_read_ar (fildes, map_address, offset, maxsize, cmd, parent); 483 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,
440{ 499{
441 /* We have to find out what kind of file this is. We handle ELF 500 /* We have to find out what kind of file this is. We handle ELF
442 files and archives. To find out what we have we must read the 501 files and archives. To find out what we have we must read the
443 header. The identification header for an ELF file is EI_NIDENT 502 header. The header for an ELF file is EI_NIDENT bytes in size,
444 bytes in size, but we read the whole ELF header since we will 503 the header for an archive file SARMAG bytes long. Read the
445 need it anyway later. For archives the header in SARMAG bytes 504 maximum of these numbers.
446 long. Read the maximum of these numbers.
447
448 XXX We have to change this for the extended `ar' format some day.
449 505
450 Use a union to ensure alignment. We might later access the 506 XXX We have to change this for the extended `ar' format some day. */
451 memory as a ElfXX_Ehdr. */ 507 unsigned char header[MAX (EI_NIDENT, SARMAG)];
452 union 508 ssize_t nread;
453 { 509 Elf_Kind kind;
454 Elf64_Ehdr ehdr;
455 unsigned char header[MAX (sizeof (Elf64_Ehdr), SARMAG)];
456 } mem;
457 510
458 /* Read the head of the file. */ 511 /* Read the head of the file. */
459 ssize_t nread = pread_retry (fildes, mem.header, 512 nread = pread (fildes, header, MIN (MAX (EI_NIDENT, SARMAG), maxsize),
460 MIN (MAX (sizeof (Elf64_Ehdr), SARMAG), 513 offset);
461 maxsize), 514 if (nread == -1)
462 offset);
463 if (unlikely (nread == -1))
464 /* We cannot even read the head of the file. Maybe FILDES is associated 515 /* We cannot even read the head of the file. Maybe FILDES is associated
465 with an unseekable device. This is nothing we can handle. */ 516 with an unseekable device. This is nothing we can handle. */
466 return NULL; 517 return NULL;
467 518
468 /* See what kind of object we have here. */ 519 /* See what kind of object we have here. */
469 Elf_Kind kind = determine_kind (mem.header, nread); 520 kind = determine_kind (header, nread);
470 521
471 switch (kind) 522 switch (kind)
472 { 523 {
@@ -475,10 +526,9 @@ read_unmmaped_file (int fildes, off_t offset, size_t maxsize, Elf_Cmd cmd,
475 526
476 case ELF_K_ELF: 527 case ELF_K_ELF:
477 /* Make sure at least the ELF header is contained in the file. */ 528 /* Make sure at least the ELF header is contained in the file. */
478 if ((size_t) nread >= (mem.header[EI_CLASS] == ELFCLASS32 529 if (maxsize >= (header[EI_CLASS] == ELFCLASS32
479 ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr))) 530 ? sizeof (Elf32_Ehdr) : sizeof (Elf64_Ehdr)))
480 return file_read_elf (fildes, NULL, mem.header, offset, maxsize, cmd, 531 return file_read_elf (fildes, NULL, offset, maxsize, cmd, parent);
481 parent);
482 /* FALLTHROUGH */ 532 /* FALLTHROUGH */
483 533
484 default: 534 default:
@@ -546,11 +596,10 @@ read_file (int fildes, off_t offset, size_t maxsize,
546 /* If we have the file in memory optimize the access. */ 596 /* If we have the file in memory optimize the access. */
547 if (map_address != NULL) 597 if (map_address != NULL)
548 { 598 {
549 assert (map_address != MAP_FAILED); 599 struct Elf *result;
550 600
551 struct Elf *result = __libelf_read_mmaped_file (fildes, map_address, 601 result = __libelf_read_mmaped_file (fildes, map_address, offset, maxsize,
552 offset, maxsize, cmd, 602 cmd, parent);
553 parent);
554 603
555 /* If something went wrong during the initialization unmap the 604 /* If something went wrong during the initialization unmap the
556 memory if we mmaped here. */ 605 memory if we mmaped here. */
@@ -594,9 +643,8 @@ read_long_names (Elf *elf)
594 else 643 else
595 { 644 {
596 /* Read the header from the file. */ 645 /* Read the header from the file. */
597 if (unlikely (pread_retry (elf->fildes, &hdrm, sizeof (hdrm), 646 if (pread (elf->fildes, &hdrm, sizeof (hdrm),
598 elf->start_offset + offset) 647 elf->start_offset + offset) != sizeof (hdrm))
599 != sizeof (hdrm)))
600 return NULL; 648 return NULL;
601 649
602 hdr = &hdrm; 650 hdr = &hdrm;
@@ -626,10 +674,10 @@ read_long_names (Elf *elf)
626 len); 674 len);
627 else 675 else
628 { 676 {
629 if (unlikely ((size_t) pread_retry (elf->fildes, newp, len, 677 if ((size_t) pread (elf->fildes, newp, len,
630 elf->start_offset + offset 678 elf->start_offset + offset
631 + sizeof (struct ar_hdr)) 679 + sizeof (struct ar_hdr))
632 != len)) 680 != len)
633 { 681 {
634 /* We were not able to read all data. */ 682 /* We were not able to read all data. */
635 free (newp); 683 free (newp);
@@ -679,8 +727,8 @@ __libelf_next_arhdr (elf)
679 if (elf->map_address != NULL) 727 if (elf->map_address != NULL)
680 { 728 {
681 /* See whether this entry is in the file. */ 729 /* See whether this entry is in the file. */
682 if (unlikely (elf->state.ar.offset + sizeof (struct ar_hdr) 730 if (elf->state.ar.offset + sizeof (struct ar_hdr)
683 > elf->start_offset + elf->maximum_size)) 731 > elf->start_offset + elf->maximum_size)
684 { 732 {
685 /* This record is not anymore in the file. */ 733 /* This record is not anymore in the file. */
686 __libelf_seterrno (ELF_E_RANGE); 734 __libelf_seterrno (ELF_E_RANGE);
@@ -692,9 +740,10 @@ __libelf_next_arhdr (elf)
692 { 740 {
693 ar_hdr = &elf->state.ar.ar_hdr; 741 ar_hdr = &elf->state.ar.ar_hdr;
694 742
695 if (unlikely (pread_retry (elf->fildes, ar_hdr, sizeof (struct ar_hdr), 743 if (TEMP_FAILURE_RETRY (pread (elf->fildes, ar_hdr,
696 elf->state.ar.offset) 744 sizeof (struct ar_hdr),
697 != sizeof (struct ar_hdr))) 745 elf->state.ar.offset))
746 != sizeof (struct ar_hdr))
698 { 747 {
699 /* Something went wrong while reading the file. */ 748 /* Something went wrong while reading the file. */
700 __libelf_seterrno (ELF_E_RANGE); 749 __libelf_seterrno (ELF_E_RANGE);
@@ -703,7 +752,7 @@ __libelf_next_arhdr (elf)
703 } 752 }
704 753
705 /* One little consistency check. */ 754 /* One little consistency check. */
706 if (unlikely (memcmp (ar_hdr->ar_fmag, ARFMAG, 2) != 0)) 755 if (memcmp (ar_hdr->ar_fmag, ARFMAG, 2) != 0)
707 { 756 {
708 /* This is no valid archive. */ 757 /* This is no valid archive. */
709 __libelf_seterrno (ELF_E_ARCHIVE_FMAG); 758 __libelf_seterrno (ELF_E_ARCHIVE_FMAG);
@@ -727,14 +776,14 @@ __libelf_next_arhdr (elf)
727 && memcmp (ar_hdr->ar_name, "// ", 16) == 0) 776 && memcmp (ar_hdr->ar_name, "// ", 16) == 0)
728 /* This is the array with the long names. */ 777 /* This is the array with the long names. */
729 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "//", 3); 778 elf_ar_hdr->ar_name = memcpy (elf->state.ar.ar_name, "//", 3);
730 else if (likely (isdigit (ar_hdr->ar_name[1]))) 779 else if (isdigit (ar_hdr->ar_name[1]))
731 { 780 {
732 size_t offset; 781 size_t offset;
733 782
734 /* This is a long name. First we have to read the long name 783 /* This is a long name. First we have to read the long name
735 table, if this hasn't happened already. */ 784 table, if this hasn't happened already. */
736 if (unlikely (elf->state.ar.long_names == NULL 785 if (elf->state.ar.long_names == NULL
737 && read_long_names (elf) == NULL)) 786 && read_long_names (elf) == NULL)
738 { 787 {
739 /* No long name table although it is reference. The archive is 788 /* No long name table although it is reference. The archive is
740 broken. */ 789 broken. */
@@ -743,7 +792,7 @@ __libelf_next_arhdr (elf)
743 } 792 }
744 793
745 offset = atol (ar_hdr->ar_name + 1); 794 offset = atol (ar_hdr->ar_name + 1);
746 if (unlikely (offset >= elf->state.ar.long_names_len)) 795 if (offset >= elf->state.ar.long_names_len)
747 { 796 {
748 /* The index in the long name table is larger than the table. */ 797 /* The index in the long name table is larger than the table. */
749 __libelf_seterrno (ELF_E_INVALID_ARCHIVE); 798 __libelf_seterrno (ELF_E_INVALID_ARCHIVE);
@@ -857,7 +906,7 @@ __libelf_next_arhdr (elf)
857 906
858 if (ar_hdr->ar_size[sizeof (ar_hdr->ar_size) - 1] == ' ') 907 if (ar_hdr->ar_size[sizeof (ar_hdr->ar_size) - 1] == ' ')
859 { 908 {
860 if (unlikely (ar_hdr->ar_size[0] == ' ')) 909 if (ar_hdr->ar_size[0] == ' ')
861 /* Something is really wrong. We cannot live without a size for 910 /* Something is really wrong. We cannot live without a size for
862 the member since it will not be possible to find the next 911 the member since it will not be possible to find the next
863 archive member. */ 912 archive member. */
@@ -897,7 +946,7 @@ dup_elf (int fildes, Elf_Cmd cmd, Elf *ref)
897 fildes = ref->fildes; 946 fildes = ref->fildes;
898 /* The file descriptor better should be the same. If it was disconnected 947 /* The file descriptor better should be the same. If it was disconnected
899 already (using `elf_cntl') we do not test it. */ 948 already (using `elf_cntl') we do not test it. */
900 else if (unlikely (ref->fildes != -1 && fildes != ref->fildes)) 949 else if (ref->fildes != -1 && fildes != ref->fildes)
901 { 950 {
902 __libelf_seterrno (ELF_E_FD_MISMATCH); 951 __libelf_seterrno (ELF_E_FD_MISMATCH);
903 return NULL; 952 return NULL;
@@ -906,10 +955,10 @@ dup_elf (int fildes, Elf_Cmd cmd, Elf *ref)
906 /* The mode must allow reading. I.e., a descriptor creating with a 955 /* The mode must allow reading. I.e., a descriptor creating with a
907 command different then ELF_C_READ, ELF_C_WRITE and ELF_C_RDWR is 956 command different then ELF_C_READ, ELF_C_WRITE and ELF_C_RDWR is
908 not allowed. */ 957 not allowed. */
909 if (unlikely (ref->cmd != ELF_C_READ && ref->cmd != ELF_C_READ_MMAP 958 if (ref->cmd != ELF_C_READ && ref->cmd != ELF_C_READ_MMAP
910 && ref->cmd != ELF_C_WRITE && ref->cmd != ELF_C_WRITE_MMAP 959 && ref->cmd != ELF_C_WRITE && ref->cmd != ELF_C_WRITE_MMAP
911 && ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP 960 && ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP
912 && ref->cmd != ELF_C_READ_MMAP_PRIVATE)) 961 && ref->cmd != ELF_C_READ_MMAP_PRIVATE)
913 { 962 {
914 __libelf_seterrno (ELF_E_INVALID_OP); 963 __libelf_seterrno (ELF_E_INVALID_OP);
915 return NULL; 964 return NULL;
@@ -986,7 +1035,7 @@ elf_begin (fildes, cmd, ref)
986{ 1035{
987 Elf *retval; 1036 Elf *retval;
988 1037
989 if (unlikely (! __libelf_version_initialized)) 1038 if (! __libelf_version_initialized)
990 { 1039 {
991 /* Version wasn't set so far. */ 1040 /* Version wasn't set so far. */
992 __libelf_seterrno (ELF_E_NO_VERSION); 1041 __libelf_seterrno (ELF_E_NO_VERSION);
@@ -996,7 +1045,7 @@ elf_begin (fildes, cmd, ref)
996 if (ref != NULL) 1045 if (ref != NULL)
997 /* Make sure the descriptor is not suddenly going away. */ 1046 /* Make sure the descriptor is not suddenly going away. */
998 rwlock_rdlock (ref->lock); 1047 rwlock_rdlock (ref->lock);
999 else if (unlikely (fcntl (fildes, F_GETFL) == -1 && errno == EBADF)) 1048 else if (fcntl (fildes, F_GETFL) == -1 && errno == EBADF)
1000 { 1049 {
1001 /* We cannot do anything productive without a file descriptor. */ 1050 /* We cannot do anything productive without a file descriptor. */
1002 __libelf_seterrno (ELF_E_INVALID_FILE); 1051 __libelf_seterrno (ELF_E_INVALID_FILE);
@@ -1012,7 +1061,7 @@ elf_begin (fildes, cmd, ref)
1012 1061
1013 case ELF_C_READ_MMAP_PRIVATE: 1062 case ELF_C_READ_MMAP_PRIVATE:
1014 /* If we have a reference it must also be opened this way. */ 1063 /* If we have a reference it must also be opened this way. */
1015 if (unlikely (ref != NULL && ref->cmd != ELF_C_READ_MMAP_PRIVATE)) 1064 if (ref != NULL && ref->cmd != ELF_C_READ_MMAP_PRIVATE)
1016 { 1065 {
1017 __libelf_seterrno (ELF_E_INVALID_CMD); 1066 __libelf_seterrno (ELF_E_INVALID_CMD);
1018 retval = NULL; 1067 retval = NULL;
@@ -1036,9 +1085,8 @@ elf_begin (fildes, cmd, ref)
1036 command. */ 1085 command. */
1037 if (ref != NULL) 1086 if (ref != NULL)
1038 { 1087 {
1039 if (unlikely (ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP 1088 if (ref->cmd != ELF_C_RDWR && ref->cmd != ELF_C_RDWR_MMAP
1040 && ref->cmd != ELF_C_WRITE 1089 && ref->cmd != ELF_C_WRITE && ref->cmd != ELF_C_WRITE_MMAP)
1041 && ref->cmd != ELF_C_WRITE_MMAP))
1042 { 1090 {
1043 /* This is not ok. REF must also be opened for writing. */ 1091 /* This is not ok. REF must also be opened for writing. */
1044 __libelf_seterrno (ELF_E_INVALID_CMD); 1092 __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 @@
28#include <string.h> 28#include <string.h>
29#include <unistd.h> 29#include <unistd.h>
30 30
31#include <system.h>
32#include <dl-hash.h> 31#include <dl-hash.h>
33#include "libelfP.h" 32#include "libelfP.h"
34 33
35 34
35#define pread_retry(fd, buf, len, off) \
36 TEMP_FAILURE_RETRY (pread (fd, buf, len, off))
37
38
36Elf_Arsym * 39Elf_Arsym *
37elf_getarsym (elf, ptr) 40elf_getarsym (elf, ptr)
38 Elf *elf; 41 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 @@
19# include <config.h> 19# include <config.h>
20#endif 20#endif
21 21
22#include <errno.h>
23#include <stddef.h> 22#include <stddef.h>
24#include <string.h> 23#include <string.h>
25#include <unistd.h> 24#include <unistd.h>
26 25
27#include "libelfP.h" 26#include "libelfP.h"
28#include <system.h>
29#include "common.h" 27#include "common.h"
30#include "elf-knowledge.h" 28#include "elf-knowledge.h"
31 29
@@ -241,7 +239,7 @@ __libelf_set_rawdata (Elf_Scn *scn)
241 if (entsize == 0) 239 if (entsize == 0)
242 entsize = 1; 240 entsize = 1;
243 241
244 if (unlikely (size % entsize != 0)) 242 if (size % entsize != 0)
245 { 243 {
246 __libelf_seterrno (ELF_E_INVALID_DATA); 244 __libelf_seterrno (ELF_E_INVALID_DATA);
247 return 1; 245 return 1;
@@ -252,7 +250,7 @@ __libelf_set_rawdata (Elf_Scn *scn)
252 { 250 {
253 /* First see whether the information in the section header is 251 /* First see whether the information in the section header is
254 valid and it does not ask for too much. */ 252 valid and it does not ask for too much. */
255 if (unlikely (offset + size > elf->maximum_size)) 253 if (offset + size > elf->maximum_size)
256 { 254 {
257 /* Something is wrong. */ 255 /* Something is wrong. */
258 __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER); 256 __libelf_seterrno (ELF_E_INVALID_SECTION_HEADER);
@@ -262,7 +260,7 @@ __libelf_set_rawdata (Elf_Scn *scn)
262 scn->rawdata_base = scn->rawdata.d.d_buf 260 scn->rawdata_base = scn->rawdata.d.d_buf
263 = (char *) elf->map_address + elf->start_offset + offset; 261 = (char *) elf->map_address + elf->start_offset + offset;
264 } 262 }
265 else if (likely (elf->fildes != -1)) 263 else if (elf->fildes != -1)
266 { 264 {
267 /* We have to read the data from the file. Allocate the needed 265 /* We have to read the data from the file. Allocate the needed
268 memory. */ 266 memory. */
@@ -274,9 +272,8 @@ __libelf_set_rawdata (Elf_Scn *scn)
274 return 1; 272 return 1;
275 } 273 }
276 274
277 ssize_t n = pread_retry (elf->fildes, scn->rawdata.d.d_buf, size, 275 if ((size_t) pread (elf->fildes, scn->rawdata.d.d_buf, size,
278 elf->start_offset + offset); 276 elf->start_offset + offset) != size)
279 if (unlikely ((size_t) n != size))
280 { 277 {
281 /* Cannot read the data. */ 278 /* Cannot read the data. */
282 free (scn->rawdata.d.d_buf); 279 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 @@
1/* Return section index of section header string table. 1/* Return section index of section header string table.
2 Copyright (C) 2002, 2005 Red Hat, Inc. 2 Copyright (C) 2002 Red Hat, Inc.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2002. 3 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -20,12 +20,10 @@
20#endif 20#endif
21 21
22#include <assert.h> 22#include <assert.h>
23#include <errno.h>
24#include <gelf.h> 23#include <gelf.h>
25#include <stddef.h> 24#include <stddef.h>
26#include <unistd.h> 25#include <unistd.h>
27 26
28#include <system.h>
29#include "libelfP.h" 27#include "libelfP.h"
30#include "common.h" 28#include "common.h"
31 29
@@ -102,9 +100,8 @@ elf_getshstrndx (elf, dst)
102 the first one. */ 100 the first one. */
103 Elf32_Shdr shdr_mem; 101 Elf32_Shdr shdr_mem;
104 102
105 if (unlikely (pread_retry (elf->fildes, &shdr_mem, 103 if (pread (elf->fildes, &shdr_mem, sizeof (Elf32_Shdr),
106 sizeof (Elf32_Shdr), offset) 104 offset) != sizeof (Elf32_Shdr))
107 != sizeof (Elf32_Shdr)))
108 { 105 {
109 /* We must be able to read this ELF section header. */ 106 /* We must be able to read this ELF section header. */
110 __libelf_seterrno (ELF_E_INVALID_FILE); 107 __libelf_seterrno (ELF_E_INVALID_FILE);
@@ -119,13 +116,15 @@ elf_getshstrndx (elf, dst)
119 } 116 }
120 else 117 else
121 { 118 {
119 size_t offset;
120
122 if (elf->state.elf64.scns.data[0].shdr.e64 != NULL) 121 if (elf->state.elf64.scns.data[0].shdr.e64 != NULL)
123 { 122 {
124 num = elf->state.elf64.scns.data[0].shdr.e64->sh_link; 123 num = elf->state.elf64.scns.data[0].shdr.e64->sh_link;
125 goto success; 124 goto success;
126 } 125 }
127 126
128 size_t offset = elf->state.elf64.ehdr->e_shoff; 127 offset = elf->state.elf64.ehdr->e_shoff;
129 128
130 if (elf->map_address != NULL 129 if (elf->map_address != NULL
131 && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA 130 && elf->state.elf64.ehdr->e_ident[EI_DATA] == MY_ELFDATA
@@ -140,9 +139,8 @@ elf_getshstrndx (elf, dst)
140 the first one. */ 139 the first one. */
141 Elf64_Shdr shdr_mem; 140 Elf64_Shdr shdr_mem;
142 141
143 if (unlikely (pread_retry (elf->fildes, &shdr_mem, 142 if (pread (elf->fildes, &shdr_mem, sizeof (Elf64_Shdr),
144 sizeof (Elf64_Shdr), offset) 143 offset) != sizeof (Elf64_Shdr))
145 != sizeof (Elf64_Shdr)))
146 { 144 {
147 /* We must be able to read this ELF section header. */ 145 /* We must be able to read this ELF section header. */
148 __libelf_seterrno (ELF_E_INVALID_FILE); 146 __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 @@
1/* Read all of the file associated with the descriptor. 1/* Read all of the file associated with the descriptor.
2 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2005 Red Hat, Inc. 2 Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 1998. 3 Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -19,10 +19,8 @@
19# include <config.h> 19# include <config.h>
20#endif 20#endif
21 21
22#include <errno.h>
23#include <unistd.h> 22#include <unistd.h>
24 23
25#include <system.h>
26#include "libelfP.h" 24#include "libelfP.h"
27#include "common.h" 25#include "common.h"
28 26
@@ -80,10 +78,8 @@ __libelf_readall (elf)
80 if (mem != NULL) 78 if (mem != NULL)
81 { 79 {
82 /* Read the file content. */ 80 /* Read the file content. */
83 if (unlikely ((size_t) pread_retry (elf->fildes, mem, 81 if ((size_t) pread (elf->fildes, mem, elf->maximum_size,
84 elf->maximum_size, 82 elf->start_offset) != elf->maximum_size)
85 elf->start_offset)
86 != elf->maximum_size))
87 { 83 {
88 /* Something went wrong. */ 84 /* Something went wrong. */
89 __libelf_seterrno (ELF_E_READ_ERROR); 85 __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 @@
1/* Retrieve uninterpreted chunk of the file contents. 1/* Retrieve uninterpreted chunk of the file contents.
2 Copyright (C) 2002, 2005 Red Hat, Inc. 2 Copyright (C) 2002 Red Hat, Inc.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. 3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -19,13 +19,11 @@
19# include <config.h> 19# include <config.h>
20#endif 20#endif
21 21
22#include <errno.h>
23#include <libelf.h> 22#include <libelf.h>
24#include <stddef.h> 23#include <stddef.h>
25#include <stdlib.h> 24#include <stdlib.h>
26#include <unistd.h> 25#include <unistd.h>
27 26
28#include <system.h>
29#include "libelfP.h" 27#include "libelfP.h"
30 28
31 29
@@ -42,9 +40,9 @@ gelf_rawchunk (elf, offset, size)
42 return NULL; 40 return NULL;
43 } 41 }
44 42
45 if (unlikely (offset >= elf->maximum_size 43 if (offset >= elf->maximum_size
46 || offset + size >= elf->maximum_size 44 || offset + size >= elf->maximum_size
47 || offset + size < offset)) 45 || offset + size < offset)
48 { 46 {
49 /* Invalid request. */ 47 /* Invalid request. */
50 __libelf_seterrno (ELF_E_INVALID_OP); 48 __libelf_seterrno (ELF_E_INVALID_OP);
@@ -61,9 +59,8 @@ gelf_rawchunk (elf, offset, size)
61 __libelf_seterrno (ELF_E_NOMEM); 59 __libelf_seterrno (ELF_E_NOMEM);
62 else 60 else
63 /* Read the file content. */ 61 /* Read the file content. */
64 if (unlikely ((size_t) pread_retry (elf->fildes, result, size, 62 if ((size_t) pread (elf->fildes, result, size, elf->start_offset + offset)
65 elf->start_offset + offset) 63 != size)
66 != size))
67 { 64 {
68 /* Something went wrong. */ 65 /* Something went wrong. */
69 __libelf_seterrno (ELF_E_READ_ERROR); 66 __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 @@
12005-08-27 Ulrich Drepper <drepper@redhat.com>
2
3 * POTFILES.in: Add src/strings.c.
4
52005-08-15 Ulrich Drepper <drepper@redhat.com> 12005-08-15 Ulrich Drepper <drepper@redhat.com>
6 2
7 * POTFILES.in: Add src/ranlib.c. 3 * POTFILES.in: Add src/ranlib.
8 4
92005-08-05 Ulrich Drepper <drepper@redhat.com> 52005-08-05 Ulrich Drepper <drepper@redhat.com>
10 6
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
23src/findtextrel.c 23src/findtextrel.c
24src/elfcmp.c 24src/elfcmp.c
25src/ranlib.c 25src/ranlib.c
26src/strings.c
diff --git a/src/ChangeLog b/src/ChangeLog
index 5ae77c42..7707ac17 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,18 +1,3 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com>
2
3 * ranlib.c: Don't define pread_retry and write_retry here.
4
5 * Makefile.an [BUILD_STATIC] (libdw): Add -ldl.
6 (CLEANFILES): Add *.gcno *.gcda *.gconv.
7
8 * strings.c (process_chunk): Reorder expressions in conditional
9 (process_chunk_mb): Likewise.
10
11 * strings.c: New file.
12 * Makefile.am (bin_PROGRAMS): Add strings.
13 (strings_no_Wstring): Define.
14 (strings_LDADD): Define.
15
162005-08-24 Ulrich Drepper <drepper@redhat.com> 12005-08-24 Ulrich Drepper <drepper@redhat.com>
17 2
18 * elflint.c (check_versym): Versioned symbols should not have 3 * 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@
38base_cpu = @base_cpu@ 38base_cpu = @base_cpu@
39 39
40bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \ 40bin_PROGRAMS = readelf nm size strip ld elflint findtextrel addr2line \
41 elfcmp objdump ranlib strings 41 elfcmp objdump ranlib
42 42
43 43
44ld_dsos = libld_elf_i386_pic.a 44ld_dsos = libld_elf_i386_pic.a
@@ -67,7 +67,7 @@ libmudflap = -lmudflap
67endif 67endif
68 68
69if BUILD_STATIC 69if BUILD_STATIC
70libdw = ../libdw/libdw.a $(libelf) $(libebl) -ldl 70libdw = ../libdw/libdw.a $(libelf) $(libebl)
71libelf = ../libelf/libelf.a 71libelf = ../libelf/libelf.a
72else 72else
73libdw = ../libdw/libdw.so 73libdw = ../libdw/libdw.so
@@ -78,7 +78,6 @@ libeu = ../lib/libeu.a
78 78
79nm_no_Wformat = yes 79nm_no_Wformat = yes
80size_no_Wformat = yes 80size_no_Wformat = yes
81strings_no_Wformat = yes
82# XXX While the file is not finished, don't warn about this 81# XXX While the file is not finished, don't warn about this
83ldgeneric_no_Wunused = yes 82ldgeneric_no_Wunused = yes
84 83
@@ -97,7 +96,6 @@ addr2line_LDADD = $(libdw) $(libmudflap)
97elfcmp_LDADD = $(libebl) $(libelf) $(libmudflap) -ldl 96elfcmp_LDADD = $(libebl) $(libelf) $(libmudflap) -ldl
98objdump_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl 97objdump_LDADD = $(libebl) $(libelf) $(libeu) $(libmudflap) -ldl
99ranlib_LDADD = $(libelf) $(libeu) $(libmudflap) 98ranlib_LDADD = $(libelf) $(libeu) $(libmudflap)
100strings_LDADD = $(libelf) $(libeu) $(libmudflap)
101 99
102ldlex.o: ldscript.c 100ldlex.o: ldscript.c
103ldlex_no_Werror = yes 101ldlex_no_Werror = yes
@@ -148,4 +146,4 @@ installcheck-binPROGRAMS: $(bin_PROGRAMS)
148 done; \ 146 done; \
149 done; rm -f c$${pid}_.???; exit $$bad 147 done; rm -f c$${pid}_.???; exit $$bad
150 148
151CLEANFILES = none_ld.os $(ld_modules:.c=.os) *.gcno *.gcda *.gconv 149CLEANFILES = 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 @@
40#include <system.h> 40#include <system.h>
41 41
42 42
43#define pread_retry(fd, buf, n, off) \
44 TEMP_FAILURE_RETRY (pread (fd, buf, n, off))
45#define write_retry(fd, buf, n) \
46 TEMP_FAILURE_RETRY (write (fd, buf, n))
47
43#if __BYTE_ORDER == __LITTLE_ENDIAN 48#if __BYTE_ORDER == __LITTLE_ENDIAN
44# define le_bswap_32(val) bswap_32 (val) 49# define le_bswap_32(val) bswap_32 (val)
45#else 50#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 @@
1/* Print the strings of printable characters in files.
2 Copyright (C) 2005 Red Hat, Inc.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2005.
4
5 This program is Open Source software; you can redistribute it and/or
6 modify it under the terms of the Open Software License version 1.0 as
7 published by the Open Source Initiative.
8
9 You should have received a copy of the Open Software License along
10 with this program; if not, you may obtain a copy of the Open Software
11 License version 1.0 from http://www.opensource.org/licenses/osl.php or
12 by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13 3001 King Ranch Road, Ukiah, CA 95482. */
14
15#ifdef HAVE_CONFIG_H
16# include <config.h>
17#endif
18
19#include <argp.h>
20#include <assert.h>
21#include <ctype.h>
22#include <endian.h>
23#include <errno.h>
24#include <error.h>
25#include <fcntl.h>
26#include <gelf.h>
27#include <inttypes.h>
28#include <libintl.h>
29#include <locale.h>
30#include <stdbool.h>
31#include <stdio.h>
32#include <stdio_ext.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36#include <sys/mman.h>
37#include <sys/param.h>
38#include <sys/stat.h>
39
40#include <system.h>
41
42
43/* Prototypes of local functions. */
44static int read_fd (int fd, const char *fname, off64_t fdlen);
45static int read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen);
46
47
48/* Name and version of program. */
49static void print_version (FILE *stream, struct argp_state *state);
50void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
51
52/* Bug report address. */
53const char *argp_program_bug_address = PACKAGE_BUGREPORT;
54
55/* Definitions of arguments for argp functions. */
56static const struct argp_option options[] =
57{
58 { NULL, 0, NULL, 0, N_("Output Selection:"), 0 },
59 { "all", 'a', NULL, 0, N_("Scan entire file, not only loaded sections"), 0 },
60 { "bytes", 'n', "MIN-LEN", 0,
61 N_("Only NUL-terminated sequences of MIN-LEN characters or more are printed"), 0 },
62 { "encoding", 'e', "SELECTOR", 0, N_("\
63Select character size and endianess: s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit"),
64 0},
65 { "print-file-name", 'f', NULL, 0,
66 N_("Print name of the file before each string."), 0 },
67 { "radix", 't', "{o,d,x}", 0,
68 N_("Print location of the string in base 8, 10, or 16 respectively."), 0 },
69 { NULL, 'o', NULL, 0, N_("Alias for --radix=o"), 0 },
70
71 { NULL, 0, NULL, 0, N_("Miscellaneous:"), 0 },
72 { NULL, 0, NULL, 0, NULL, 0 }
73};
74
75/* Short description of program. */
76static const char doc[] = N_("\
77Print the strings of printable characters in files.");
78
79/* Strings for arguments in help texts. */
80static const char args_doc[] = N_("[FILE...]");
81
82/* Prototype for option handler. */
83static error_t parse_opt (int key, char *arg, struct argp_state *state);
84
85/* Data structure to communicate with argp functions. */
86static struct argp argp =
87{
88 options, parse_opt, args_doc, doc, NULL, NULL, NULL
89};
90
91
92/* Global variables. */
93
94/* True if whole file and not only loaded sections are looked at. */
95static bool entire_file;
96
97/* Minimum length of any sequence reported. */
98static size_t min_len = 4;
99
100/* Number of bytes per character. */
101static size_t bytes_per_char = 1;
102
103/* Minimum length of any sequence reported in bytes. */
104static size_t min_len_bytes;
105
106/* True if multibyte characters are in big-endian order. */
107static bool big_endian;
108
109/* True unless 7-bit ASCII are expected. */
110static bool char_7bit;
111
112/* True if file names should be printed before strings. */
113static bool print_file_name;
114
115/* Location print format string. */
116static const char *locfmt;
117
118/* Page size in use. */
119static size_t ps;
120
121
122/* Mapped parts of the ELF file. */
123static unsigned char *elfmap;
124static unsigned char *elfmap_base;
125static size_t elfmap_size;
126static off64_t elfmap_off;
127
128
129int
130main (int argc, char *argv[])
131{
132 /* We use no threads. */
133 __fsetlocking (stdin, FSETLOCKING_BYCALLER);
134 __fsetlocking (stdout, FSETLOCKING_BYCALLER);
135
136 /* Set locale. */
137 (void) setlocale (LC_ALL, "");
138
139 /* Make sure the message catalog can be found. */
140 (void) bindtextdomain (PACKAGE, LOCALEDIR);
141
142 /* Initialize the message catalog. */
143 (void) textdomain (PACKAGE);
144
145 /* Parse and process arguments. */
146 int remaining;
147 (void) argp_parse (&argp, argc, argv, 0, &remaining, NULL);
148
149 /* Tell the library which version we are expecting. */
150 elf_version (EV_CURRENT);
151
152 /* Determine the page size. We will likely need it a couple of times. */
153 ps = sysconf (_SC_PAGESIZE);
154
155 struct stat64 st;
156 int result = 0;
157 if (remaining == argc)
158 /* We read from standard input. This we cannot do for a
159 structured file. */
160 result = read_fd (STDOUT_FILENO,
161 print_file_name ? "{standard input}" : NULL,
162 fstat64 (STDOUT_FILENO, &st) == 0
163 ? st.st_size : INT64_C (0x7fffffffffffffff));
164 else
165 do
166 {
167 int fd = (strcmp (argv[remaining], "-") == 0
168 ? STDIN_FILENO : open (argv[remaining], O_RDONLY));
169 if (unlikely (fd == -1))
170 {
171 error (0, errno, gettext ("cannot open '%s'"), argv[remaining]);
172 result = 1;
173 }
174 else
175 {
176 const char *fname = print_file_name ? argv[remaining] : NULL;
177 int fstat_fail = fstat64 (fd, &st);
178 off64_t fdlen = (fstat_fail
179 ? INT64_C (0x7fffffffffffffff) : st.st_size);
180 if (fdlen > (off64_t) min_len_bytes)
181 {
182 Elf *elf = NULL;
183 if (entire_file
184 || fstat_fail
185 || !S_ISREG (st.st_mode)
186 || (elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL
187 || elf_kind (elf) != ELF_K_ELF)
188 result |= read_fd (fd, fname, fdlen);
189 else
190 result |= read_elf (elf, fd, fname, fdlen);
191
192 /* This call will succeed even if ELF is NULL. */
193 elf_end (elf);
194 }
195
196 if (strcmp (argv[remaining], "-") != 0)
197 close (fd);
198 }
199
200 if (elfmap != NULL && elfmap != MAP_FAILED)
201 munmap (elfmap, elfmap_size);
202 }
203 while (++remaining < argc);
204
205 return result;
206}
207
208
209/* Print the version information. */
210static void
211print_version (FILE *stream, struct argp_state *state __attribute__ ((unused)))
212{
213 fprintf (stream, "strings (%s) %s\n", PACKAGE_NAME, VERSION);
214 fprintf (stream, gettext ("\
215Copyright (C) %s Red Hat, Inc.\n\
216This is free software; see the source for copying conditions. There is NO\n\
217warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
218"), "2005");
219 fprintf (stream, gettext ("Written by %s.\n"), "Ulrich Drepper");
220}
221
222
223/* Handle program arguments. */
224static error_t
225parse_opt (int key, char *arg,
226 struct argp_state *state __attribute__ ((unused)))
227{
228 switch (key)
229 {
230 case 'a':
231 entire_file = true;
232 break;
233
234 case 'e':
235 /* We expect a string of one character. */
236 switch (arg[1] != '\0' ? '\0' : arg[0])
237 {
238 case 's':
239 case 'S':
240 char_7bit = arg[0] == 's';
241 bytes_per_char = 1;
242 break;
243
244 case 'b':
245 case 'B':
246 big_endian = true;
247 /* FALLTHROUGH */
248
249 case 'l':
250 case 'L':
251 bytes_per_char = isupper (arg[0]) ? 4 : 2;
252 break;
253
254 default:
255 error (0, 0, gettext ("invalid value '%s' for %s parameter"),
256 arg, "-e");
257 argp_help (&argp, stderr, ARGP_HELP_SEE, "strings");
258 return ARGP_ERR_UNKNOWN;
259 }
260 break;
261
262 case 'f':
263 print_file_name = true;
264 break;
265
266 case 'n':
267 min_len = atoi (arg);
268 break;
269
270 case 'o':
271 goto octfmt;
272
273 case 't':
274 switch (arg[0])
275 {
276 case 'd':
277 locfmt = "%7" PRId64 " ";
278 break;
279
280 case 'o':
281 octfmt:
282 locfmt = "%7" PRIo64 " ";
283 break;
284
285 case 'x':
286 locfmt = "%7" PRIx64 " ";
287 break;
288
289 default:
290 error (0, 0, gettext ("invalid value '%s' for %s parameter"),
291 arg, "-t");
292 argp_help (&argp, stderr, ARGP_HELP_SEE, "strings");
293 return ARGP_ERR_UNKNOWN;
294 }
295 break;
296
297 case ARGP_KEY_FINI:
298 /* Compute the length in bytes of any match. */
299 if (min_len <= 0 || min_len > INT_MAX / bytes_per_char)
300 error (EXIT_FAILURE, 0,
301 gettext ("invalid minimum length of matched string size"));
302 min_len_bytes = min_len * bytes_per_char;
303 break;
304
305 default:
306 return ARGP_ERR_UNKNOWN;
307 }
308 return 0;
309}
310
311
312static void
313process_chunk_mb (const char *fname, const unsigned char *buf, off64_t to,
314 size_t len, char **unprinted)
315{
316 size_t curlen = *unprinted == NULL ? 0 : strlen (*unprinted);
317 const unsigned char *start = buf;
318 while (len >= bytes_per_char)
319 {
320 uint32_t ch;
321
322 if (bytes_per_char == 2)
323 {
324 if (big_endian)
325 ch = buf[0] << 8 | buf[1];
326 else
327 ch = buf[1] << 8 | buf[0];
328 }
329 else
330 {
331 if (big_endian)
332 ch = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
333 else
334 ch = buf[3] << 24 | buf[2] << 16 | buf[1] << 8 | buf[0];
335 }
336
337 if (ch <= 255 && (isprint (ch) || ch == '\t'))
338 {
339 ++buf;
340 ++curlen;
341 }
342 else
343 {
344 if (curlen >= min_len)
345 {
346 /* We found a match. */
347 if (unlikely (fname != NULL))
348 {
349 fputs_unlocked (fname, stdout);
350 fputs_unlocked (": ", stdout);
351 }
352
353 if (unlikely (locfmt != NULL))
354 printf (locfmt, (int64_t) to - len - (buf - start));
355
356 if (unlikely (*unprinted != NULL))
357 {
358 fputs_unlocked (*unprinted, stdout);
359 free (*unprinted);
360 *unprinted = NULL;
361 }
362
363 /* There is no sane way of printing the string. If we
364 assume the file data is encoded in UCS-2/UTF-16 or
365 UCS-4/UTF-32 respectively we could covert the string.
366 But there is no such guarantee. */
367 fwrite_unlocked (start, 1, buf - start, stdout);
368 putc_unlocked ('\n', stdout);
369 }
370
371 start = ++buf;
372 curlen = 0;
373
374 if (len <= min_len)
375 break;
376 }
377
378 --len;
379 }
380
381 if (curlen != 0)
382 *unprinted = xstrndup ((const char *) start, curlen);
383}
384
385
386static void
387process_chunk (const char *fname, const unsigned char *buf, off64_t to,
388 size_t len, char **unprinted)
389{
390 /* We are not going to slow the check down for the 2- and 4-byte
391 encodings. Handle them special. */
392 if (unlikely (bytes_per_char != 1))
393 {
394 process_chunk_mb (fname, buf, to, len, unprinted);
395 return;
396 }
397
398 size_t curlen = *unprinted == NULL ? 0 : strlen (*unprinted);
399 const unsigned char *start = buf;
400 while (len > 0)
401 {
402 if ((isprint (*buf) || *buf == '\t') && (! char_7bit || *buf <= 127))
403 {
404 ++buf;
405 ++curlen;
406 }
407 else
408 {
409 if (curlen >= min_len)
410 {
411 /* We found a match. */
412 if (unlikely (fname != NULL))
413 {
414 fputs_unlocked (fname, stdout);
415 fputs_unlocked (": ", stdout);
416 }
417
418 if (unlikely (locfmt != NULL))
419 printf (locfmt, (int64_t) to - len - (buf - start));
420
421 if (unlikely (*unprinted != NULL))
422 {
423 fputs_unlocked (*unprinted, stdout);
424 free (*unprinted);
425 *unprinted = NULL;
426 }
427 fwrite_unlocked (start, 1, buf - start, stdout);
428 putc_unlocked ('\n', stdout);
429 }
430
431 start = ++buf;
432 curlen = 0;
433
434 if (len <= min_len)
435 break;
436 }
437
438 --len;
439 }
440
441 if (curlen != 0)
442 *unprinted = xstrndup ((const char *) start, curlen);
443}
444
445
446/* Map a file in as large chunks as possible. */
447static void *
448map_file (int fd, off64_t start_off, off64_t fdlen, size_t *map_sizep)
449{
450 /* Maximum size we mmap. We use an #ifdef to avoid overflows on
451 32-bit machines. 64-bit machines these days do not have usable
452 address spaces larger than about 43 bits. Not that any file
453 should be that large. */
454#if SIZE_MAX > 0xffffffff
455 const size_t mmap_max = 0x4000000000lu;
456#else
457 const size_t mmap_max = 0x40000000lu;
458#endif
459
460 /* Try to mmap the file. */
461 size_t map_size = MIN ((off64_t) mmap_max, fdlen);
462 const size_t map_size_min = MAX (MAX (SIZE_MAX / 16, 2 * ps),
463 roundup (2 * min_len_bytes + 1, ps));
464 void *mem;
465 while (1)
466 {
467 /* We map the memory for reading only here. Since we will
468 always look at every byte of the file it makes sense to
469 use MAP_POPULATE. */
470 mem = mmap64 (NULL, map_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
471 fd, start_off);
472 if (mem != MAP_FAILED)
473 {
474 /* We will go through the mapping sequentially. */
475 (void) posix_madvise (mem, map_size, POSIX_MADV_SEQUENTIAL);
476 break;
477 }
478 if (errno != EINVAL && errno != ENOMEM)
479 /* This is an error other than the lack of address space. */
480 break;
481
482 /* Maybe the size of the mapping is too big. Try again. */
483 map_size /= 2;
484 if (map_size < map_size_min)
485 /* That size should have fit. */
486 break;
487 }
488
489 *map_sizep = map_size;
490 return mem;
491}
492
493
494/* Read the file without mapping. */
495static int
496read_block_no_mmap (int fd, const char *fname, off64_t from, off64_t fdlen)
497{
498 char *unprinted = NULL;
499#define CHUNKSIZE 65536
500 unsigned char *buf = xmalloc (CHUNKSIZE + min_len_bytes
501 + bytes_per_char - 1);
502 size_t ntrailer = 0;
503 int result = 0;
504 while (fdlen > 0)
505 {
506 ssize_t n = TEMP_FAILURE_RETRY (read (fd, buf + ntrailer,
507 MIN (fdlen, CHUNKSIZE)));
508 if (n == 0)
509 {
510 /* There are less than MIN_LEN+1 bytes left so there cannot be
511 another match. */
512 assert (unprinted == NULL || ntrailer == 0);
513 break;
514 }
515 if (unlikely (n < 0))
516 {
517 /* Something went wrong. */
518 result = 1;
519 break;
520 }
521
522 /* Account for the number of bytes read in this round. */
523 fdlen -= n;
524
525 /* Do not use the signed N value. Note that the addition cannot
526 overflow. */
527 size_t nb = (size_t) n + ntrailer;
528 if (nb >= min_len_bytes)
529 {
530 /* We only use complete charactesr. */
531 nb &= ~(bytes_per_char - 1);
532
533 process_chunk (fname, buf, from + nb, nb, &unprinted);
534
535 /* If the last bytes of the buffer (module the character
536 size) have been printed we are not copying them. */
537 size_t to_keep = unprinted != NULL ? 0 : min_len_bytes;
538
539 memmove (buf, buf + nb - to_keep, to_keep + nb);
540 ntrailer = to_keep + nb;
541 from += nb;
542 }
543 else
544 ntrailer = nb;
545 }
546
547 free (buf);
548
549 /* Don't print anything we collected so far. There is no
550 terminating NUL byte. */
551 free (unprinted);
552
553 return result;
554}
555
556
557static int
558read_block (int fd, const char *fname, off64_t fdlen, off64_t from, off64_t to)
559{
560 assert ((off64_t) min_len_bytes < fdlen);
561
562 if (elfmap == NULL)
563 {
564 /* We need a completely new mapping. */
565 elfmap_off = from & ~(ps - 1);
566 elfmap_base = elfmap = map_file (fd, elfmap_off, fdlen, &elfmap_size);
567
568 if (unlikely (elfmap == MAP_FAILED))
569 /* Let the kernel know we are going to read everything in sequence. */
570 (void) posix_fadvise (fd, 0, 0, POSIX_FADV_SEQUENTIAL);
571 }
572
573 if (unlikely (elfmap == MAP_FAILED))
574 {
575 /* Read from the file descriptor. For this we must position the
576 read pointer. */
577 // XXX Eventually add flag which avoids this if the position
578 // XXX is known to match.
579 if (lseek64 (fd, from, SEEK_SET) != from)
580 error (EXIT_FAILURE, errno, gettext ("lseek64 failed"));
581
582 return read_block_no_mmap (fd, fname, from, to - from);
583 }
584
585 if (to < (off64_t) elfmap_off || from > (off64_t) (elfmap_off + elfmap_size))
586 {
587 /* The existing mapping cannot fit at all. Map the new area.
588 We always map the full range of ELFMAP_SIZE bytes even if
589 this extend beyond the end of the file. The Linux kernel
590 handles this OK if the access pages are not touched. */
591 elfmap_off = from & ~(ps - 1);
592 if (mmap64 (elfmap, elfmap_size, PROT_READ,
593 MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, from)
594 == MAP_FAILED)
595 error (EXIT_FAILURE, errno, gettext ("re-mmap failed"));
596 elfmap_base = elfmap;
597 }
598
599 char *unprinted = NULL;
600
601 /* Use the existing mapping as much as possible. If necessary, map
602 new pages. */
603 if (from >= (off64_t) elfmap_off
604 && from < (off64_t) (elfmap_off + elfmap_size))
605 /* There are at least a few bytes in this mapping which we can
606 use. */
607 process_chunk (fname, elfmap_base + (from - elfmap_off),
608 MIN (to, (off64_t) (elfmap_off + elfmap_size)),
609 MIN (to, (off64_t) (elfmap_off + elfmap_size)) - from,
610 &unprinted);
611
612 if (to > (off64_t) (elfmap_off + elfmap_size))
613 {
614 unsigned char *remap_base = elfmap_base;
615 size_t read_now = elfmap_size - (elfmap_base - elfmap);
616
617 assert (from >= (off64_t) elfmap_off
618 && from < (off64_t) (elfmap_off + elfmap_size));
619 off64_t handled_to = elfmap_off + elfmap_size;
620 assert (elfmap == elfmap_base
621 || (elfmap_base - elfmap
622 == (ptrdiff_t) ((min_len_bytes + ps - 1) & ~(ps - 1))));
623 if (elfmap == elfmap_base)
624 {
625 size_t keep_area = (min_len_bytes + ps - 1) & ~(ps - 1);
626 assert (elfmap_size >= keep_area + ps);
627 /* The keep area is used for the content of the previous
628 buffer we have to keep. This means copying those bytes
629 and for this we have to make the data writable. */
630 if (unlikely (mprotect (elfmap, keep_area, PROT_READ | PROT_WRITE)
631 != 0))
632 error (EXIT_FAILURE, errno, gettext ("mprotect failed"));
633
634 elfmap_base = elfmap + keep_area;
635 }
636
637 while (1)
638 {
639 /* Map the rest of the file, eventually again in pieces.
640 We speed things up with a nice Linux feature. Note
641 that we have at least two pages mapped. */
642 size_t to_keep = unprinted != NULL ? 0 : min_len_bytes;
643
644 assert (read_now >= to_keep);
645 memmove (elfmap_base - to_keep,
646 remap_base + read_now - to_keep, to_keep);
647 remap_base = elfmap_base;
648
649 assert ((elfmap_size - (elfmap_base - elfmap)) % bytes_per_char
650 == 0);
651 read_now = MIN (to - handled_to,
652 (ptrdiff_t) elfmap_size - (elfmap_base - elfmap));
653
654 assert (handled_to % ps == 0);
655 assert (handled_to % bytes_per_char == 0);
656 if (mmap64 (remap_base, read_now, PROT_READ,
657 MAP_PRIVATE | MAP_POPULATE | MAP_FIXED, fd, handled_to)
658 == MAP_FAILED)
659 error (EXIT_FAILURE, errno, gettext ("re=mmap failed"));
660 elfmap_off = handled_to;
661
662 process_chunk (fname, remap_base - to_keep,
663 elfmap_off + (read_now & ~(bytes_per_char - 1)),
664 to_keep + (read_now & ~(bytes_per_char - 1)),
665 &unprinted);
666 handled_to += read_now;
667 if (handled_to >= to)
668 break;
669 }
670 }
671
672 /* Don't print anything we collected so far. There is no
673 terminating NUL byte. */
674 free (unprinted);
675
676 return 0;
677}
678
679
680static int
681read_fd (int fd, const char *fname, off64_t fdlen)
682{
683 return read_block (fd, fname, fdlen, 0, fdlen);
684}
685
686
687static int
688read_elf (Elf *elf, int fd, const char *fname, off64_t fdlen)
689{
690 assert (fdlen >= 0);
691
692 /* We will look at each section separately. The ELF file is not
693 mmapped. The libelf implementation will load the needed parts on
694 demand. Since we only interate over the section header table the
695 memory consumption at this stage is kept minimal. */
696 Elf_Scn *scn = elf_nextscn (elf, NULL);
697 if (scn == NULL)
698 return read_fd (fd, fname, fdlen);
699
700 int result = 0;
701 do
702 {
703 GElf_Shdr shdr_mem;
704 GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
705
706 /* Only look in sections which are loaded at runtime and
707 actually have content. */
708 if (shdr != NULL && shdr->sh_type != SHT_NOBITS
709 && (shdr->sh_flags & SHF_ALLOC) != 0)
710 result |= read_block (fd, fname, fdlen, shdr->sh_offset,
711 shdr->sh_offset + shdr->sh_size);
712 }
713 while ((scn = elf_nextscn (elf, scn)) != NULL);
714
715 if (elfmap != NULL && elfmap != MAP_FAILED)
716 munmap (elfmap, elfmap_size);
717 elfmap = NULL;
718
719 return result;
720}
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 81f8d1d6..bf58cb5a 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,12 +1,6 @@
12005-08-28 Ulrich Drepper <drepper@redhat.com> 12005-08-24 Roland McGrath <roland@redhat.com>
2 2
3 * Makefile.an [BUILD_STATIC] (libdw): Add -ldl. 3 * line2addr.c (print_address): Omit () for DSOs.
4 (CLEANFILES): Add *.gcno *.gcda *.gconv.
5
62005-08-28 Ulrich Drepper <drepper@redhat.com>
7
8 * run-strings-test.sh: New file.
9 * Makefile.am (TESTS, EXTRA_DIST): Add it.
10 4
112005-08-24 Ulrich Drepper <drepper@redhat.com> 52005-08-24 Ulrich Drepper <drepper@redhat.com>
12 6
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 \
47 run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \ 47 run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \
48 run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \ 48 run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \
49 run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ 49 run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
50 run-addrscopes.sh run-strings-test.sh 50 run-addrscopes.sh
51# run-show-ciefde.sh 51# run-show-ciefde.sh
52 52
53EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ 53EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
@@ -63,7 +63,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
63 run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \ 63 run-strip-test4.sh run-strip-test5.sh run-strip-test6.sh \
64 run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ 64 run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \
65 run-ranlib-test3.sh run-ranlib-test4.sh \ 65 run-ranlib-test3.sh run-ranlib-test4.sh \
66 run-addrscopes.sh run-strings-test.sh \ 66 run-addrscopes.sh \
67 testfile15.bz2 testfile15.debug.bz2 \ 67 testfile15.bz2 testfile15.debug.bz2 \
68 testfile16.bz2 testfile16.debug.bz2 \ 68 testfile16.bz2 testfile16.debug.bz2 \
69 testfile17.bz2 testfile17.debug.bz2 \ 69 testfile17.bz2 testfile17.debug.bz2 \
@@ -78,7 +78,7 @@ libmudflap = -lmudflap
78endif 78endif
79 79
80if BUILD_STATIC 80if BUILD_STATIC
81libdw = ../libdw/libdw.a $(libelf) $(libebl) -ldl 81libdw = ../libdw/libdw.a $(libelf) $(libebl)
82libelf = ../libelf/libelf.a 82libelf = ../libelf/libelf.a
83libasm = ../libasm/libasm.a 83libasm = ../libasm/libasm.a
84else 84else
@@ -126,4 +126,4 @@ asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
126asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl 126asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
127dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl 127dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
128 128
129CLEANFILES = xxx *.gcno *.gcda *gconv 129CLEANFILES = 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)
28 if (n > 1 || secname[0] != '\0') 28 if (n > 1 || secname[0] != '\0')
29 printf ("%s(%s)+%#" PRIx64, modname, secname, address); 29 printf ("%s(%s)+%#" PRIx64, modname, secname, address);
30 else 30 else
31 printf ("%s(%s)+%#" PRIx64, modname, secname, address); 31 printf ("%s+%#" PRIx64, modname, address);
32 return; 32 return;
33 } 33 }
34 } 34 }
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 @@
1#! /bin/sh
2# Copyright (C) 2005 Red Hat, Inc.
3# Written by Ulrich Drepper <drepper@redhat.com>, 2005.
4#
5# This program is Open Source software; you can redistribute it and/or
6# modify it under the terms of the Open Software License version 1.0 as
7# published by the Open Source Initiative.
8#
9# You should have received a copy of the Open Software License along
10# with this program; if not, you may obtain a copy of the Open Software
11# License version 1.0 from http://www.opensource.org/licenses/osl.php or
12# by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13# 3001 King Ranch Road, Ukiah, CA 95482.
14set -e
15
16# Don't fail if we cannot decompress the file.
17bunzip2 -c $srcdir/testfile.bz2 > testfile 2>/dev/null || exit 0
18
19# Don't fail if we cannot decompress the file.
20for n in $(seq 2 9); do
21bunzip2 -c $srcdir/testfile$n.bz2 > testfile$n 2>/dev/null || exit 0
22done
23
24LD_LIBRARY_PATH=../libelf${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
25 ../src/strings -tx -f testfile testfile[23456789] > strings.out
26
27diff -u strings.out - <<"EOF"
28testfile: f4 /lib/ld-linux.so.2
29testfile: 1c9 __gmon_start__
30testfile: 1d8 libc.so.6
31testfile: 1e2 __cxa_finalize
32testfile: 1f1 __deregister_frame_info
33testfile: 209 _IO_stdin_used
34testfile: 218 __libc_start_main
35testfile: 22a __register_frame_info
36testfile: 240 GLIBC_2.1.3
37testfile: 24c GLIBC_2.0
38testfile: 338 PTRh
39testfile: 345 QVh,
40testfile2: 114 /lib/ld.so.1
41testfile2: 1f1 __gmon_start__
42testfile2: 200 __deregister_frame_info
43testfile2: 218 __register_frame_info
44testfile2: 22e libc.so.6
45testfile2: 238 __cxa_finalize
46testfile2: 247 _IO_stdin_used
47testfile2: 256 __libc_start_main
48testfile2: 268 GLIBC_2.1.3
49testfile2: 274 GLIBC_2.0
50testfile2: 488 }a[xN
51testfile2: 4a8 }a[xN
52testfile2: 50c }a[xN
53testfile2: 540 }?Kx
54testfile3: f4 /lib/ld-linux.so.2
55testfile3: 1c9 __gmon_start__
56testfile3: 1d8 libc.so.6
57testfile3: 1e2 __cxa_finalize
58testfile3: 1f1 __deregister_frame_info
59testfile3: 209 _IO_stdin_used
60testfile3: 218 __libc_start_main
61testfile3: 22a __register_frame_info
62testfile3: 240 GLIBC_2.1.3
63testfile3: 24c GLIBC_2.0
64testfile3: 338 PTRh
65testfile3: 345 QVh,
66testfile4: f4 /lib/ld-linux.so.2
67testfile4: 8e1 __gmon_start__
68testfile4: 8f0 __terminate_func
69testfile4: 901 stderr
70testfile4: 908 __tf9type_info
71testfile4: 917 __tf16__user_type_info
72testfile4: 92e __tf19__pointer_type_info
73testfile4: 948 __tf16__attr_type_info
74testfile4: 95f __tf16__func_type_info
75testfile4: 976 __vt_9type_info
76testfile4: 986 __vt_19__pointer_type_info
77testfile4: 9a1 __vt_16__attr_type_info
78testfile4: 9b9 __vt_16__func_type_info
79testfile4: 9d1 __vt_16__ptmf_type_info
80testfile4: 9e9 __vt_16__ptmd_type_info
81testfile4: a01 __vt_17__array_type_info
82testfile4: a1a __tiv
83testfile4: a20 __vt_19__builtin_type_info
84testfile4: a3b __tix
85testfile4: a41 __til
86testfile4: a47 __tii
87testfile4: a4d __tis
88testfile4: a53 __tib
89testfile4: a59 __tic
90testfile4: a5f __tiw
91testfile4: a65 __tir
92testfile4: a6b __tid
93testfile4: a71 __tif
94testfile4: a77 __tiUi
95testfile4: a7e __tiUl
96testfile4: a85 __tiUx
97testfile4: a8c __tiUs
98testfile4: a93 __tiUc
99testfile4: a9a __tiSc
100testfile4: aa1 __ti19__pointer_type_info
101testfile4: abb __ti9type_info
102testfile4: aca __ti16__attr_type_info
103testfile4: ae1 __ti19__builtin_type_info
104testfile4: afb __ti16__func_type_info
105testfile4: b12 __ti16__ptmf_type_info
106testfile4: b29 __ti16__ptmd_type_info
107testfile4: b40 __ti17__array_type_info
108testfile4: b58 __cplus_type_matcher
109testfile4: b6d __vt_13bad_exception
110testfile4: b82 __vt_9exception
111testfile4: b92 _._13bad_exception
112testfile4: ba5 __vt_8bad_cast
113testfile4: bb4 _._8bad_cast
114testfile4: bc1 __vt_10bad_typeid
115testfile4: bd3 _._10bad_typeid
116testfile4: be3 __ti9exception
117testfile4: bf2 __ti13bad_exception
118testfile4: c06 __vt_16__user_type_info
119testfile4: c1e __vt_17__class_type_info
120testfile4: c37 __vt_14__si_type_info
121testfile4: c4d __ti8bad_cast
122testfile4: c5b __ti10bad_typeid
123testfile4: c6c __ti16__user_type_info
124testfile4: c83 __ti14__si_type_info
125testfile4: c98 __ti17__class_type_info
126testfile4: cb0 libc.so.6
127testfile4: cba __register_frame
128testfile4: ccb pthread_create
129testfile4: cda pthread_getspecific
130testfile4: cee pthread_key_delete
131testfile4: d01 __cxa_finalize
132testfile4: d10 malloc
133testfile4: d17 __frame_state_for
134testfile4: d29 abort
135testfile4: d2f __register_frame_table
136testfile4: d46 fprintf
137testfile4: d4e pthread_once
138testfile4: d5b __deregister_frame_info
139testfile4: d73 pthread_key_create
140testfile4: d86 memset
141testfile4: d8d strcmp
142testfile4: d94 pthread_mutex_unlock
143testfile4: da9 __deregister_frame
144testfile4: dbc pthread_mutex_lock
145testfile4: dcf _IO_stdin_used
146testfile4: dde __libc_start_main
147testfile4: df0 strlen
148testfile4: df7 __register_frame_info_table
149testfile4: e13 __register_frame_info
150testfile4: e29 pthread_setspecific
151testfile4: e3d free
152testfile4: e42 GLIBC_2.1.3
153testfile4: e4e GLIBC_2.0
154testfile4: 1308 PTRh<
155testfile4: 194b [^_]
156testfile4: 19bf [^_]
157testfile4: 1dd9 wT9L>
158testfile4: 1f3b [^_]
159testfile4: 1fae [^_]
160testfile4: 21c1 BZQRP
161testfile4: 237f [^_]
162testfile4: 2431 JWRV
163testfile4: 2454 [^_]
164testfile4: 2506 JWRV
165testfile4: 2529 [^_]
166testfile4: 2b6c [^_]
167testfile4: 2b9d ZYPV
168testfile4: 2c28 [^_]
169testfile4: 2c4d ZYPV
170testfile4: 2ce2 [^_]
171testfile4: 2dfb X^_]
172testfile4: 2fc8 [^_]
173testfile4: 307d tq;F
174testfile4: 315a [^_]
175testfile4: 31a5 :zt 1
176testfile4: 3238 [^_]
177testfile4: 32f8 AXY_VR
178testfile4: 334a [^_]
179testfile4: 37ab [^_]
180testfile4: 38b8 sU;E
181testfile4: 38f2 QRPV
182testfile4: 3926 [^_]
183testfile4: 3bfe QRWP
184testfile4: 3e65 [^_]
185testfile4: 4136 [^_]
186testfile4: 472d [^_]
187testfile4: 47a5 0[^_]
188testfile4: 48ab [^_]
189testfile4: 4ab1 _ZPV
190testfile4: 4b53 _ZPV
191testfile4: 4bd3 _ZPV
192testfile4: 4e05 PQWj
193testfile4: 4f75 [^_]
194testfile4: 4f9b u$;E u
195testfile4: 4feb [^_]
196testfile4: 5080 [^_]
197testfile4: 50a8 }$9u
198testfile4: 5149 [^_]
199testfile4: 51b0 [^_]
200testfile4: 539b [^_]
201testfile4: 53b5 E 9E
202testfile4: 540d x!)E
203testfile4: 5598 U$ B
204testfile4: 571c [^_]
205testfile4: 5819 [^_]
206testfile4: 5922 [^_]
207testfile4: 59c2 [^_]
208testfile4: 5a62 [^_]
209testfile4: 5b02 [^_]
210testfile4: 5ba2 [^_]
211testfile4: 5c42 [^_]
212testfile4: 5ce2 [^_]
213testfile4: 6112 [^_]
214testfile4: 62bb [^_]
215testfile4: 639b [^_]
216testfile4: 6436 [^_]
217testfile4: 6468 val is zero
218testfile4: 6480 Internal Compiler Bug: No runtime type matcher.
219testfile4: 64dc 19__pointer_type_info
220testfile4: 64f2 16__attr_type_info
221testfile4: 6505 19__builtin_type_info
222testfile4: 651b 16__func_type_info
223testfile4: 652e 16__ptmf_type_info
224testfile4: 6541 16__ptmd_type_info
225testfile4: 6554 17__array_type_info
226testfile4: 6568 9exception
227testfile4: 6573 13bad_exception
228testfile4: 6583 9type_info
229testfile4: 658e 8bad_cast
230testfile4: 6598 10bad_typeid
231testfile4: 65a5 16__user_type_info
232testfile4: 65b8 14__si_type_info
233testfile4: 65c9 17__class_type_info
234testfile4: 6fc1 H. $
235testfile5: f4 /lib/ld-linux.so.2
236testfile5: 1c9 __gmon_start__
237testfile5: 1d8 libc.so.6
238testfile5: 1e2 __cxa_finalize
239testfile5: 1f1 __deregister_frame_info
240testfile5: 209 _IO_stdin_used
241testfile5: 218 __libc_start_main
242testfile5: 22a __register_frame_info
243testfile5: 240 GLIBC_2.1.3
244testfile5: 24c GLIBC_2.0
245testfile5: 338 PTRh
246testfile5: 345 QVhD
247testfile6: 114 /lib/ld-linux.so.2
248testfile6: 3d9 libstdc++.so.5
249testfile6: 3e8 _ZTVSt16invalid_argument
250testfile6: 401 _ZNSaIcEC1Ev
251testfile6: 40e _ZTSSt16invalid_argument
252testfile6: 427 _ZTVN10__cxxabiv120__si_class_type_infoE
253testfile6: 450 _ZNSsD1Ev
254testfile6: 45a _ZdlPv
255testfile6: 461 __cxa_end_catch
256testfile6: 471 __gxx_personality_v0
257testfile6: 486 _ZTISt9exception
258testfile6: 497 _ZNSaIcED1Ev
259testfile6: 4a4 _ZTISt11logic_error
260testfile6: 4b8 _ZNSt16invalid_argumentD1Ev
261testfile6: 4d4 _ZTVN10__cxxabiv117__class_type_infoE
262testfile6: 4fa __cxa_throw
263testfile6: 506 _ZNSt16invalid_argumentC1ERKSs
264testfile6: 525 _ZNSsC1EPKcRKSaIcE
265testfile6: 538 _ZNSt11logic_errorD2Ev
266testfile6: 54f _ZTVN10__cxxabiv121__vmi_class_type_infoE
267testfile6: 579 _ZNSt16invalid_argumentD0Ev
268testfile6: 595 __cxa_begin_catch
269testfile6: 5a7 __cxa_allocate_exception
270testfile6: 5c0 _ZNKSt11logic_error4whatEv
271testfile6: 5db _Jv_RegisterClasses
272testfile6: 5ef _ZTISt16invalid_argument
273testfile6: 608 __gmon_start__
274testfile6: 617 libm.so.6
275testfile6: 621 _IO_stdin_used
276testfile6: 630 libgcc_s.so.1
277testfile6: 63e _Unwind_Resume
278testfile6: 64d libc.so.6
279testfile6: 657 __libc_start_main
280testfile6: 669 GCC_3.0
281testfile6: 671 GLIBC_2.0
282testfile6: 67b GLIBCPP_3.2
283testfile6: 687 CXXABI_1.2
284testfile6: 908 PTRh
285testfile6: e48 gdb.1
286testfile6: ec8 N10__gnu_test9gnu_obj_1E
287testfile6: ee1 N10__gnu_test9gnu_obj_2IiEE
288testfile6: efd N10__gnu_test9gnu_obj_2IlEE
289testfile6: f19 St16invalid_argument
290testfile7: 114 /lib/ld-linux.so.2
291testfile7: 3d9 libstdc++.so.5
292testfile7: 3e8 _ZTVSt16invalid_argument
293testfile7: 401 _ZNSaIcEC1Ev
294testfile7: 40e _ZTSSt16invalid_argument
295testfile7: 427 _ZTVN10__cxxabiv120__si_class_type_infoE
296testfile7: 450 _ZNSsD1Ev
297testfile7: 45a _ZdlPv
298testfile7: 461 __cxa_end_catch
299testfile7: 471 __gxx_personality_v0
300testfile7: 486 _ZTISt9exception
301testfile7: 497 _ZNSaIcED1Ev
302testfile7: 4a4 _ZTISt11logic_error
303testfile7: 4b8 _ZNSt16invalid_argumentD1Ev
304testfile7: 4d4 _ZTVN10__cxxabiv117__class_type_infoE
305testfile7: 4fa __cxa_throw
306testfile7: 506 _ZNSt16invalid_argumentC1ERKSs
307testfile7: 525 _ZNSsC1EPKcRKSaIcE
308testfile7: 538 _ZNSt11logic_errorD2Ev
309testfile7: 54f _ZTVN10__cxxabiv121__vmi_class_type_infoE
310testfile7: 579 _ZNSt16invalid_argumentD0Ev
311testfile7: 595 __cxa_begin_catch
312testfile7: 5a7 __cxa_allocate_exception
313testfile7: 5c0 _ZNKSt11logic_error4whatEv
314testfile7: 5db _Jv_RegisterClasses
315testfile7: 5ef _ZTISt16invalid_argument
316testfile7: 608 __gmon_start__
317testfile7: 617 libm.so.6
318testfile7: 621 _IO_stdin_used
319testfile7: 630 libgcc_s.so.1
320testfile7: 63e _Unwind_Resume
321testfile7: 64d libc.so.6
322testfile7: 657 __libc_start_main
323testfile7: 669 GCC_3.0
324testfile7: 671 GLIBC_2.0
325testfile7: 67b GLIBCPP_3.2
326testfile7: 687 CXXABI_1.2
327testfile7: 908 PTRh
328testfile7: e48 gdb.1
329testfile7: ec8 N10__gnu_test9gnu_obj_1E
330testfile7: ee1 N10__gnu_test9gnu_obj_2IiEE
331testfile7: efd N10__gnu_test9gnu_obj_2IlEE
332testfile7: f19 St16invalid_argument
333testfile8: 79 XZh;
334testfile8: 87 YXh<
335testfile8: 14f SQh[
336testfile8: 259 t5Wj
337testfile8: 502 WRVQ
338testfile8: 1fe7 ZYPj
339testfile8: 2115 u'Pj
340testfile8: 7bba FILE
341testfile8: 7bbf preserve-dates
342testfile8: 7bce remove-comment
343testfile8: 7bdd Remove .comment section
344testfile8: 7bf6 ${prefix}/share
345testfile8: 7c06 elfutils
346testfile8: 7c0f a.out
347testfile8: 7c15 0.58
348testfile8: 7c1a strip (Red Hat %s) %s
349testfile8: 7c31 2002
350testfile8: 7c36 Ulrich Drepper
351testfile8: 7c45 Written by %s.
352testfile8: 7c55 cannot stat input file "%s"
353testfile8: 7c71 %s: INTERNAL ERROR: %s
354testfile8: 7c88 while opening "%s"
355testfile8: 7c9b handle_elf
356testfile8: 7ca6 ../../src/strip.c
357testfile8: 7cb8 shdr_info[cnt].group_idx != 0
358testfile8: 7cd6 illformed file `%s'
359testfile8: 7cea elf_ndxscn (scn) == cnt
360testfile8: 7d02 .shstrtab
361testfile8: 7d0c while writing `%s': %s
362testfile8: 7d23 ((sym->st_info) & 0xf) == 3
363testfile8: 7d3f shndxdata != ((void *)0)
364testfile8: 7d58 scn != ((void *)0)
365testfile8: 7d6b .gnu_debuglink
366testfile8: 7d7a .comment
367testfile8: 7d83 cannot open `%s'
368testfile8: 7da0 Place stripped output into FILE
369testfile8: 7dc0 Extract the removed sections into FILE
370testfile8: 7e00 Copy modified/access timestamps to the output
371testfile8: 7e40 Only one input file allowed together with '-o' and '-f'
372testfile8: 7e80 Copyright (C) %s Red Hat, Inc.
373testfile8: 7e9f This is free software; see the source for copying conditions. There is NO
374testfile8: 7eea warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
375testfile8: 7f40 Report bugs to <drepper@redhat.com>.
376testfile8: 7f80 %s: File format not recognized
377testfile8: 7fa0 cannot set access and modification date of "%s"
378testfile8: 7fe0 cannot create new file `%s': %s
379testfile8: 8000 error while finishing `%s': %s
380testfile8: 8020 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0
381testfile8: 8060 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0
382testfile8: 80a0 %s: error while creating ELF header: %s
383testfile8: 80e0 %s: error while reading the file: %s
384testfile8: 8120 sec < 0xff00 || shndxdata != ((void *)0)
385testfile8: 8160 (versiondata->d_size / sizeof (GElf_Versym)) >= shdr_info[cnt].data->d_size / elsize
386testfile8: 81c0 shdr_info[cnt].shdr.sh_type == 11
387testfile8: 8200 (versiondata->d_size / sizeof (Elf32_Word)) >= shdr_info[cnt].data->d_size / elsize
388testfile8: 8260 shdr_info[cnt].shdr.sh_type == 18
389testfile8: 82a0 shdr_info[cnt].data != ((void *)0)
390testfile8: 82e0 elf_ndxscn (shdr_info[cnt].newscn) == idx
391testfile8: 8320 while create section header section: %s
392testfile8: 8360 cannot allocate section data: %s
393testfile8: 83a0 elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx
394testfile8: 83e0 while generating output file: %s
395testfile8: 8420 while preparing output for `%s'
396testfile8: 8440 shdr_info[cnt].shdr.sh_type == 2
397testfile8: 8480 shdr_info[idx].data != ((void *)0)
398testfile8: 84c0 cannot determine number of sections: %s
399testfile8: 8500 cannot get section header string table index
400testfile8: 85c0 Discard symbols from object files.
401testfile8: 85e3 [FILE...]
402testfile9: 79 XZh;
403testfile9: 87 YXh<
404testfile9: 14f SQh[
405testfile9: 259 t5Wj
406testfile9: 502 WRVQ
407testfile9: 1fe7 ZYPj
408testfile9: 2115 u'Pj
409testfile9: 3414 FILE
410testfile9: 3419 preserve-dates
411testfile9: 3428 remove-comment
412testfile9: 3437 Remove .comment section
413testfile9: 3450 ${prefix}/share
414testfile9: 3460 elfutils
415testfile9: 3469 a.out
416testfile9: 346f 0.58
417testfile9: 3474 strip (Red Hat %s) %s
418testfile9: 348b 2002
419testfile9: 3490 Ulrich Drepper
420testfile9: 349f Written by %s.
421testfile9: 34af cannot stat input file "%s"
422testfile9: 34cb %s: INTERNAL ERROR: %s
423testfile9: 34e2 while opening "%s"
424testfile9: 34f5 handle_elf
425testfile9: 3500 ../../src/strip.c
426testfile9: 3512 shdr_info[cnt].group_idx != 0
427testfile9: 3530 illformed file `%s'
428testfile9: 3544 elf_ndxscn (scn) == cnt
429testfile9: 355c .shstrtab
430testfile9: 3566 while writing `%s': %s
431testfile9: 357d ((sym->st_info) & 0xf) == 3
432testfile9: 3599 shndxdata != ((void *)0)
433testfile9: 35b2 scn != ((void *)0)
434testfile9: 35c5 .gnu_debuglink
435testfile9: 35d4 .comment
436testfile9: 35dd cannot open `%s'
437testfile9: 3600 Place stripped output into FILE
438testfile9: 3620 Extract the removed sections into FILE
439testfile9: 3660 Copy modified/access timestamps to the output
440testfile9: 36a0 Only one input file allowed together with '-o' and '-f'
441testfile9: 36e0 Copyright (C) %s Red Hat, Inc.
442testfile9: 36ff This is free software; see the source for copying conditions. There is NO
443testfile9: 374a warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
444testfile9: 37a0 Report bugs to <drepper@redhat.com>.
445testfile9: 37e0 %s: File format not recognized
446testfile9: 3800 cannot set access and modification date of "%s"
447testfile9: 3840 cannot create new file `%s': %s
448testfile9: 3860 error while finishing `%s': %s
449testfile9: 3880 shdr_info[shdr_info[cnt].shdr.sh_link].version_idx == 0
450testfile9: 38c0 shdr_info[shdr_info[cnt].shdr.sh_link].symtab_idx == 0
451testfile9: 3900 %s: error while creating ELF header: %s
452testfile9: 3940 %s: error while reading the file: %s
453testfile9: 3980 sec < 0xff00 || shndxdata != ((void *)0)
454testfile9: 39c0 (versiondata->d_size / sizeof (GElf_Versym)) >= shdr_info[cnt].data->d_size / elsize
455testfile9: 3a20 shdr_info[cnt].shdr.sh_type == 11
456testfile9: 3a60 (versiondata->d_size / sizeof (Elf32_Word)) >= shdr_info[cnt].data->d_size / elsize
457testfile9: 3ac0 shdr_info[cnt].shdr.sh_type == 18
458testfile9: 3b00 shdr_info[cnt].data != ((void *)0)
459testfile9: 3b40 elf_ndxscn (shdr_info[cnt].newscn) == idx
460testfile9: 3b80 while create section header section: %s
461testfile9: 3bc0 cannot allocate section data: %s
462testfile9: 3c00 elf_ndxscn (shdr_info[cnt].newscn) == shdr_info[cnt].idx
463testfile9: 3c40 while generating output file: %s
464testfile9: 3c80 while preparing output for `%s'
465testfile9: 3ca0 shdr_info[cnt].shdr.sh_type == 2
466testfile9: 3ce0 shdr_info[idx].data != ((void *)0)
467testfile9: 3d20 cannot determine number of sections: %s
468testfile9: 3d60 cannot get section header string table index
469testfile9: 3e20 Discard symbols from object files.
470testfile9: 3e43 [FILE...]
471EOF
472
473rm -f testfile testfile[23456789]
474
475exit 0