diff --git a/ELFIOTest/ELFIOTest.cpp b/ELFIOTest/ELFIOTest.cpp index 8312879ff265136dcdcde512d8e38e18d5665627..5cceab0794cb1a633ae8fb0c62870c5d62478fbd 100644 --- a/ELFIOTest/ELFIOTest.cpp +++ b/ELFIOTest/ELFIOTest.cpp @@ -915,9 +915,74 @@ BOOST_AUTO_TEST_CASE( test_dummy_out_ppc_64 ) checkSection( sec, 1, ".shstrtab", SHT_STRTAB, 0, 0, 17, 0, 0, 0, 0 ); - sec =reader.sections[ ".note" ]; + sec = reader.sections[ ".note" ]; BOOST_CHECK_EQUAL( sec->get_index(), 2 ); checkSection( sec, 2, ".note", SHT_NOTE, SHF_ALLOC, 0, 28, 0, 0, 4, 0 ); } + + +//////////////////////////////////////////////////////////////////////////////// +BOOST_AUTO_TEST_CASE( test_dynamic_64_1 ) +{ + elfio reader; + + reader.load( "../elf_examples/main" ); + + section* dynsec = reader.sections[".dynamic"]; + + dynamic_section_accessor da( reader, dynsec ); + + BOOST_CHECK_EQUAL( da.get_entries_num(), 26 ); + + Elf_Xword tag; + Elf_Xword value; + std::string str; + da.get_entry( 0, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_NEEDED ); + BOOST_CHECK_EQUAL( str, "libfunc.so" ); + da.get_entry( 1, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_NEEDED ); + BOOST_CHECK_EQUAL( str, "libc.so.6" ); + da.get_entry( 2, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_INIT ); + BOOST_CHECK_EQUAL( value, 0x400530 ); + da.get_entry( 19, tag, value, str ); + BOOST_CHECK_EQUAL( tag, 0x6ffffff0 ); + BOOST_CHECK_EQUAL( value, 0x40047e ); + da.get_entry( 20, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_NULL ); + BOOST_CHECK_EQUAL( value, 0 ); +} + + +//////////////////////////////////////////////////////////////////////////////// +BOOST_AUTO_TEST_CASE( test_dynamic_64_2 ) +{ + elfio reader; + + reader.load( "../elf_examples/libfunc.so" ); + + section* dynsec = reader.sections[".dynamic"]; + + dynamic_section_accessor da( reader, dynsec ); + + BOOST_CHECK_EQUAL( da.get_entries_num(), 24 ); + + Elf_Xword tag; + Elf_Xword value; + std::string str; + da.get_entry( 0, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_NEEDED ); + BOOST_CHECK_EQUAL( str, "libc.so.6" ); + da.get_entry( 1, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_INIT ); + BOOST_CHECK_EQUAL( value, 0x480 ); + da.get_entry( 18, tag, value, str ); + BOOST_CHECK_EQUAL( tag, 0x6ffffff9 ); + BOOST_CHECK_EQUAL( value, 1 ); + da.get_entry( 19, tag, value, str ); + BOOST_CHECK_EQUAL( tag, DT_NULL ); + BOOST_CHECK_EQUAL( value, 0 ); +} diff --git a/ELFIOTest/ELFIOTest.vcxproj b/ELFIOTest/ELFIOTest.vcxproj index c99e369fe113f8767102a6af9842dce980844dda..5ad1a3762039fa1f9c79fb767c01edeca4e431b4 100644 --- a/ELFIOTest/ELFIOTest.vcxproj +++ b/ELFIOTest/ELFIOTest.vcxproj @@ -62,7 +62,7 @@ <AdditionalDependencies> </AdditionalDependencies> <AdditionalLibraryDirectories>\Developer\boost_1_52_0\stage12\lib</AdditionalLibraryDirectories> - <Profile>true</Profile> + <Profile>false</Profile> </Link> <PostBuildEvent> <Command>"$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=short </Command> @@ -100,6 +100,7 @@ </ItemGroup> <ItemGroup> <ClInclude Include="..\elfio\elfio.hpp" /> + <ClInclude Include="..\elfio\elfio_dynamic.hpp" /> <ClInclude Include="..\elfio\elfio_header.hpp" /> <ClInclude Include="..\elfio\elfio_note.hpp" /> <ClInclude Include="..\elfio\elfio_relocation.hpp" /> @@ -108,8 +109,6 @@ <ClInclude Include="..\elfio\elfio_strings.hpp" /> <ClInclude Include="..\elfio\elfio_symbols.hpp" /> <ClInclude Include="..\elfio\elfio_utils.hpp" /> - <ClInclude Include="..\elfio\elfi_dynamic.hpp" /> - <ClInclude Include="..\elfio\elfo_dynamic.hpp" /> <ClInclude Include="..\elfio\elf_types.hpp" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> diff --git a/ELFIOTest/ELFIOTest.vcxproj.filters b/ELFIOTest/ELFIOTest.vcxproj.filters index dd363317e4623aec73332ad5041d1ad17a2a73b9..cc19fff6ff166026ac5edbf9379a5778a2769a74 100644 --- a/ELFIOTest/ELFIOTest.vcxproj.filters +++ b/ELFIOTest/ELFIOTest.vcxproj.filters @@ -26,9 +26,6 @@ <ClInclude Include="..\elfio\elf_types.hpp"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\elfio\elfi_dynamic.hpp"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="..\elfio\elfio.hpp"> <Filter>Header Files</Filter> </ClInclude> @@ -56,7 +53,7 @@ <ClInclude Include="..\elfio\elfio_utils.hpp"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="..\elfio\elfo_dynamic.hpp"> + <ClInclude Include="..\elfio\elfio_dynamic.hpp"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> diff --git a/Makefile.am b/Makefile.am index 53173321ec89073ef38015eff73163b825146b2b..dd2a4b4ec2303cc9940fd5cffbc9fc9d01938edb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,11 +1,10 @@ SUBDIRS = examples -nobase_include_HEADERS = elfio/elf_types.hpp elfio/elfi_dynamic.hpp \ +nobase_include_HEADERS = elfio/elf_types.hpp elfio/elfio_dynamic.hpp \ elfio/elfio.hpp elfio/elfio_header.hpp \ elfio/elfio_note.hpp elfio/elfio_relocation.hpp \ elfio/elfio_section.hpp elfio/elfio_segment.hpp \ elfio/elfio_strings.hpp elfio/elfio_symbols.hpp \ - elfio/elfio_utils.hpp elfio/elfo_dynamic.hpp \ - elfio/elfio_dump.hpp + elfio/elfio_utils.hpp elfio/elfio_dump.hpp EXTRA_DIST = doc/site/elfio.pdf dist-hook: mv $(distdir)/doc/site/elfio.pdf $(distdir)/doc diff --git a/Makefile.in b/Makefile.in index 222ecf29d1ad5d145a7315227565ae295da232a4..569ef2cbc06ba30394b13f0b535a358d7dcf91b9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -55,6 +72,11 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -216,13 +238,12 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = examples -nobase_include_HEADERS = elfio/elf_types.hpp elfio/elfi_dynamic.hpp \ +nobase_include_HEADERS = elfio/elf_types.hpp elfio/elfio_dynamic.hpp \ elfio/elfio.hpp elfio/elfio_header.hpp \ elfio/elfio_note.hpp elfio/elfio_relocation.hpp \ elfio/elfio_section.hpp elfio/elfio_segment.hpp \ elfio/elfio_strings.hpp elfio/elfio_symbols.hpp \ - elfio/elfio_utils.hpp elfio/elfo_dynamic.hpp \ - elfio/elfio_dump.hpp + elfio/elfio_utils.hpp elfio/elfio_dump.hpp EXTRA_DIST = doc/site/elfio.pdf all: all-recursive @@ -264,15 +285,18 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): install-nobase_includeHEADERS: $(nobase_include_HEADERS) @$(NORMAL_INSTALL) - test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(nobase_include_HEADERS)'; test -n "$(includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ + fi; \ $(am__nobase_list) | while read dir files; do \ xfiles=; for file in $$files; do \ if test -f "$$file"; then xfiles="$$xfiles $$file"; \ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ test -z "$$xfiles" || { \ test "x$$dir" = x. || { \ - echo "$(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \ + echo " $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)/$$dir"; }; \ echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'"; \ $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(includedir)/$$dir" || exit $$?; }; \ @@ -453,13 +477,10 @@ distdir: $(DISTFILES) done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ @@ -548,7 +569,7 @@ distcheck: dist *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir); chmod a+w $(distdir) + chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) diff --git a/aclocal.m4 b/aclocal.m4 index da06da5f99cc4ea5382f550714b1571a2c8abc59..30941788d63d739cdc6488936a54f4015d4c76e9 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.11.3 -*- Autoconf -*- +# generated automatically by aclocal 1.11.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, @@ -14,8 +14,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, -[m4_warning([this file was generated for autoconf 2.68. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -38,7 +38,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.3], [], +m4_if([$1], [1.11.6], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -54,7 +54,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.3])dnl +[AM_AUTOMAKE_VERSION([1.11.6])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) diff --git a/configure b/configure index 792dbe1a93efa8c2db27642aa5edffbc58a57d01..ded28497a5de1060fe4707ba1bd8228b3efc0fb7 100755 --- a/configure +++ b/configure @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for ELFIO 2.0. +# Generated by GNU Autoconf 2.69 for ELFIO 2.0. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -134,6 +132,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -211,21 +235,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -327,6 +355,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -448,6 +484,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -482,16 +522,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -503,28 +543,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -1112,8 +1132,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1352,9 +1370,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF ELFIO configure 2.0 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1407,7 +1425,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by ELFIO $as_me 2.0, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -1822,7 +1840,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -1991,7 +2009,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2031,7 +2049,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2082,7 +2100,7 @@ do test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -2135,7 +2153,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2289,7 +2307,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2333,7 +2351,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3420,16 +3438,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -3489,28 +3507,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -3532,7 +3538,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by ELFIO $as_me 2.0, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -3589,10 +3595,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ ELFIO config.status 2.0 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -3672,7 +3678,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/elf_examples/elf_dummy_header_i386_32.elf b/elf_examples/elf_dummy_header_i386_32.elf index 8d551a8213bdbdcbda0f61c749152527465e09bf..dc2fd13b07e08c972bb117546d33ac83b7aec4ce 100644 Binary files a/elf_examples/elf_dummy_header_i386_32.elf and b/elf_examples/elf_dummy_header_i386_32.elf differ diff --git a/elf_examples/elf_dummy_header_i386_64.elf b/elf_examples/elf_dummy_header_i386_64.elf index c4c5c30bf19ae7458146f0f1f86c8b691051d707..31c8a92e6eba08824e9fdd3494bb77eed2044950 100644 Binary files a/elf_examples/elf_dummy_header_i386_64.elf and b/elf_examples/elf_dummy_header_i386_64.elf differ diff --git a/elf_examples/elf_dummy_header_ppc_32.elf b/elf_examples/elf_dummy_header_ppc_32.elf index 2b85ecc591009502e7b1feca377eb635066f2825..3e40c2de95b806240a66cfb82c7dfbb99d4af32f 100644 Binary files a/elf_examples/elf_dummy_header_ppc_32.elf and b/elf_examples/elf_dummy_header_ppc_32.elf differ diff --git a/elf_examples/elf_dummy_header_ppc_64.elf b/elf_examples/elf_dummy_header_ppc_64.elf index b85aa18d4fe06ceb7f871cb42027201bddcc9c02..a713e50fc4a51cb397b7a74d4baf16f2d132fde0 100644 Binary files a/elf_examples/elf_dummy_header_ppc_64.elf and b/elf_examples/elf_dummy_header_ppc_64.elf differ diff --git a/elf_examples/hello_32_copy.o b/elf_examples/hello_32_copy.o index 437bfcdd5b30a3ddc15e23928663e3d770a126a8..50d6ee04b6cc88606272a5e70864883e5871e068 100644 Binary files a/elf_examples/hello_32_copy.o and b/elf_examples/hello_32_copy.o differ diff --git a/elf_examples/hello_64_copy.o b/elf_examples/hello_64_copy.o index 39bd4ae7b79855ee3c7c714fd24f4c3ab4c8537b..ec8f831a9f6dcd8e5b7995974a07e48044612a80 100644 Binary files a/elf_examples/hello_64_copy.o and b/elf_examples/hello_64_copy.o differ diff --git a/elf_examples/libfunc.so b/elf_examples/libfunc.so new file mode 100644 index 0000000000000000000000000000000000000000..8377027bef0f0068ca575b1079af037219e3c40d Binary files /dev/null and b/elf_examples/libfunc.so differ diff --git a/elf_examples/libfunc32.so b/elf_examples/libfunc32.so new file mode 100644 index 0000000000000000000000000000000000000000..eaa6826cb95d1e7d6e22c6d9a1b702afc4b3278d Binary files /dev/null and b/elf_examples/libfunc32.so differ diff --git a/elf_examples/main b/elf_examples/main new file mode 100644 index 0000000000000000000000000000000000000000..f4018b7122ed7e8ab8188299efeef38e6991f033 Binary files /dev/null and b/elf_examples/main differ diff --git a/elf_examples/main32 b/elf_examples/main32 new file mode 100644 index 0000000000000000000000000000000000000000..63196e91f221128c0a7cff51ea185d87cc4835cf Binary files /dev/null and b/elf_examples/main32 differ diff --git a/elf_examples/test_ppc_copy.o b/elf_examples/test_ppc_copy.o index 36b008fff868ef6cec31023add4c98834d1eec1b..60211cf6dab747183fa2e89e6bdceff3608213a9 100644 Binary files a/elf_examples/test_ppc_copy.o and b/elf_examples/test_ppc_copy.o differ diff --git a/elf_examples/write_obj_i386_32.o b/elf_examples/write_obj_i386_32.o index 6cb68e564326ada3af0168b32d87f4ca135edc11..48f0942d0f8e0fa0f3386ee0f350ad8a32c530cb 100644 Binary files a/elf_examples/write_obj_i386_32.o and b/elf_examples/write_obj_i386_32.o differ diff --git a/elf_examples/write_obj_i386_32_copy.o b/elf_examples/write_obj_i386_32_copy.o index 6cb68e564326ada3af0168b32d87f4ca135edc11..48f0942d0f8e0fa0f3386ee0f350ad8a32c530cb 100644 Binary files a/elf_examples/write_obj_i386_32_copy.o and b/elf_examples/write_obj_i386_32_copy.o differ diff --git a/elf_examples/write_obj_i386_32_match.o b/elf_examples/write_obj_i386_32_match.o index 6cb68e564326ada3af0168b32d87f4ca135edc11..48f0942d0f8e0fa0f3386ee0f350ad8a32c530cb 100644 Binary files a/elf_examples/write_obj_i386_32_match.o and b/elf_examples/write_obj_i386_32_match.o differ diff --git a/elf_examples/write_obj_i386_64.o b/elf_examples/write_obj_i386_64.o index fdd95bdeb60546dc4c044398ae23c5e4eb166835..8335573feecfdb3b9004c53faf053f6eb551b11a 100644 Binary files a/elf_examples/write_obj_i386_64.o and b/elf_examples/write_obj_i386_64.o differ diff --git a/elf_examples/write_obj_i386_64_copy.o b/elf_examples/write_obj_i386_64_copy.o index fdd95bdeb60546dc4c044398ae23c5e4eb166835..8335573feecfdb3b9004c53faf053f6eb551b11a 100644 Binary files a/elf_examples/write_obj_i386_64_copy.o and b/elf_examples/write_obj_i386_64_copy.o differ diff --git a/elf_examples/write_obj_i386_64_match.o b/elf_examples/write_obj_i386_64_match.o index fdd95bdeb60546dc4c044398ae23c5e4eb166835..8335573feecfdb3b9004c53faf053f6eb551b11a 100644 Binary files a/elf_examples/write_obj_i386_64_match.o and b/elf_examples/write_obj_i386_64_match.o differ diff --git a/elfio/elf_types.hpp b/elfio/elf_types.hpp index ac7c2aafbedf469d4058126e0169d83eb5d57c97..17dc51f3d41b8a763f4316abd863e6f4835e4441 100644 --- a/elfio/elf_types.hpp +++ b/elfio/elf_types.hpp @@ -528,6 +528,7 @@ typedef uint64_t Elf64_Off; #define DT_ENCODING 32 #define DT_PREINIT_ARRAY 32 #define DT_PREINIT_ARRAYSZ 33 +#define DT_MAXPOSTAGS 34 #define DT_LOOS 0x6000000D #define DT_HIOS 0x6ffff000 #define DT_LOPROC 0x70000000 diff --git a/elfio/elfi_dynamic.hpp b/elfio/elfi_dynamic.hpp deleted file mode 100644 index ce8d073b257c405363086feb7a0e23a8f1b722d5..0000000000000000000000000000000000000000 --- a/elfio/elfi_dynamic.hpp +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef ELFI_DYNAMIC_HPP -#define ELFI_DYNAMIC_HPP - -class ELFIDynamicReader : virtual public ELFIReaderImpl, virtual public IELFIDynamicReader -{ - public: - ELFIDynamicReader( const IELFI* pIELFI, const section* pSection ); - virtual ~ELFIDynamicReader(); - - // Dynamic reader functions - virtual Elf_Xword getEntriesNum() const; - virtual ELFIO_Err get_entry( Elf_Xword index, - Elf_Sxword& tag, - Elf_Xword& value ) const; -}; - - -ELFIDynamicReader::ELFIDynamicReader( const IELFI* pIELFI, const section* pSection ) : - ELFIReaderImpl( pIELFI, pSection ) -{ -} - - -ELFIDynamicReader::~ELFIDynamicReader() -{ -} - - -Elf_Xword -ELFIDynamicReader::getEntriesNum() const -{ - Elf_Xword nRet = 0; - if ( 0 != m_pSection->get_entry_size() ) { - nRet = m_pSection->get_size() / m_pSection->get_entry_size(); - } - - return nRet; -} - - -ELFIO_Err -ELFIDynamicReader::get_entry( Elf_Xword index, - Elf_Sxword& tag, - Elf_Xword& value ) const -{ - if ( index >= getEntriesNum() ) { // Is index valid - return ERR_ELFIO_INDEX_ERROR; - } - - const Elf64_Dyn* pEntry = reinterpret_cast<const Elf64_Dyn*>( - m_pSection->get_data() + index * m_pSection->get_entry_size() ); - tag = convert2host( pEntry->d_tag, m_pIELFI->get_encoding() ); - value = convert2host( pEntry->d_un.d_val, m_pIELFI->get_encoding() ); - - return ERR_ELFIO_NO_ERROR; -} - -#endif // ELFI_DYNAMIC_HPP diff --git a/elfio/elfio.hpp b/elfio/elfio.hpp index c75c32d08bbf13e80d9178f843412c7e3608557b..79d36585120d6fb597b3e99513883c621d2db0dd 100644 --- a/elfio/elfio.hpp +++ b/elfio/elfio.hpp @@ -44,7 +44,6 @@ THE SOFTWARE. #include <elfio/elfio_segment.hpp> #include <elfio/elfio_strings.hpp> - #define ELFIO_HEADER_ACCESS_GET( TYPE, FNAME ) \ TYPE \ get_##FNAME() const \ @@ -390,10 +389,15 @@ class elfio { // Fill not completed fields in the header header->set_segments_num( segments.size() ); - header->set_segments_offset( header->get_header_size() ); + if ( segments.size() == 0 ) { + header->set_segments_offset( 0 ); + } + else { + header->set_segments_offset( header->get_header_size() ); + } header->set_sections_num( sections.size() ); header->set_sections_offset( header->get_header_size() + - header->get_segment_entry_size() * segments.size() ); + header->get_segment_entry_size() * segments.size() ); } //------------------------------------------------------------------------------ @@ -606,9 +610,10 @@ class elfio } // namespace ELFIO -#include "elfio_symbols.hpp" -#include "elfio_note.hpp" -#include "elfio_relocation.hpp" +#include <elfio/elfio_symbols.hpp> +#include <elfio/elfio_note.hpp> +#include <elfio/elfio_relocation.hpp> +#include <elfio/elfio_dynamic.hpp> #ifdef _MSC_VER #pragma warning ( pop ) diff --git a/elfio/elfio_dump.hpp b/elfio/elfio_dump.hpp index c92ba0977c962f375285ff5f412a0fde1bd6967d..999450c17e568ab69f9bd6d02701c7c5cc813e29 100644 --- a/elfio/elfio_dump.hpp +++ b/elfio/elfio_dump.hpp @@ -370,6 +370,49 @@ static struct symbol_type_t { }; +static struct dynamic_tag_t { + const Elf_Word key; + const char* str; +} dynamic_tag_table [] = +{ + { DT_NULL , "NULL" }, + { DT_NEEDED , "NEEDED" }, + { DT_PLTRELSZ , "PLTRELSZ" }, + { DT_PLTGOT , "PLTGOT" }, + { DT_HASH , "HASH" }, + { DT_STRTAB , "STRTAB" }, + { DT_SYMTAB , "SYMTAB" }, + { DT_RELA , "RELA" }, + { DT_RELASZ , "RELASZ" }, + { DT_RELAENT , "RELAENT" }, + { DT_STRSZ , "STRSZ" }, + { DT_SYMENT , "SYMENT" }, + { DT_INIT , "INIT" }, + { DT_FINI , "FINI" }, + { DT_SONAME , "SONAME" }, + { DT_RPATH , "RPATH" }, + { DT_SYMBOLIC , "SYMBOLIC" }, + { DT_REL , "REL" }, + { DT_RELSZ , "RELSZ" }, + { DT_RELENT , "RELENT" }, + { DT_PLTREL , "PLTREL" }, + { DT_DEBUG , "DEBUG" }, + { DT_TEXTREL , "TEXTREL" }, + { DT_JMPREL , "JMPREL" }, + { DT_BIND_NOW , "BIND_NOW" }, + { DT_INIT_ARRAY , "INIT_ARRAY" }, + { DT_FINI_ARRAY , "FINI_ARRAY" }, + { DT_INIT_ARRAYSZ , "INIT_ARRAYSZ" }, + { DT_FINI_ARRAYSZ , "FINI_ARRAYSZ" }, + { DT_RUNPATH , "RUNPATH" }, + { DT_FLAGS , "FLAGS" }, + { DT_ENCODING , "ENCODING" }, + { DT_PREINIT_ARRAY , "PREINIT_ARRAY" }, + { DT_PREINIT_ARRAYSZ, "PREINIT_ARRAYSZ" }, + { DT_MAXPOSTAGS , "MAXPOSTAGS" }, +}; + + //------------------------------------------------------------------------------ class dump { @@ -668,6 +711,58 @@ class dump << std::endl; } +//------------------------------------------------------------------------------ + static void + dynamic_tags( std::ostream& out, const elfio& reader ) + { + Elf_Half n = reader.sections.size(); + for ( Elf_Half i = 0; i < n; ++i ) { // For all sections + section* sec = reader.sections[i]; + if ( SHT_DYNAMIC == sec->get_type() ) { + dynamic_section_accessor dynamic( reader, sec ); + + Elf_Xword dyn_no = dynamic.get_entries_num(); + if ( dyn_no > 0 ) { + out << "Dynamic section (" << sec->get_name() << ")" << std::endl; + out << "[ Nr ] Tag Name/Value" << std::endl; + for ( int i = 0; i < dyn_no; ++i ) { + Elf_Xword tag; + Elf_Xword value; + std::string str; + dynamic.get_entry( i, tag, value, str ); + dynamic_tag( out, i, tag, value, str, reader.get_class() ); + if ( DT_NULL == tag ) { + break; + } + } + + out << std::endl; + } + } + } + } + +//------------------------------------------------------------------------------ + static void + dynamic_tag( std::ostream& out, + int no, + Elf_Xword tag, + Elf_Xword value, + std::string str, + unsigned int elf_class ) + { + out << "[" + << DUMP_DEC_FORMAT( 5 ) << no + << "] " + << DUMP_STR_FORMAT( 16 ) << str_dynamic_tag( tag ) << " "; + if ( str.empty() ) { + out << DUMP_HEX_FORMAT( 16 ) << value << " "; + } + else { + out << DUMP_STR_FORMAT( 32 ) << str << " "; + } + out << std::endl; + } private: //------------------------------------------------------------------------------ @@ -755,6 +850,7 @@ class dump STR_FUNC_TABLE( segment_flag ); STR_FUNC_TABLE( symbol_bind ); STR_FUNC_TABLE( symbol_type ); + STR_FUNC_TABLE( dynamic_tag ); #undef STR_FUNC_TABLE #undef DUMP_DEC_FORMAT diff --git a/elfio/elfio_dynamic.hpp b/elfio/elfio_dynamic.hpp new file mode 100644 index 0000000000000000000000000000000000000000..f075304c4e5da99bcf0db59c5f2272d910cbfb72 --- /dev/null +++ b/elfio/elfio_dynamic.hpp @@ -0,0 +1,183 @@ +/* +Copyright (C) 2001-2011 by Serge Lamikhov-Center + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +#ifndef ELFIO_DYNAMIC_HPP +#define ELFIO_DYNAMIC_HPP + +namespace ELFIO { + +//------------------------------------------------------------------------------ +class dynamic_section_accessor +{ + public: +//------------------------------------------------------------------------------ + dynamic_section_accessor( const elfio& elf_file_, section* section_ ) : + elf_file( elf_file_ ), + dynamic_section( section_ ) + { + } + +//------------------------------------------------------------------------------ + Elf_Xword + get_entries_num() const + { + Elf_Xword nRet = 0; + + if ( 0 != dynamic_section->get_entry_size() ) { + nRet = dynamic_section->get_size() / dynamic_section->get_entry_size(); + } + + return nRet; + } + +//------------------------------------------------------------------------------ + bool + get_entry( Elf_Xword index, + Elf_Xword& tag, + Elf_Xword& value, + std::string& str ) const + { + if ( index >= get_entries_num() ) { // Is index valid + return false; + } + + if ( elf_file.get_class() == ELFCLASS32 ) { + generic_get_entry_dyn< Elf32_Dyn >( index, tag, value ); + } + else { + generic_get_entry_dyn< Elf64_Dyn >( index, tag, value ); + } + + // If the tag may have a string table reference, prepare the string + if ( tag == DT_NEEDED || + tag == DT_SONAME || + tag == DT_RPATH || + tag == DT_RUNPATH ) { + string_section_accessor strsec = + elf_file.sections[ dynamic_section->get_link() ]; + str = strsec.get_string( value ); + } + else { + str = ""; + } + + return true; + } + +//------------------------------------------------------------------------------ + private: +//------------------------------------------------------------------------------ + Elf_Half + get_symbol_table_index() const + { + return (Elf_Half)dynamic_section->get_link(); + } + +//------------------------------------------------------------------------------ + template< class T > + void + generic_get_entry_dyn( Elf_Xword index, + Elf_Xword& tag, + Elf_Xword& value ) const + { + const endianess_convertor& convertor = elf_file.get_convertor(); + + const T* pEntry = reinterpret_cast<const T*>( + dynamic_section->get_data() + + index * dynamic_section->get_entry_size() ); + tag = convertor( pEntry->d_tag ); + switch ( tag ) { + case DT_NULL: + value = 0; + break; + case DT_NEEDED: + case DT_PLTRELSZ: + case DT_RELASZ: + case DT_RELAENT: + case DT_STRSZ: + case DT_SYMENT: + case DT_SONAME: + case DT_RPATH: + case DT_RELSZ: + case DT_RELENT: + case DT_PLTREL: + case DT_INIT_ARRAYSZ: + case DT_FINI_ARRAYSZ: + case DT_RUNPATH: + case DT_FLAGS: + case DT_PREINIT_ARRAYSZ: +/* + case DT_SUNW_SYMSZ: + case DT_SUNW_SORTENT: + case DT_SUNW_SYMSORTSZ: + case DT_SUNW_TLSSORTSZ: + case DT_SUNW_STRPAD: + case DT_SUNW_LDMACH: + case DT_SUNW_CAPCHAINENT: + case DT_SUNW_CAPCHAINSZ: + case DT_CHECKSUM: + case DT_PLTPADSZ: + case DT_MOVEENT: + case DT_MOVESZ: + case DT_POSFLAG_1: + case DT_SYMINSZ: + case DT_SYMINENT: + case DT_RELACOUNT: + case DT_RELCOUNT: + case DT_FLAGS_1: + case DT_VERDEFNUM: + case DT_VERNEEDNUM: + case DT_SPARC_REGISTER: + case DT_AUXILIARY: + case DT_USED: + case DT_FILTER: +*/ + value = convertor( pEntry->d_un.d_val ); + break; + case DT_PLTGOT: + case DT_HASH: + case DT_STRTAB: + case DT_SYMTAB: + case DT_RELA: + case DT_INIT: + case DT_FINI: + case DT_REL: + case DT_DEBUG: + case DT_JMPREL: + case DT_INIT_ARRAY: + case DT_FINI_ARRAY: + case DT_PREINIT_ARRAY: + default: + value = convertor( pEntry->d_un.d_ptr ); + break; + } + } + +//------------------------------------------------------------------------------ + private: + const elfio& elf_file; + section* dynamic_section; +}; + +} // namespace ELFIO + +#endif // ELFIO_DYNAMIC_HPP diff --git a/elfio/elfio_relocation.hpp b/elfio/elfio_relocation.hpp index 3d26adc4f5866771120b1a4a35f23bd2ac0e510b..f29f3bf8b50d4d8aa5f31debcbe5cda648bf0686 100644 --- a/elfio/elfio_relocation.hpp +++ b/elfio/elfio_relocation.hpp @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef ELFI_RELOCATION_HPP -#define ELFI_RELOCATION_HPP +#ifndef ELFIO_RELOCATION_HPP +#define ELFIO_RELOCATION_HPP namespace ELFIO { @@ -77,7 +77,7 @@ class relocation_section_accessor { public: //------------------------------------------------------------------------------ - relocation_section_accessor( elfio& elf_file_, section* section_ ) : + relocation_section_accessor( const elfio& elf_file_, section* section_ ) : elf_file( elf_file_ ), relocation_section( section_ ) { @@ -282,13 +282,6 @@ class relocation_section_accessor return (Elf_Half)relocation_section->get_link(); } -//------------------------------------------------------------------------------ - Elf_Half - getTargetSectionIndex() const - { - return (Elf_Half)relocation_section->get_info(); - } - //------------------------------------------------------------------------------ template< class T > void @@ -365,10 +358,10 @@ class relocation_section_accessor //------------------------------------------------------------------------------ private: - elfio& elf_file; - section* relocation_section; + const elfio& elf_file; + section* relocation_section; }; } // namespace ELFIO -#endif // ELFI_RELOCATION_HPP +#endif // ELFIO_RELOCATION_HPP diff --git a/elfio/elfio_section.hpp b/elfio/elfio_section.hpp index 73f1e31b66b3fe0cabe51946a52d81df6727958b..d24b9bbcf8aa1962bf72d0cd608be5aee48ebc94 100644 --- a/elfio/elfio_section.hpp +++ b/elfio/elfio_section.hpp @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef ELFI_SECTION_HPP -#define ELFI_SECTION_HPP +#ifndef ELFIO_SECTION_HPP +#define ELFIO_SECTION_HPP #include <string> #include <fstream> @@ -271,4 +271,4 @@ class section_impl : public section } // namespace ELFIO -#endif // ELFI_SECTION_HPP +#endif // ELFIO_SECTION_HPP diff --git a/elfio/elfio_segment.hpp b/elfio/elfio_segment.hpp index 78fc44969ca2b0fe38d0eaf597167083e56929be..fb93fb22cf1567b43e72da26c3d4aaf098b50a9a 100644 --- a/elfio/elfio_segment.hpp +++ b/elfio/elfio_segment.hpp @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef ELFI_SEGMENT_HPP -#define ELFI_SEGMENT_HPP +#ifndef ELFIO_SEGMENT_HPP +#define ELFIO_SEGMENT_HPP #include <fstream> #include <vector> @@ -179,4 +179,4 @@ class segment_impl : public segment } // namespace ELFIO -#endif // ELFI_SEGMENT_HPP +#endif // ELFIO_SEGMENT_HPP diff --git a/elfio/elfio_symbols.hpp b/elfio/elfio_symbols.hpp index d498ca1cfcd25c5a8699e0b4265f8b960e99ec3c..b893e2bf19c14102ec74825398f99ee39e6cac50 100644 --- a/elfio/elfio_symbols.hpp +++ b/elfio/elfio_symbols.hpp @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef ELFI_SYMBOLS_HPP -#define ELFI_SYMBOLS_HPP +#ifndef ELFIO_SYMBOLS_HPP +#define ELFIO_SYMBOLS_HPP namespace ELFIO { @@ -273,4 +273,4 @@ class symbol_section_accessor } // namespace ELFIO -#endif // ELFI_SYMBOLS_HPP +#endif // ELFIO_SYMBOLS_HPP diff --git a/elfio/elfo_dynamic.hpp b/elfio/elfo_dynamic.hpp deleted file mode 100644 index f477a3552eed0b152e817873232a75430e2e87b3..0000000000000000000000000000000000000000 --- a/elfio/elfo_dynamic.hpp +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef ELFO_DYNAMIC_HPP -#define ELFO_DYNAMIC_HPP - -// Dynamic section producer -class ELFODynamicWriter : public IELFODynamicWriter -{ - public: - ELFODynamicWriter( IELFO* pIELFO, IELFOSection* pSection ); - ~ELFODynamicWriter(); - - virtual int addRef(); - virtual int release(); - - virtual ELFIO_Err addEntry( Elf_Sword tag, Elf_Word value ); - - private: - int m_nRefCnt; - IELFO* m_pIELFO; - IELFOSection* m_pSection; -}; - - -ELFODynamicWriter::ELFODynamicWriter( IELFO* pIELFO, IELFOSection* pSection ) : - m_nRefCnt( 1 ), - m_pIELFO( pIELFO ), - m_pSection( pSection ) -{ - m_pIELFO->addRef(); - m_pSection->addRef(); -} - - -ELFODynamicWriter::~ELFODynamicWriter() -{ -} - - -int -ELFODynamicWriter::addRef() -{ - m_pIELFO->addRef(); - m_pSection->addRef(); - return ++m_nRefCnt; -} - - -int -ELFODynamicWriter::release() -{ - int nRet = --m_nRefCnt; - IELFO* pIELFO = m_pIELFO; - IELFOSection* pSec = m_pSection; - - if ( 0 == m_nRefCnt ) { - delete this; - } - pSec->release(); - pIELFO->release(); - - return nRet; -} - - -ELFIO_Err -ELFODynamicWriter::addEntry( Elf_Sword tag, Elf_Word value ) -{ - Elf64_Dyn entry; - entry.d_tag = convert2host( tag, m_pIELFO->get_encoding() ); - entry.d_un.d_val = convert2host( value, m_pIELFO->get_encoding() ); - - return m_pSection->appendData( reinterpret_cast<const char*>( &entry ), - sizeof( entry ) ); -} - -#endif // ELFO_DYNAMIC_HPP diff --git a/examples/Makefile.in b/examples/Makefile.in index 9837be12a09ffa3f97e5324fe67f22018618b8b9..e8409cde69404a44286539d19296a071c15f9dcc 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -15,6 +15,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -49,6 +66,11 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ @@ -368,13 +390,10 @@ distdir: $(DISTFILES) done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ - test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ diff --git a/examples/elfdump/Makefile.in b/examples/elfdump/Makefile.in index 4dda5567c54e36885c29f5fad20fed1d6ceee844..f7f21f09072a284ae21c25fb14cce6236336ceb0 100644 --- a/examples/elfdump/Makefile.in +++ b/examples/elfdump/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -58,6 +75,11 @@ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(elfdump_SOURCES) DIST_SOURCES = $(elfdump_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -183,8 +205,11 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ diff --git a/examples/elfdump/elfdump.cpp b/examples/elfdump/elfdump.cpp index bf985ee4a53fe7211217960957d316d365628ac5..1c6eb5027b023ce91ef5759becdae0362bfa60b2 100644 --- a/examples/elfdump/elfdump.cpp +++ b/examples/elfdump/elfdump.cpp @@ -51,6 +51,7 @@ int main( int argc, char** argv ) dump::segment_headers( std::cout, reader ); dump::symbol_tables ( std::cout, reader ); dump::notes ( std::cout, reader ); + dump::dynamic_tags ( std::cout, reader ); return 0; } diff --git a/examples/tutorial/Makefile.in b/examples/tutorial/Makefile.in index 1e9cc0cd0103b737a3e31378177df5b9b50680cf..37235569c3ddef829e3459855240e0cde85871e2 100644 --- a/examples/tutorial/Makefile.in +++ b/examples/tutorial/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -58,6 +75,11 @@ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(tutorial_SOURCES) DIST_SOURCES = $(tutorial_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -182,8 +204,11 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ diff --git a/examples/write_obj/Makefile.in b/examples/write_obj/Makefile.in index ed855515fac12d09b54f553f7389e9c8a8ddc7bb..307b23fd8ab9c750c3234d32c8cdb31266ac5722 100644 --- a/examples/write_obj/Makefile.in +++ b/examples/write_obj/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -58,6 +75,11 @@ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(write_obj_SOURCES) DIST_SOURCES = $(write_obj_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -182,8 +204,11 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ diff --git a/examples/writer/Makefile.in b/examples/writer/Makefile.in index 039c69e0a6f9ff064e06e7039c7c6f08e5aef429..f59b5d3b16e5f9e86c02461ad9bf2789dec1e0e7 100644 --- a/examples/writer/Makefile.in +++ b/examples/writer/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.3 from Makefile.am. +# Makefile.in generated by automake 1.11.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -16,6 +16,23 @@ @SET_MAKE@ VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ @@ -58,6 +75,11 @@ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(writer_SOURCES) DIST_SOURCES = $(writer_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -182,8 +204,11 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ + fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \