diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2005-12-05 19:00:40 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2005-12-05 19:00:40 +0000 |
commit | 0f859659dc8da5050e36ebca7cdf26e62c113b63 (patch) | |
tree | d250592ff4374915a2e7546d4e2348cd3de43668 /elfutils | |
parent | 743e33eeb33512b69912da1f5dfd2d4e136a003a (diff) | |
download | elfutils-0f859659dc8da5050e36ebca7cdf26e62c113b63.tar.gz |
0.116-alt10.116-alt1
- Updated to 0.116.
Diffstat (limited to 'elfutils')
60 files changed, 1405 insertions, 984 deletions
diff --git a/elfutils/ChangeLog b/elfutils/ChangeLog index fc5cb13a..d03a7713 100644 --- a/elfutils/ChangeLog +++ b/elfutils/ChangeLog @@ -1,3 +1,9 @@ +2005-09-16 Roland McGrath <roland@redhat.com> + + * configure.ac (ALLOW_UNALIGNED) [__ia64__ || __alpha__]: + Don't set it, since on IA64 you get error messages for unaligned + accesses, and on Alpha it's at least very slow. + 2005-08-29 Ulrich Drepper <drepper@redhat.com> * configure.ac: Fix GCOV make condition generation. diff --git a/elfutils/NEWS b/elfutils/NEWS index 1d88564f..fcda7cef 100644 --- a/elfutils/NEWS +++ b/elfutils/NEWS @@ -1,3 +1,15 @@ +Version 0.116: + +libdw: New functions dwarf_ranges, dwarf_entrypc, dwarf_diecu, + dwarf_entry_breakpoints. Removed Dwarf_Func type and functions + dwarf_func_name, dwarf_func_lowpc, dwarf_func_highpc, + dwarf_func_entrypc, dwarf_func_die; dwarf_getfuncs callback now uses + Dwarf_Die, and dwarf_func_file, dwarf_func_line, dwarf_func_col + replaced by dwarf_decl_file, dwarf_decl_line, dwarf_decl_column; + dwarf_func_inline, dwarf_func_inline_instances now take Dwarf_Die. + Type Dwarf_Loc renamed to Dwarf_Op; dwarf_getloclist, + dwarf_addrloclists renamed dwarf_getlocation, dwarf_getlocation_addr. + Version 0.115: libelf: speed-ups of non-mmap reading. diff --git a/elfutils/config.h.in b/elfutils/config.h.in index be063abf..f0122a98 100644 --- a/elfutils/config.h.in +++ b/elfutils/config.h.in @@ -92,7 +92,7 @@ /* Define ALLOW_UNALIGNED if the architecture allows operations on unaligned memory locations. */ -#if defined __i386__ || defined __alpha__ || defined __x86_64__ || defined __ia64__ +#if defined __i386__ || defined __x86_64__ # define ALLOW_UNALIGNED 1 #else # define ALLOW_UNALIGNED 0 diff --git a/elfutils/config/elfutils.spec.in b/elfutils/config/elfutils.spec.in index 229bd3e7..1b512637 100644 --- a/elfutils/config/elfutils.spec.in +++ b/elfutils/config/elfutils.spec.in @@ -185,6 +185,17 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/libelf.so %changelog +* Mon Oct 31 2005 Ulrich Drepper <drepper@redhat.com> 0.116-1 +- libdw: New functions dwarf_ranges, dwarf_entrypc, dwarf_diecu, d +warf_entry_breakpoints. Removed Dwarf_Func type and functions d +warf_func_name, dwarf_func_lowpc, dwarf_func_highpc, dwarf_func_ +entrypc, dwarf_func_die; dwarf_getfuncs callback now uses Dwarf_ +Die, and dwarf_func_file, dwarf_func_line, dwarf_func_col replac +ed by dwarf_decl_file, dwarf_decl_line, dwarf_decl_column; dwarf +_func_inline, dwarf_func_inline_instances now take Dwarf_Die. Ty +pe Dwarf_Loc renamed to Dwarf_Op; dwarf_getloclist, dwarf_addrlo +clists renamed dwarf_getlocation, dwarf_getlocation_addr. + * Fri Sep 2 2005 Ulrich Drepper <drepper@redhat.com> 0.115-1 - libelf: speed-ups of non-mmap reading. - strings: New program. diff --git a/elfutils/configure b/elfutils/configure index d9514ca4..8380c9e0 100755 --- a/elfutils/configure +++ b/elfutils/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for Red Hat elfutils 0.115. +# Generated by GNU Autoconf 2.59 for Red Hat elfutils 0.116. # # Report bugs to <http://bugzilla.redhat.com/bugzilla/>. # @@ -271,8 +271,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='Red Hat elfutils' PACKAGE_TARNAME='elfutils' -PACKAGE_VERSION='0.115' -PACKAGE_STRING='Red Hat elfutils 0.115' +PACKAGE_VERSION='0.116' +PACKAGE_STRING='Red Hat elfutils 0.116' PACKAGE_BUGREPORT='http://bugzilla.redhat.com/bugzilla/' ac_unique_file="libelf/libelf.h" @@ -741,7 +741,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Red Hat elfutils 0.115 to adapt to many kinds of systems. +\`configure' configures Red Hat elfutils 0.116 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -807,7 +807,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Red Hat elfutils 0.115:";; + short | recursive ) echo "Configuration of Red Hat elfutils 0.116:";; esac cat <<\_ACEOF @@ -932,7 +932,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -Red Hat elfutils configure 0.115 +Red Hat elfutils configure 0.116 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -948,7 +948,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Red Hat elfutils $as_me 0.115, which was +It was created by Red Hat elfutils $as_me 0.116, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -1597,7 +1597,7 @@ fi # Define the identity of the package. PACKAGE='elfutils' - VERSION='0.115' + VERSION='0.116' cat >>confdefs.h <<_ACEOF @@ -4589,7 +4589,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by Red Hat elfutils $as_me 0.115, which was +This file was extended by Red Hat elfutils $as_me 0.116, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4652,7 +4652,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -Red Hat elfutils config.status 0.115 +Red Hat elfutils config.status 0.116 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/elfutils/configure.ac b/elfutils/configure.ac index 547d1182..c2140e26 100644 --- a/elfutils/configure.ac +++ b/elfutils/configure.ac @@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software Foundation, dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. dnl -AC_INIT([Red Hat elfutils],[0.115],[http://bugzilla.redhat.com/bugzilla/], +AC_INIT([Red Hat elfutils],[0.116],[http://bugzilla.redhat.com/bugzilla/], [elfutils]) AC_CONFIG_AUX_DIR([config]) @@ -248,7 +248,7 @@ AH_BOTTOM([ /* Define ALLOW_UNALIGNED if the architecture allows operations on unaligned memory locations. */ -#if defined __i386__ || defined __alpha__ || defined __x86_64__ || defined __ia64__ +#if defined __i386__ || defined __x86_64__ # define ALLOW_UNALIGNED 1 #else # define ALLOW_UNALIGNED 0 diff --git a/elfutils/elfutils.spec b/elfutils/elfutils.spec index 47da48ee..1cebb92e 100644 --- a/elfutils/elfutils.spec +++ b/elfutils/elfutils.spec @@ -2,7 +2,7 @@ %define fake 0 Summary: A collection of utilities and DSOs to handle compiled objects. Name: elfutils -Version: 0.115 +Version: 0.116 Release: 1 %if %{fake} License: GPL @@ -185,6 +185,17 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/libelf.so %changelog +* Mon Oct 31 2005 Ulrich Drepper <drepper@redhat.com> 0.116-1 +- libdw: New functions dwarf_ranges, dwarf_entrypc, dwarf_diecu, d +warf_entry_breakpoints. Removed Dwarf_Func type and functions d +warf_func_name, dwarf_func_lowpc, dwarf_func_highpc, dwarf_func_ +entrypc, dwarf_func_die; dwarf_getfuncs callback now uses Dwarf_ +Die, and dwarf_func_file, dwarf_func_line, dwarf_func_col replac +ed by dwarf_decl_file, dwarf_decl_line, dwarf_decl_column; dwarf +_func_inline, dwarf_func_inline_instances now take Dwarf_Die. Ty +pe Dwarf_Loc renamed to Dwarf_Op; dwarf_getloclist, dwarf_addrlo +clists renamed dwarf_getlocation, dwarf_getlocation_addr. + * Fri Sep 2 2005 Ulrich Drepper <drepper@redhat.com> 0.115-1 - libelf: speed-ups of non-mmap reading. - strings: New program. diff --git a/elfutils/libasm/ChangeLog b/elfutils/libasm/ChangeLog index d4c06348..e25e197b 100644 --- a/elfutils/libasm/ChangeLog +++ b/elfutils/libasm/ChangeLog @@ -1,3 +1,7 @@ +2005-09-02 Ulrich Drepper <drepper@redhat.com> + + * asm_error.c (asm_errmsg): Unify error message. + 2005-08-28 Ulrich Drepper <drepper@redhat.com> * Makefile.am: Use $(LINK) not $(CC) when creating DSO. diff --git a/elfutils/libasm/asm_error.c b/elfutils/libasm/asm_error.c index 3b5aa055..74176cda 100644 --- a/elfutils/libasm/asm_error.c +++ b/elfutils/libasm/asm_error.c @@ -147,7 +147,7 @@ asm_errmsg (error) last_error = global_error; if (error < -1) - return _("Unknown error"); + return _("unknown error"); if (error == 0 && last_error == 0) /* No error. */ return NULL; diff --git a/elfutils/libdw/ChangeLog b/elfutils/libdw/ChangeLog index db069c94..0c8539ef 100644 --- a/elfutils/libdw/ChangeLog +++ b/elfutils/libdw/ChangeLog @@ -1,3 +1,102 @@ +2005-10-27 Roland McGrath <roland@redhat.com> + + * dwarf_entry_breakpoints.c (search_range): Fix binary search code; + don't match end_sequence markers. + + * dwarf_getsrclines.c (compare_lines): Sort end_sequence markers + before normal records at the same address. + * dwarf_getsrc_die.c (dwarf_getsrc_die): Don't match an end_sequence + marker. + +2005-10-26 Roland McGrath <roland@redhat.com> + + * dwarf_getfuncs.c (dwarf_getfuncs): Use Dwarf_Die, not Dwarf_Func. + * dwarf_func_file.c: Renamed to ... + * dwarf_decl_file.c: ... here. + * dwarf_func_col.c: Renamed to ... + * dwarf_decl_column.c: ... here. + * dwarf_func_line.c: Renamed to ... + * dwarf_decl_line.c: ... here. + (dwarf_func_line): Renamed to ... + (dwarf_decl_line): ... this. Take a Dwarf_Die * argument. + (__libdw_func_intval): Renamed __libdw_attr_intval. + * dwarf_func_name.c: File removed. + * dwarf_func_lowpc.c: File removed. + * dwarf_func_highpc.c: File removed. + * dwarf_func_entrypc.c: File removed. + * dwarf_func_die.c: File removed. + * Makefile.am (libdw_a_SOURCES): Updated. + * libdw.h: Update decls. + (Dwarf_Func): Type removed. + * libdwP.h: Update decls. + (struct Dwarf_Func_s): Type removed. + * libdw.map: Updated. + + * libdwP.h (CUDIE): New macro. + * dwarf_getlocation.c (dwarf_getlocation_addr): Use it. + * dwarf_getscopes_die.c (dwarf_getscopes_die): Likewise. + * dwarf_ranges.c (dwarf_ranges): Likewise. + + * dwarf_getloclist.c: Renamed to ... + * dwarf_getlocation.c: ... here. + (getloclist): Renamed to getlocation. + (dwarf_getloclist): Renamed to dwarf_getlocation. + (dwarf_addrloclists): Renamed to dwarf_getlocation_addr. + * Makefile.am (libdw_a_SOURCES): Updated. + * libdw.h (dwarf_getloclist): Renamed to dwarf_getlocation. + (dwarf_addrloclists): Renamed dwarf_getlocation_addr. + (Dwarf_Loc): Renamed Dwarf_Op. + * libdwP.h (struct loc_s): Update use. + * libdw.map: Update map. + + * dwarf_entry_breakpoints.c: Use the second line record within the + function, regardless of its source location data. + +2005-10-25 Roland McGrath <roland@redhat.com> + + * dwarf_entry_breakpoints.c: Fall back to entrypc for contiguous too. + + * libdw.map: Add dwarf_entrypc, dwarf_entry_breakpoints. + +2005-10-14 Roland McGrath <roland@redhat.com> + + * dwarf_diecu.c (dwarf_diecu): New file. + * Makefile.am (libdw_a_SOURCES): Add it. + * libdw.h: Declare dwarf_diecu. + * libdw.map: Export it. + + * libdw.map: Bump to 0.116; export dwarf_ranges. + +2005-09-20 Roland McGrath <roland@redhat.com> + + * dwarf_haspc.c: Use dwarf_ranges. + * dwarf_entry_breakpoints.c: Likewise. + + * dwarf_ranges.c: New file. + * Makefile.am (libdw_a_SOURCES): Add it. + * libdw.h: Declare dwarf_ranges. + * libdwP.h: Add INTDECL. + +2005-09-14 Roland McGrath <roland@redhat.com> + + * dwarf_entry_breakpoints.c (dwarf_entry_breakpoints): Fix braino in + prologue_end marker scanning loop. + +2005-09-11 Roland McGrath <roland@redhat.com> + + * dwarf.h: Comment typo fix. + +2005-09-07 Roland McGrath <roland@redhat.com> + + * dwarf_entry_breakpoints.c: New file. + * Makefile.am (libdw_a_SOURCES): Add it. + * libdw.h: Declare dwarf_entry_breakpoints. + + * dwarf_entrypc.c: New file. + * Makefile.am (libdw_a_SOURCES): Add it. + * libdw.h: Declare dwarf_entrypc. + * libdwP.h: Add INTDECL. + 2005-08-28 Ulrich Drepper <drepper@redhat.com> * Makefile.am: Use $(LINK) not $(CC) when creating DSO. diff --git a/elfutils/libdw/Makefile.am b/elfutils/libdw/Makefile.am index a35f5dcc..6e53312e 100644 --- a/elfutils/libdw/Makefile.am +++ b/elfutils/libdw/Makefile.am @@ -42,10 +42,11 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ dwarf_attr_integrate.c dwarf_hasattr_integrate.c \ dwarf_child.c dwarf_haschildren.c dwarf_formaddr.c \ dwarf_formudata.c dwarf_formsdata.c dwarf_lowpc.c \ - dwarf_haspc.c dwarf_highpc.c \ + dwarf_entrypc.c dwarf_haspc.c dwarf_highpc.c dwarf_ranges.c \ dwarf_formref.c dwarf_formref_die.c dwarf_siblingof.c \ - dwarf_dieoffset.c dwarf_cuoffset.c dwarf_hasattr.c \ - dwarf_hasform.c dwarf_whatform.c dwarf_whatattr.c \ + dwarf_dieoffset.c dwarf_cuoffset.c dwarf_diecu.c \ + dwarf_hasattr.c dwarf_hasform.c \ + dwarf_whatform.c dwarf_whatattr.c \ dwarf_bytesize.c dwarf_arrayorder.c dwarf_bitsize.c \ dwarf_bitoffset.c dwarf_srclang.c dwarf_getabbrevtag.c \ dwarf_getabbrevcode.c dwarf_abbrevhaschildren.c \ @@ -58,18 +59,17 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ dwarf_lineprologueend.c dwarf_lineepiloguebegin.c \ dwarf_onesrcline.c dwarf_formblock.c \ dwarf_getsrcfiles.c dwarf_filesrc.c \ - dwarf_getloclist.c dwarf_getstring.c dwarf_offabbrev.c \ + dwarf_getlocation.c dwarf_getstring.c dwarf_offabbrev.c \ dwarf_getaranges.c dwarf_onearange.c dwarf_getarangeinfo.c \ dwarf_getarange_addr.c dwarf_getattrs.c dwarf_formflag.c \ dwarf_getmacros.c dwarf_macro_opcode.c dwarf_macro_param1.c \ dwarf_macro_param2.c dwarf_addrdie.c \ - dwarf_getfuncs.c dwarf_func_name.c dwarf_func_lowpc.c \ - dwarf_func_highpc.c dwarf_func_entrypc.c dwarf_func_file.c \ - dwarf_func_line.c dwarf_func_col.c dwarf_func_die.c \ + dwarf_getfuncs.c \ + dwarf_decl_file.c dwarf_decl_line.c dwarf_decl_column.c \ dwarf_func_inline.c dwarf_getsrc_file.c \ libdw_findcu.c libdw_form.c libdw_alloc.c memory-access.c \ - libdw_visit_scopes.c - + libdw_visit_scopes.c \ + dwarf_entry_breakpoints.c if !MUDFLAP libdw_pic_a_SOURCES = diff --git a/elfutils/libdw/Makefile.in b/elfutils/libdw/Makefile.in index 32323433..2061fc84 100644 --- a/elfutils/libdw/Makefile.in +++ b/elfutils/libdw/Makefile.in @@ -79,16 +79,17 @@ am_libdw_a_OBJECTS = dwarf_begin.$(OBJEXT) dwarf_begin_elf.$(OBJEXT) \ dwarf_hasattr_integrate.$(OBJEXT) dwarf_child.$(OBJEXT) \ dwarf_haschildren.$(OBJEXT) dwarf_formaddr.$(OBJEXT) \ dwarf_formudata.$(OBJEXT) dwarf_formsdata.$(OBJEXT) \ - dwarf_lowpc.$(OBJEXT) dwarf_haspc.$(OBJEXT) \ - dwarf_highpc.$(OBJEXT) dwarf_formref.$(OBJEXT) \ + dwarf_lowpc.$(OBJEXT) dwarf_entrypc.$(OBJEXT) \ + dwarf_haspc.$(OBJEXT) dwarf_highpc.$(OBJEXT) \ + dwarf_ranges.$(OBJEXT) dwarf_formref.$(OBJEXT) \ dwarf_formref_die.$(OBJEXT) dwarf_siblingof.$(OBJEXT) \ dwarf_dieoffset.$(OBJEXT) dwarf_cuoffset.$(OBJEXT) \ - dwarf_hasattr.$(OBJEXT) dwarf_hasform.$(OBJEXT) \ - dwarf_whatform.$(OBJEXT) dwarf_whatattr.$(OBJEXT) \ - dwarf_bytesize.$(OBJEXT) dwarf_arrayorder.$(OBJEXT) \ - dwarf_bitsize.$(OBJEXT) dwarf_bitoffset.$(OBJEXT) \ - dwarf_srclang.$(OBJEXT) dwarf_getabbrevtag.$(OBJEXT) \ - dwarf_getabbrevcode.$(OBJEXT) \ + dwarf_diecu.$(OBJEXT) dwarf_hasattr.$(OBJEXT) \ + dwarf_hasform.$(OBJEXT) dwarf_whatform.$(OBJEXT) \ + dwarf_whatattr.$(OBJEXT) dwarf_bytesize.$(OBJEXT) \ + dwarf_arrayorder.$(OBJEXT) dwarf_bitsize.$(OBJEXT) \ + dwarf_bitoffset.$(OBJEXT) dwarf_srclang.$(OBJEXT) \ + dwarf_getabbrevtag.$(OBJEXT) dwarf_getabbrevcode.$(OBJEXT) \ dwarf_abbrevhaschildren.$(OBJEXT) dwarf_getattrcnt.$(OBJEXT) \ dwarf_getabbrevattr.$(OBJEXT) dwarf_getsrclines.$(OBJEXT) \ dwarf_getsrc_die.$(OBJEXT) dwarf_getscopes.$(OBJEXT) \ @@ -100,7 +101,7 @@ am_libdw_a_OBJECTS = dwarf_begin.$(OBJEXT) dwarf_begin_elf.$(OBJEXT) \ dwarf_lineprologueend.$(OBJEXT) \ dwarf_lineepiloguebegin.$(OBJEXT) dwarf_onesrcline.$(OBJEXT) \ dwarf_formblock.$(OBJEXT) dwarf_getsrcfiles.$(OBJEXT) \ - dwarf_filesrc.$(OBJEXT) dwarf_getloclist.$(OBJEXT) \ + dwarf_filesrc.$(OBJEXT) dwarf_getlocation.$(OBJEXT) \ dwarf_getstring.$(OBJEXT) dwarf_offabbrev.$(OBJEXT) \ dwarf_getaranges.$(OBJEXT) dwarf_onearange.$(OBJEXT) \ dwarf_getarangeinfo.$(OBJEXT) dwarf_getarange_addr.$(OBJEXT) \ @@ -108,14 +109,12 @@ am_libdw_a_OBJECTS = dwarf_begin.$(OBJEXT) dwarf_begin_elf.$(OBJEXT) \ dwarf_getmacros.$(OBJEXT) dwarf_macro_opcode.$(OBJEXT) \ dwarf_macro_param1.$(OBJEXT) dwarf_macro_param2.$(OBJEXT) \ dwarf_addrdie.$(OBJEXT) dwarf_getfuncs.$(OBJEXT) \ - dwarf_func_name.$(OBJEXT) dwarf_func_lowpc.$(OBJEXT) \ - dwarf_func_highpc.$(OBJEXT) dwarf_func_entrypc.$(OBJEXT) \ - dwarf_func_file.$(OBJEXT) dwarf_func_line.$(OBJEXT) \ - dwarf_func_col.$(OBJEXT) dwarf_func_die.$(OBJEXT) \ - dwarf_func_inline.$(OBJEXT) dwarf_getsrc_file.$(OBJEXT) \ - libdw_findcu.$(OBJEXT) libdw_form.$(OBJEXT) \ - libdw_alloc.$(OBJEXT) memory-access.$(OBJEXT) \ - libdw_visit_scopes.$(OBJEXT) + dwarf_decl_file.$(OBJEXT) dwarf_decl_line.$(OBJEXT) \ + dwarf_decl_column.$(OBJEXT) dwarf_func_inline.$(OBJEXT) \ + dwarf_getsrc_file.$(OBJEXT) libdw_findcu.$(OBJEXT) \ + libdw_form.$(OBJEXT) libdw_alloc.$(OBJEXT) \ + memory-access.$(OBJEXT) libdw_visit_scopes.$(OBJEXT) \ + dwarf_entry_breakpoints.$(OBJEXT) libdw_a_OBJECTS = $(am_libdw_a_OBJECTS) libdw_pic_a_AR = $(AR) $(ARFLAGS) libdw_pic_a_LIBADD = @@ -266,10 +265,11 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ dwarf_attr_integrate.c dwarf_hasattr_integrate.c \ dwarf_child.c dwarf_haschildren.c dwarf_formaddr.c \ dwarf_formudata.c dwarf_formsdata.c dwarf_lowpc.c \ - dwarf_haspc.c dwarf_highpc.c \ + dwarf_entrypc.c dwarf_haspc.c dwarf_highpc.c dwarf_ranges.c \ dwarf_formref.c dwarf_formref_die.c dwarf_siblingof.c \ - dwarf_dieoffset.c dwarf_cuoffset.c dwarf_hasattr.c \ - dwarf_hasform.c dwarf_whatform.c dwarf_whatattr.c \ + dwarf_dieoffset.c dwarf_cuoffset.c dwarf_diecu.c \ + dwarf_hasattr.c dwarf_hasform.c \ + dwarf_whatform.c dwarf_whatattr.c \ dwarf_bytesize.c dwarf_arrayorder.c dwarf_bitsize.c \ dwarf_bitoffset.c dwarf_srclang.c dwarf_getabbrevtag.c \ dwarf_getabbrevcode.c dwarf_abbrevhaschildren.c \ @@ -282,17 +282,17 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ dwarf_lineprologueend.c dwarf_lineepiloguebegin.c \ dwarf_onesrcline.c dwarf_formblock.c \ dwarf_getsrcfiles.c dwarf_filesrc.c \ - dwarf_getloclist.c dwarf_getstring.c dwarf_offabbrev.c \ + dwarf_getlocation.c dwarf_getstring.c dwarf_offabbrev.c \ dwarf_getaranges.c dwarf_onearange.c dwarf_getarangeinfo.c \ dwarf_getarange_addr.c dwarf_getattrs.c dwarf_formflag.c \ dwarf_getmacros.c dwarf_macro_opcode.c dwarf_macro_param1.c \ dwarf_macro_param2.c dwarf_addrdie.c \ - dwarf_getfuncs.c dwarf_func_name.c dwarf_func_lowpc.c \ - dwarf_func_highpc.c dwarf_func_entrypc.c dwarf_func_file.c \ - dwarf_func_line.c dwarf_func_col.c dwarf_func_die.c \ + dwarf_getfuncs.c \ + dwarf_decl_file.c dwarf_decl_line.c dwarf_decl_column.c \ dwarf_func_inline.c dwarf_getsrc_file.c \ libdw_findcu.c libdw_form.c libdw_alloc.c memory-access.c \ - libdw_visit_scopes.c + libdw_visit_scopes.c \ + dwarf_entry_breakpoints.c @MUDFLAP_FALSE@libdw_pic_a_SOURCES = @MUDFLAP_FALSE@am_libdw_pic_a_OBJECTS = $(libdw_a_SOURCES:.c=.os) @@ -400,9 +400,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_bytesize.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_child.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_cuoffset.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_decl_column.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_decl_file.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_decl_line.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_diecu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_diename.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_dieoffset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_end.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_entry_breakpoints.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_entrypc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_filesrc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_formaddr.Po@am__quote@ @@ -413,15 +419,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_formsdata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_formstring.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_formudata.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_col.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_die.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_entrypc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_file.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_highpc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_inline.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_line.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_lowpc.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_func_name.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getabbrev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getabbrevattr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getabbrevcode.Po@am__quote@ @@ -433,7 +431,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getattrs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getelf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getfuncs.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getloclist.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getlocation.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getmacros.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getpubnames.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_getscopes.Po@am__quote@ @@ -468,6 +466,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_offdie.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_onearange.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_onesrcline.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_ranges.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_siblingof.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_srclang.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_tag.Po@am__quote@ diff --git a/elfutils/libdw/dwarf.h b/elfutils/libdw/dwarf.h index 2268256f..bf53f51d 100644 --- a/elfutils/libdw/dwarf.h +++ b/elfutils/libdw/dwarf.h @@ -516,7 +516,7 @@ enum }; -/* DWARF extended opcide encodings. */ +/* DWARF extended opcode encodings. */ enum { DW_LNE_end_sequence = 1, diff --git a/elfutils/libdw/dwarf_func_col.c b/elfutils/libdw/dwarf_decl_column.c index feda1435..aae232fa 100644 --- a/elfutils/libdw/dwarf_func_col.c +++ b/elfutils/libdw/dwarf_decl_column.c @@ -1,4 +1,4 @@ -/* Get line number of beginning of given function. +/* Get column number of beginning of given declaration. Copyright (C) 2005 Red Hat, Inc. Written by Ulrich Drepper <drepper@redhat.com>, 2005. @@ -21,7 +21,7 @@ int -dwarf_func_col (Dwarf_Func *func, int *colp) +dwarf_decl_column (Dwarf_Die *decl, int *colp) { - return __libdw_func_intval (func, colp, DW_AT_decl_column); + return __libdw_attr_intval (decl, colp, DW_AT_decl_column); } diff --git a/elfutils/libdw/dwarf_func_file.c b/elfutils/libdw/dwarf_decl_file.c index d5302df0..50a3ab3a 100644 --- a/elfutils/libdw/dwarf_func_file.c +++ b/elfutils/libdw/dwarf_decl_file.c @@ -22,11 +22,10 @@ const char * -dwarf_func_file (Dwarf_Func *func) +dwarf_decl_file (Dwarf_Die *die) { Dwarf_Attribute attr_mem; Dwarf_Sword idx = 0; - Dwarf_Die *die = func->die; if (INTUSE(dwarf_formsdata) (INTUSE(dwarf_attr) (die, DW_AT_decl_file, &attr_mem), &idx) != 0) @@ -40,7 +39,7 @@ dwarf_func_file (Dwarf_Func *func) } /* Get the array of source files for the CU. */ - struct Dwarf_CU *cu = die->cu; + struct Dwarf_CU *cu = die->cu; if (cu->lines == NULL) { Dwarf_Lines *lines; @@ -48,7 +47,7 @@ dwarf_func_file (Dwarf_Func *func) /* Let the more generic function do the work. It'll create more data but that will be needed in an real program anyway. */ - (void) INTUSE(dwarf_getsrclines) (func->cudie, &lines, &nlines); + (void) INTUSE(dwarf_getsrclines) (&CUDIE (cu), &lines, &nlines); assert (cu->lines != NULL); } diff --git a/elfutils/libdw/dwarf_func_line.c b/elfutils/libdw/dwarf_decl_line.c index 6259b9f1..44a95243 100644 --- a/elfutils/libdw/dwarf_func_line.c +++ b/elfutils/libdw/dwarf_decl_line.c @@ -23,19 +23,19 @@ int -dwarf_func_line (Dwarf_Func *func, int *linep) +dwarf_decl_line (Dwarf_Die *func, int *linep) { - return __libdw_func_intval (func, linep, DW_AT_decl_line); + return __libdw_attr_intval (func, linep, DW_AT_decl_line); } int internal_function -__libdw_func_intval (Dwarf_Func *func, int *linep, int attval) +__libdw_attr_intval (Dwarf_Die *die, int *linep, int attval) { Dwarf_Attribute attr_mem; Dwarf_Sword line; - int res = INTUSE(dwarf_formsdata) (INTUSE(dwarf_attr) (func->die, attval, + int res = INTUSE(dwarf_formsdata) (INTUSE(dwarf_attr) (die, attval, &attr_mem), &line); if (res == 0) { diff --git a/elfutils/libdw/dwarf_diecu.c b/elfutils/libdw/dwarf_diecu.c new file mode 100644 index 00000000..5b0f1b8c --- /dev/null +++ b/elfutils/libdw/dwarf_diecu.c @@ -0,0 +1,46 @@ +/* Return CU DIE containing given DIE. + Copyright (C) 2005 Red Hat, Inc. + + This program is Open Source software; you can redistribute it and/or + modify it under the terms of the Open Software License version 1.0 as + published by the Open Source Initiative. + + You should have received a copy of the Open Software License along + with this program; if not, you may obtain a copy of the Open Software + License version 1.0 from http://www.opensource.org/licenses/osl.php or + by writing the Open Source Initiative c/o Lawrence Rosen, Esq., + 3001 King Ranch Road, Ukiah, CA 95482. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <string.h> +#include "libdwP.h" + + +Dwarf_Die * +dwarf_diecu (die, result, address_sizep, offset_sizep) + Dwarf_Die *die; + Dwarf_Die *result; + uint8_t *address_sizep; + uint8_t *offset_sizep; +{ + if (die == NULL) + return NULL; + + /* Clear the entire DIE structure. This signals we have not yet + determined any of the information. */ + memset (result, '\0', sizeof (Dwarf_Die)); + + result->addr = ((char *) die->cu->dbg->sectiondata[IDX_debug_info]->d_buf + + die->cu->start + 3 * die->cu->offset_size - 4 + 3); + result->cu = die->cu; + + if (address_sizep != NULL) + *address_sizep = die->cu->address_size; + if (offset_sizep != NULL) + *offset_sizep = die->cu->offset_size; + + return result; +} diff --git a/elfutils/libdw/dwarf_entry_breakpoints.c b/elfutils/libdw/dwarf_entry_breakpoints.c new file mode 100644 index 00000000..30f03fd6 --- /dev/null +++ b/elfutils/libdw/dwarf_entry_breakpoints.c @@ -0,0 +1,147 @@ +/* Find entry breakpoint locations for a function. + Copyright (C) 2005 Red Hat, Inc. + + This program is Open Source software; you can redistribute it and/or + modify it under the terms of the Open Software License version 1.0 as + published by the Open Source Initiative. + + You should have received a copy of the Open Software License along + with this program; if not, you may obtain a copy of the Open Software + License version 1.0 from http://www.opensource.org/licenses/osl.php or + by writing the Open Source Initiative c/o Lawrence Rosen, Esq., + 3001 King Ranch Road, Ukiah, CA 95482. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif +#include "libdwP.h" +#include <dwarf.h> +#include <stdlib.h> + + +int +dwarf_entry_breakpoints (die, bkpts) + Dwarf_Die *die; + Dwarf_Addr **bkpts; +{ + int nbkpts = 0; + *bkpts = NULL; + + /* Add one breakpoint location to the result vector. */ + inline int add_bkpt (Dwarf_Addr pc) + { + Dwarf_Addr *newlist = realloc (*bkpts, ++nbkpts * sizeof newlist[0]); + if (newlist == NULL) + { + free (*bkpts); + *bkpts = NULL; + __libdw_seterrno (DWARF_E_NOMEM); + return -1; + } + newlist[nbkpts - 1] = pc; + *bkpts = newlist; + return nbkpts; + } + + /* Fallback result, break at the entrypc/lowpc value. */ + inline int entrypc_bkpt (void) + { + Dwarf_Addr pc; + return INTUSE(dwarf_entrypc) (die, &pc) < 0 ? -1 : add_bkpt (pc); + } + + /* Fetch the CU's line records to look for this DIE's addresses. */ + Dwarf_Die cudie = + { + .cu = die->cu, + .addr = ((char *) die->cu->dbg->sectiondata[IDX_debug_info]->d_buf + + die->cu->start + 3 * die->cu->offset_size - 4 + 3), + }; + Dwarf_Lines *lines; + size_t nlines; + if (INTUSE(dwarf_getsrclines) (&cudie, &lines, &nlines) < 0) + { + int error = INTUSE (dwarf_errno) (); + if (error == DWARF_E_NO_DEBUG_LINE) + return entrypc_bkpt (); + __libdw_seterrno (error); + return -1; + } + + /* Search a contiguous PC range for prologue-end markers. + If DWARF, look for proper markers. + Failing that, if ADHOC, look for the ad hoc convention. */ + inline int search_range (Dwarf_Addr low, Dwarf_Addr high, + bool dwarf, bool adhoc) + { + size_t l = 0, u = nlines; + while (l < u) + { + size_t idx = (l + u) / 2; + if (lines->info[idx].addr < low) + l = idx + 1; + else if (lines->info[idx].addr > low) + u = idx; + else if (lines->info[idx].end_sequence) + l = idx + 1; + else + { + l = idx; + break; + } + } + if (l < u) + { + if (dwarf) + for (size_t i = l; i < u && lines->info[i].addr < high; ++i) + if (lines->info[i].prologue_end + && add_bkpt (lines->info[i].addr) < 0) + return -1; + if (adhoc && nbkpts == 0) + while (++l < nlines && lines->info[l].addr < high) + if (!lines->info[l].end_sequence) + return add_bkpt (lines->info[l].addr); + return nbkpts; + } + __libdw_seterrno (DWARF_E_INVALID_DWARF); + return -1; + } + + /* Search each contiguous address range for DWARF prologue_end markers. */ + + Dwarf_Addr base; + Dwarf_Addr begin; + Dwarf_Addr end; + ptrdiff_t offset = INTUSE(dwarf_ranges) (die, 0, &base, &begin, &end); + if (offset < 0) + return -1; + + /* Most often there is a single contiguous PC range for the DIE. */ + if (offset == 1) + return search_range (begin, end, true, true) ?: entrypc_bkpt (); + + Dwarf_Addr lowpc = (Dwarf_Addr) -1l; + Dwarf_Addr highpc = (Dwarf_Addr) -1l; + while (offset > 0) + { + /* We have an address range entry. */ + if (search_range (begin, end, true, false) < 0) + return -1; + + if (begin < lowpc) + { + lowpc = begin; + highpc = end; + } + + offset = INTUSE(dwarf_ranges) (die, offset, &base, &begin, &end); + } + + /* If we didn't find any proper DWARF markers, then look in the + lowest-addressed range for an ad hoc marker. Failing that, + fall back to just using the entrypc value. */ + return (nbkpts + ?: (lowpc == (Dwarf_Addr) -1l ? 0 + : search_range (lowpc, highpc, false, true)) + ?: entrypc_bkpt ()); +} diff --git a/elfutils/libdw/dwarf_func_entrypc.c b/elfutils/libdw/dwarf_entrypc.c index 6b5103e0..61a1d4be 100644 --- a/elfutils/libdw/dwarf_func_entrypc.c +++ b/elfutils/libdw/dwarf_entrypc.c @@ -1,6 +1,5 @@ -/* Get entry address of function. - Copyright (C) 2005 Red Hat, Inc. - Written by Ulrich Drepper <drepper@redhat.com>, 2005. +/* Return entry PC attribute of DIE. + Copyright (C) 2003, 2005 Red Hat, Inc. This program is Open Source software; you can redistribute it and/or modify it under the terms of the Open Software License version 1.0 as @@ -21,13 +20,16 @@ int -dwarf_func_entrypc (Dwarf_Func *func, Dwarf_Addr *return_addr) +dwarf_entrypc (die, return_addr) + Dwarf_Die *die; + Dwarf_Addr *return_addr; { Dwarf_Attribute attr_mem; - Dwarf_Attribute *attr = INTUSE(dwarf_attr) (func->die, DW_AT_entry_pc, - &attr_mem); - if (attr != NULL) - return INTUSE(dwarf_formaddr) (attr, return_addr); - return INTUSE(dwarf_lowpc) (func->die, return_addr); + return INTUSE(dwarf_formaddr) (INTUSE(dwarf_attr) (die, DW_AT_entry_pc, + &attr_mem) + ?: INTUSE(dwarf_attr) (die, DW_AT_low_pc, + &attr_mem), + return_addr); } +INTDEF(dwarf_entrypc) diff --git a/elfutils/libdw/dwarf_func_die.c b/elfutils/libdw/dwarf_func_die.c deleted file mode 100644 index 73c65d4d..00000000 --- a/elfutils/libdw/dwarf_func_die.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Get definition DIE of function. - Copyright (C) 2005 Red Hat, Inc. - - This program is Open Source software; you can redistribute it and/or - modify it under the terms of the Open Software License version 1.0 as - published by the Open Source Initiative. - - You should have received a copy of the Open Software License along - with this program; if not, you may obtain a copy of the Open Software - License version 1.0 from http://www.opensource.org/licenses/osl.php or - by writing the Open Source Initiative c/o Lawrence Rosen, Esq., - 3001 King Ranch Road, Ukiah, CA 95482. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <dwarf.h> -#include "libdwP.h" - - -Dwarf_Die * -dwarf_func_die (Dwarf_Func *func, Dwarf_Die *die_mem) -{ - *die_mem = *func->die; - return die_mem; -} diff --git a/elfutils/libdw/dwarf_func_highpc.c b/elfutils/libdw/dwarf_func_highpc.c deleted file mode 100644 index c5d2eec3..00000000 --- a/elfutils/libdw/dwarf_func_highpc.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Get end address of function. - Copyright (C) 2005 Red Hat, Inc. - Written by Ulrich Drepper <drepper@redhat.com>, 2005. - - This program is Open Source software; you can redistribute it and/or - modify it under the terms of the Open Software License version 1.0 as - published by the Open Source Initiative. - - You should have received a copy of the Open Software License along - with this program; if not, you may obtain a copy of the Open Software - License version 1.0 from http://www.opensource.org/licenses/osl.php or - by writing the Open Source Initiative c/o Lawrence Rosen, Esq., - 3001 King Ranch Road, Ukiah, CA 95482. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "libdwP.h" - - -int -dwarf_func_highpc (Dwarf_Func *func, Dwarf_Addr *return_addr) -{ - return INTUSE(dwarf_highpc) (func->die, return_addr); -} diff --git a/elfutils/libdw/dwarf_func_inline.c b/elfutils/libdw/dwarf_func_inline.c index 4472515d..99e656ff 100644 --- a/elfutils/libdw/dwarf_func_inline.c +++ b/elfutils/libdw/dwarf_func_inline.c @@ -39,11 +39,11 @@ scope_visitor (unsigned int depth __attribute__ ((unused)), } int -dwarf_func_inline (Dwarf_Func *func) +dwarf_func_inline (Dwarf_Die *func) { Dwarf_Attribute attr_mem; Dwarf_Word val; - if (INTUSE(dwarf_formudata) (INTUSE(dwarf_attr) (func->die, DW_AT_inline, + if (INTUSE(dwarf_formudata) (INTUSE(dwarf_attr) (func, DW_AT_inline, &attr_mem), &val) == 0) switch (val) @@ -63,11 +63,11 @@ dwarf_func_inline (Dwarf_Func *func) } int -dwarf_func_inline_instances (Dwarf_Func *func, +dwarf_func_inline_instances (Dwarf_Die *func, int (*callback) (Dwarf_Die *, void *), void *arg) { - struct visitor_info v = { func->die->addr, callback, arg }; - struct Dwarf_Die_Chain cu = { .die = *func->cudie, .parent = NULL }; + struct visitor_info v = { func->addr, callback, arg }; + struct Dwarf_Die_Chain cu = { .die = CUDIE (func->cu), .parent = NULL }; return __libdw_visit_scopes (0, &cu, &scope_visitor, NULL, &v); } diff --git a/elfutils/libdw/dwarf_func_lowpc.c b/elfutils/libdw/dwarf_func_lowpc.c deleted file mode 100644 index d364e6c6..00000000 --- a/elfutils/libdw/dwarf_func_lowpc.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Get start address of function. - Copyright (C) 2005 Red Hat, Inc. - Written by Ulrich Drepper <drepper@redhat.com>, 2005. - - This program is Open Source software; you can redistribute it and/or - modify it under the terms of the Open Software License version 1.0 as - published by the Open Source Initiative. - - You should have received a copy of the Open Software License along - with this program; if not, you may obtain a copy of the Open Software - License version 1.0 from http://www.opensource.org/licenses/osl.php or - by writing the Open Source Initiative c/o Lawrence Rosen, Esq., - 3001 King Ranch Road, Ukiah, CA 95482. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include "libdwP.h" - - -int -dwarf_func_lowpc (Dwarf_Func *func, Dwarf_Addr *return_addr) -{ - return INTUSE(dwarf_lowpc) (func->die, return_addr); -} diff --git a/elfutils/libdw/dwarf_func_name.c b/elfutils/libdw/dwarf_func_name.c deleted file mode 100644 index c6912aa6..00000000 --- a/elfutils/libdw/dwarf_func_name.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Get function name. - Copyright (C) 2005 Red Hat, Inc. - Written by Ulrich Drepper <drepper@redhat.com>, 2005. - - This program is Open Source software; you can redistribute it and/or - modify it under the terms of the Open Software License version 1.0 as - published by the Open Source Initiative. - - You should have received a copy of the Open Software License along - with this program; if not, you may obtain a copy of the Open Software - License version 1.0 from http://www.opensource.org/licenses/osl.php or - by writing the Open Source Initiative c/o Lawrence Rosen, Esq., - 3001 King Ranch Road, Ukiah, CA 95482. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#include <dwarf.h> -#include "libdwP.h" - - -const char * -dwarf_func_name (Dwarf_Func *func) -{ - return INTUSE(dwarf_diename) (func->die); -} diff --git a/elfutils/libdw/dwarf_getfuncs.c b/elfutils/libdw/dwarf_getfuncs.c index 149f1860..f967678b 100644 --- a/elfutils/libdw/dwarf_getfuncs.c +++ b/elfutils/libdw/dwarf_getfuncs.c @@ -21,7 +21,7 @@ ptrdiff_t -dwarf_getfuncs (Dwarf_Die *cudie, int (*callback) (Dwarf_Func *, void *), +dwarf_getfuncs (Dwarf_Die *cudie, int (*callback) (Dwarf_Die *, void *), void *arg, ptrdiff_t offset) { if (unlikely (cudie == NULL @@ -45,12 +45,7 @@ dwarf_getfuncs (Dwarf_Die *cudie, int (*callback) (Dwarf_Func *, void *), { if (INTUSE(dwarf_tag) (die) == DW_TAG_subprogram) { - Dwarf_Func fct; - - fct.die = die; - fct.cudie = cudie; - - if (callback (&fct, arg) != DWARF_CB_OK) + if (callback (die, arg) != DWARF_CB_OK) return INTUSE(dwarf_dieoffset) (die); } diff --git a/elfutils/libdw/dwarf_getloclist.c b/elfutils/libdw/dwarf_getlocation.c index ab7c3869..4a75f97d 100644 --- a/elfutils/libdw/dwarf_getloclist.c +++ b/elfutils/libdw/dwarf_getlocation.c @@ -76,8 +76,8 @@ loc_compare (const void *p1, const void *p2) } static int -getloclist (struct Dwarf_CU *cu, const Dwarf_Block *block, - Dwarf_Loc **llbuf, size_t *listlen) +getlocation (struct Dwarf_CU *cu, const Dwarf_Block *block, + Dwarf_Op **llbuf, size_t *listlen) { Dwarf *dbg = cu->dbg; @@ -269,7 +269,7 @@ getloclist (struct Dwarf_CU *cu, const Dwarf_Block *block, } /* Allocate the array. */ - Dwarf_Loc *result = libdw_alloc (dbg, Dwarf_Loc, sizeof (Dwarf_Loc), n); + Dwarf_Op *result = libdw_alloc (dbg, Dwarf_Op, sizeof (Dwarf_Op), n); /* Store the result. */ *llbuf = result; @@ -303,9 +303,9 @@ getloclist (struct Dwarf_CU *cu, const Dwarf_Block *block, } int -dwarf_getloclist (attr, llbuf, listlen) +dwarf_getlocation (attr, llbuf, listlen) Dwarf_Attribute *attr; - Dwarf_Loc **llbuf; + Dwarf_Op **llbuf; size_t *listlen; { if (! attr_ok (attr)) @@ -316,14 +316,14 @@ dwarf_getloclist (attr, llbuf, listlen) if (INTUSE(dwarf_formblock) (attr, &block) != 0) return -1; - return getloclist (attr->cu, &block, llbuf, listlen); + return getlocation (attr->cu, &block, llbuf, listlen); } int -dwarf_addrloclists (attr, address, llbufs, listlens, maxlocs) +dwarf_getlocation_addr (attr, address, llbufs, listlens, maxlocs) Dwarf_Attribute *attr; Dwarf_Addr address; - Dwarf_Loc **llbufs; + Dwarf_Op **llbufs; size_t *listlens; size_t maxlocs; { @@ -340,7 +340,7 @@ dwarf_addrloclists (attr, address, llbufs, listlens, maxlocs) if (maxlocs == 0) return 0; if (llbufs != NULL && - getloclist (attr->cu, &block, &llbufs[0], &listlens[0]) != 0) + getlocation (attr->cu, &block, &llbufs[0], &listlens[0]) != 0) return -1; return listlens[0] == 0 ? 0 : 1; } @@ -366,13 +366,7 @@ dwarf_addrloclists (attr, address, llbufs, listlens, maxlocs) /* Fetch the CU's base address. */ Dwarf_Addr base; - Dwarf_Die cudie = - { - .cu = attr->cu, - .addr = ((char *) attr->cu->dbg->sectiondata[IDX_debug_info]->d_buf - + attr->cu->start + 3 * attr->cu->offset_size - 4 + 3), - }; - + Dwarf_Die cudie = CUDIE (attr->cu); /* Find the base address of the compilation unit. It will normally be specified by DW_AT_low_pc. In DWARF-3 draft 4, @@ -443,8 +437,9 @@ dwarf_addrloclists (attr, address, llbufs, listlens, maxlocs) if (address >= base + begin && address < base + end) { /* This one matches the address. */ - if (llbufs != NULL && getloclist (attr->cu, &block, - &llbufs[got], &listlens[got]) != 0) + if (llbufs != NULL + && getlocation (attr->cu, &block, + &llbufs[got], &listlens[got]) != 0) return -1; ++got; } diff --git a/elfutils/libdw/dwarf_getscopes_die.c b/elfutils/libdw/dwarf_getscopes_die.c index bdcee354..6e46f666 100644 --- a/elfutils/libdw/dwarf_getscopes_die.c +++ b/elfutils/libdw/dwarf_getscopes_die.c @@ -50,17 +50,7 @@ dwarf_getscopes_die (Dwarf_Die *die, Dwarf_Die **scopes) if (die == NULL) return -1; - struct Dwarf_Die_Chain cu = - { - .parent = NULL, - .die = - { - .cu = die->cu, - .addr = ((char *) die->cu->dbg->sectiondata[IDX_debug_info]->d_buf - + die->cu->start + 3 * die->cu->offset_size - 4 + 3), - } - }; - + struct Dwarf_Die_Chain cu = { .die = CUDIE (die->cu), .parent = NULL }; void *info = die->addr; int result = __libdw_visit_scopes (1, &cu, &scope_visitor, NULL, &info); if (result > 0) diff --git a/elfutils/libdw/dwarf_getscopevar.c b/elfutils/libdw/dwarf_getscopevar.c index 3ceb292d..fcac1987 100644 --- a/elfutils/libdw/dwarf_getscopevar.c +++ b/elfutils/libdw/dwarf_getscopevar.c @@ -25,13 +25,7 @@ static int getfiles (Dwarf_Die *die, Dwarf_Files **files) { - Dwarf_Die cudie = - { - .cu = die->cu, - .addr = ((char *) die->cu->dbg->sectiondata[IDX_debug_info]->d_buf - + 3 * die->cu->offset_size - 4 + 3), - }; - return INTUSE(dwarf_getsrcfiles) (&cudie, files, NULL); + return INTUSE(dwarf_getsrcfiles) (&CUDIE (die->cu), files, NULL); } /* Fetch an attribute that should have a constant integer form. */ diff --git a/elfutils/libdw/dwarf_getsrc_die.c b/elfutils/libdw/dwarf_getsrc_die.c index e3ce4f2a..753d48f7 100644 --- a/elfutils/libdw/dwarf_getsrc_die.c +++ b/elfutils/libdw/dwarf_getsrc_die.c @@ -36,7 +36,7 @@ dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr) size_t idx = (l + u) / 2; if (addr < lines->info[idx].addr) u = idx; - else if (addr > lines->info[idx].addr) + else if (addr > lines->info[idx].addr || lines->info[idx].end_sequence) l = idx + 1; else return &lines->info[idx]; @@ -51,7 +51,12 @@ dwarf_getsrc_die (Dwarf_Die *cudie, Dwarf_Addr addr) information is faulty and no end-sequence marker is present, we still ignore it. */ if (u > 0 && u < nlines && addr > lines->info[u - 1].addr) - return &lines->info[u - 1]; + { + while (lines->info[u - 1].end_sequence && u > 0) + --u; + if (u > 0) + return &lines->info[u - 1]; + } __libdw_seterrno (DWARF_E_ADDR_OUTOFRANGE); return NULL; diff --git a/elfutils/libdw/dwarf_getsrclines.c b/elfutils/libdw/dwarf_getsrclines.c index 85fe35eb..a207b16a 100644 --- a/elfutils/libdw/dwarf_getsrclines.c +++ b/elfutils/libdw/dwarf_getsrclines.c @@ -43,6 +43,10 @@ compare_lines (const void *a, const void *b) Dwarf_Line *const *p1 = a; Dwarf_Line *const *p2 = b; + if ((*p1)->addr == (*p2)->addr) + /* An end_sequence marker precedes a normal record at the same address. */ + return (*p2)->end_sequence - (*p1)->end_sequence; + return (*p1)->addr - (*p2)->addr; } diff --git a/elfutils/libdw/dwarf_haspc.c b/elfutils/libdw/dwarf_haspc.c index 7f29296d..d2e737a5 100644 --- a/elfutils/libdw/dwarf_haspc.c +++ b/elfutils/libdw/dwarf_haspc.c @@ -25,81 +25,15 @@ dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc) if (die == NULL) return -1; - /* Usually there is a single contiguous range. */ - Dwarf_Addr lowpc, highpc; - if (INTUSE(dwarf_highpc) (die, &highpc) == 0 - && INTUSE(dwarf_lowpc) (die, &lowpc) == 0) - return pc >= lowpc && pc < highpc; - - /* We have to look for a noncontiguous range. */ - Dwarf_Attribute attr_mem; - Dwarf_Attribute *attr = INTUSE(dwarf_attr) (die, DW_AT_ranges, &attr_mem); - if (attr == NULL) - return -1; - - /* Must have the form data4 or data8 which act as an offset. */ - Dwarf_Word offset; - if (INTUSE(dwarf_formudata) (attr, &offset) != 0) - return -1; - - const Elf_Data *d = attr->cu->dbg->sectiondata[IDX_debug_ranges]; - if (d == NULL) - { - __libdw_seterrno (DWARF_E_NO_DEBUG_RANGES); - return -1; - } - - /* Fetch the CU's base address. */ Dwarf_Addr base; - Dwarf_Die cudie = - { - .cu = attr->cu, - .addr = ((char *) attr->cu->dbg->sectiondata[IDX_debug_info]->d_buf - + attr->cu->start + 3 * attr->cu->offset_size - 4 + 3), - }; - if (INTUSE(dwarf_lowpc) (&cudie, &base) != 0) - return -1; - - unsigned char *readp = d->d_buf + offset; Dwarf_Addr begin; Dwarf_Addr end; - do - { - next: - if ((unsigned char *) d->d_buf + d->d_size - readp - < attr->cu->address_size * 2) - { - __libdw_seterrno (DWARF_E_INVALID_DWARF); - return -1; - } - - if (attr->cu->address_size == 8) - { - begin = read_8ubyte_unaligned_inc (attr->cu->dbg, readp); - end = read_8ubyte_unaligned_inc (attr->cu->dbg, readp); - } - else - { - begin = (Dwarf_Sword) read_4sbyte_unaligned_inc (attr->cu->dbg, - readp); - end = read_4ubyte_unaligned_inc (attr->cu->dbg, readp); - } - - if (begin == (Dwarf_Addr) -1l) /* Base address entry. */ - { - base = end; - goto next; - } - - if (begin == 0 && end == 0) /* End of list entry. */ - /* This is not the droid you are looking for. */ - return 0; - - /* We have an address range entry. */ - } - while (pc < base + begin || pc >= base + end); + ptrdiff_t offset = 0; + while ((offset = INTUSE(dwarf_ranges) (die, offset, &base, + &begin, &end)) > 0) + if (pc >= begin && pc < end) + return 1; - /* This one matches the address. */ - return 1; + return offset; } INTDEF (dwarf_haspc) diff --git a/elfutils/libdw/dwarf_ranges.c b/elfutils/libdw/dwarf_ranges.c new file mode 100644 index 00000000..5d6710a0 --- /dev/null +++ b/elfutils/libdw/dwarf_ranges.c @@ -0,0 +1,115 @@ +/* Enumerate the PC ranges covered by a DIE. + Copyright (C) 2005 Red Hat, Inc. + + This program is Open Source software; you can redistribute it and/or + modify it under the terms of the Open Software License version 1.0 as + published by the Open Source Initiative. + + You should have received a copy of the Open Software License along + with this program; if not, you may obtain a copy of the Open Software + License version 1.0 from http://www.opensource.org/licenses/osl.php or + by writing the Open Source Initiative c/o Lawrence Rosen, Esq., + 3001 King Ranch Road, Ukiah, CA 95482. */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "libdwP.h" +#include <dwarf.h> +#include <assert.h> + + +ptrdiff_t +dwarf_ranges (Dwarf_Die *die, ptrdiff_t offset, Dwarf_Addr *basep, + Dwarf_Addr *startp, Dwarf_Addr *endp) +{ + if (die == NULL) + return -1; + + if (offset == 0 + /* Usually there is a single contiguous range. */ + && INTUSE(dwarf_highpc) (die, endp) == 0 + && INTUSE(dwarf_lowpc) (die, startp) == 0) + /* A offset into .debug_ranges will never be 1, it must be at least a + multiple of 4. So we can return 1 as a special case value to mark + there are no ranges to look for on the next call. */ + return 1; + + if (offset == 1) + return 0; + + /* We have to look for a noncontiguous range. */ + + const Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_ranges]; + if (d == NULL) + { + __libdw_seterrno (DWARF_E_NO_DEBUG_RANGES); + return -1; + } + + if (offset == 0) + { + Dwarf_Attribute attr_mem; + Dwarf_Attribute *attr = INTUSE(dwarf_attr) (die, DW_AT_ranges, + &attr_mem); + if (attr == NULL) + return -1; + + /* Must have the form data4 or data8 which act as an offset. */ + Dwarf_Word start_offset; + if (INTUSE(dwarf_formudata) (attr, &start_offset) != 0) + return -1; + + offset = start_offset; + assert ((Dwarf_Word) offset == start_offset); + + /* Fetch the CU's base address. */ + if (INTUSE(dwarf_lowpc) (&CUDIE (attr->cu), basep) != 0) + return -1; + } + else if (offset < 0 || (size_t) offset >= d->d_size) + { + __libdw_seterrno (DWARF_E_INVALID_OFFSET); + return -1l; + } + + unsigned char *readp = d->d_buf + offset; + + next: + if ((unsigned char *) d->d_buf + d->d_size - readp + < die->cu->address_size * 2) + { + __libdw_seterrno (DWARF_E_INVALID_DWARF); + return -1; + } + + Dwarf_Addr begin; + Dwarf_Addr end; + if (die->cu->address_size == 8) + { + begin = read_8ubyte_unaligned_inc (die->cu->dbg, readp); + end = read_8ubyte_unaligned_inc (die->cu->dbg, readp); + } + else + { + begin = (Dwarf_Sword) read_4sbyte_unaligned_inc (die->cu->dbg, + readp); + end = read_4ubyte_unaligned_inc (die->cu->dbg, readp); + } + + if (begin == (Dwarf_Addr) -1l) /* Base address entry. */ + { + *basep = end; + goto next; + } + + if (begin == 0 && end == 0) /* End of list entry. */ + return 0; + + /* We have an address range entry. */ + *startp = *basep + begin; + *endp = *basep + end; + return readp - (unsigned char *) d->d_buf; +} +INTDEF (dwarf_ranges) diff --git a/elfutils/libdw/libdw.h b/elfutils/libdw/libdw.h index 350aa440..69eb903f 100644 --- a/elfutils/libdw/libdw.h +++ b/elfutils/libdw/libdw.h @@ -90,9 +90,6 @@ typedef struct Dwarf_Aranges_s Dwarf_Aranges; /* CU representation. */ struct Dwarf_CU; -/* Function information. */ -typedef struct Dwarf_Func_s Dwarf_Func; - /* Macro information. */ typedef struct Dwarf_Macro_s Dwarf_Macro; @@ -138,15 +135,15 @@ typedef struct } Dwarf_Global; -// XXX It remains to be seen whether the next two need to be exported. -/* Location record. */ +/* One operation in a DWARF location expression. + A location expression is an array of these. */ typedef struct { uint8_t atom; /* Operation */ Dwarf_Word number; /* Operand */ Dwarf_Word number2; /* Possible second operand */ Dwarf_Word offset; /* Offset in location expression */ -} Dwarf_Loc; +} Dwarf_Op; /* Handle for debug sessions. */ @@ -194,6 +191,10 @@ extern Dwarf_Off dwarf_dieoffset (Dwarf_Die *die); /* Return offset of DIE in CU. */ extern Dwarf_Off dwarf_cuoffset (Dwarf_Die *die); +/* Return CU DIE containing given DIE. */ +extern Dwarf_Die *dwarf_diecu (Dwarf_Die *die, Dwarf_Die *result, + uint8_t *address_sizep, uint8_t *offset_sizep); + /* Return CU DIE containing given address. */ extern Dwarf_Die *dwarf_addrdie (Dwarf *dbg, Dwarf_Addr addr, Dwarf_Die *result) __nonnull_attribute__ (3); @@ -292,10 +293,26 @@ extern int dwarf_highpc (Dwarf_Die *die, Dwarf_Addr *return_addr) extern int dwarf_lowpc (Dwarf_Die *die, Dwarf_Addr *return_addr) __nonnull_attribute__ (2); +/* Return entry_pc or low_pc attribute of DIE. */ +extern int dwarf_entrypc (Dwarf_Die *die, Dwarf_Addr *return_addr) + __nonnull_attribute__ (2); + /* Return 1 if DIE's lowpc/highpc or ranges attributes match the PC address, 0 if not, or -1 for errors. */ extern int dwarf_haspc (Dwarf_Die *die, Dwarf_Addr pc); +/* Enumerate the PC address ranges covered by this DIE, covering all + addresses where dwarf_haspc returns true. In the first call OFFSET + should be zero and *BASEP need not be initialized. Returns -1 for + errors, zero when there are no more address ranges to report, or a + nonzero OFFSET value to pass to the next call. Each subsequent call + must preserve *BASEP from the prior call. Successful calls fill in + *STARTP and *ENDP with a contiguous address range. */ +extern ptrdiff_t dwarf_ranges (Dwarf_Die *die, + ptrdiff_t offset, Dwarf_Addr *basep, + Dwarf_Addr *startp, Dwarf_Addr *endp); + + /* Return byte size attribute of DIE. */ extern int dwarf_bytesize (Dwarf_Die *die); @@ -416,21 +433,21 @@ extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx, Dwarf_Word *mtime, Dwarf_Word *length); -/* Return location expression list. */ -extern int dwarf_getloclist (Dwarf_Attribute *attr, Dwarf_Loc **llbuf, - size_t *listlen) __nonnull_attribute__ (2, 3); +/* Return location expression, decoded as a list of operations. */ +extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr, + size_t *exprlen) __nonnull_attribute__ (2, 3); -/* Return location expression lists. If the attribute uses a location - list, ADDRESS selects the relevant location expressions from the list. +/* Return location expressions. If the attribute uses a location list, + ADDRESS selects the relevant location expressions from the list. There can be multiple matches, resulting in multiple expressions to - return. LLBUFS and LISTLENS are parallel arrays of NLOCS slots to fill - in. Returns the number of locations filled in, or -1 for errors. If - LLBUFS is a null pointer, stores nothing and returns the total number of - locations. A return value of zero means that the location list - indicated no value is accessible. */ -extern int dwarf_addrloclists (Dwarf_Attribute *attr, Dwarf_Addr address, - Dwarf_Loc **llbufs, size_t *listlens, - size_t nlocs); + return. EXPRS and EXPRLENS are parallel arrays of NLOCS slots to + fill in. Returns the number of locations filled in, or -1 for + errors. If EXPRS is a null pointer, stores nothing and returns the + total number of locations. A return value of zero means that the + location list indicated no value is accessible. */ +extern int dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address, + Dwarf_Op **exprs, size_t *exprlens, + size_t nlocs); /* Return scope DIEs containing PC address. @@ -488,48 +505,37 @@ extern Dwarf_Arange *dwarf_getarange_addr (Dwarf_Aranges *aranges, /* Get functions in CUDIE. */ extern ptrdiff_t dwarf_getfuncs (Dwarf_Die *cudie, - int (*callback) (Dwarf_Func *, void *), + int (*callback) (Dwarf_Die *, void *), void *arg, ptrdiff_t offset); -/* Return name of function. */ -extern const char *dwarf_func_name (Dwarf_Func *func); -/* Return start address of function. */ -extern int dwarf_func_lowpc (Dwarf_Func *func, Dwarf_Addr *return_addr) - __nonnull_attribute__ (2); +/* Return file name containing definition of the given declaration. */ +extern const char *dwarf_decl_file (Dwarf_Die *decl); -/* Return end address of function. */ -extern int dwarf_func_highpc (Dwarf_Func *func, Dwarf_Addr *return_addr) +/* Get line number of beginning of given declaration. */ +extern int dwarf_decl_line (Dwarf_Die *decl, int *linep) __nonnull_attribute__ (2); -/* Return entry point address of function. */ -extern int dwarf_func_entrypc (Dwarf_Func *func, Dwarf_Addr *return_addr) +/* Get column number of beginning of given declaration. */ +extern int dwarf_decl_column (Dwarf_Die *decl, int *colp) __nonnull_attribute__ (2); -/* Return file name containing definition of the given function. */ -extern const char *dwarf_func_file (Dwarf_Func *func); - -/* Get line number of beginning of given function. */ -extern int dwarf_func_line (Dwarf_Func *func, int *linep) - __nonnull_attribute__ (2); - -/* Get column number of beginning of given function. */ -extern int dwarf_func_col (Dwarf_Func *func, int *colp) - __nonnull_attribute__ (2); - -/* Get definition DIE of given function. */ -extern Dwarf_Die *dwarf_func_die (Dwarf_Func *func, Dwarf_Die *die_mem) - __nonnull_attribute__ (2); /* Return nonzero if given function is an abstract inline definition. */ -extern int dwarf_func_inline (Dwarf_Func *func); +extern int dwarf_func_inline (Dwarf_Die *func); /* Find each concrete inlined instance of the abstract inline definition. */ -extern int dwarf_func_inline_instances (Dwarf_Func *func, +extern int dwarf_func_inline_instances (Dwarf_Die *func, int (*callback) (Dwarf_Die *, void *), void *arg); +/* Find the appropriate PC location or locations for function entry + breakpoints for the given DW_TAG_subprogram DIE. Returns -1 for errors. + On success, returns the number of breakpoint locations (never zero) + and sets *BKPTS to a malloc'd vector of addresses. */ +extern int dwarf_entry_breakpoints (Dwarf_Die *die, Dwarf_Addr **bkpts); + /* Call callback function for each of the macro information entry for the CU. */ diff --git a/elfutils/libdw/libdw.map b/elfutils/libdw/libdw.map index a5324bd1..493df48e 100644 --- a/elfutils/libdw/libdw.map +++ b/elfutils/libdw/libdw.map @@ -1,12 +1,11 @@ ELFUTILS_0 { }; -ELFUTILS_0.115 { +ELFUTILS_0.116 { global: dwarf_abbrevhaschildren; dwarf_addrdie; - dwarf_addrloclists; + dwarf_arrayorder; dwarf_attr; dwarf_attr_integrate; - dwarf_arrayorder; dwarf_begin; dwarf_begin_elf; dwarf_bitoffset; @@ -14,9 +13,15 @@ ELFUTILS_0.115 { dwarf_bytesize; dwarf_child; dwarf_cuoffset; + dwarf_decl_column; + dwarf_decl_file; + dwarf_decl_line; + dwarf_diecu; dwarf_diename; dwarf_dieoffset; dwarf_end; + dwarf_entry_breakpoints; + dwarf_entrypc; dwarf_errmsg; dwarf_errno; dwarf_filesrc; @@ -28,16 +33,8 @@ ELFUTILS_0.115 { dwarf_formsdata; dwarf_formstring; dwarf_formudata; - dwarf_func_col; - dwarf_func_die; - dwarf_func_entrypc; - dwarf_func_file; - dwarf_func_highpc; dwarf_func_inline; dwarf_func_inline_instances; - dwarf_func_line; - dwarf_func_lowpc; - dwarf_func_name; dwarf_getabbrev; dwarf_getabbrevattr; dwarf_getabbrevcode; @@ -49,13 +46,14 @@ ELFUTILS_0.115 { dwarf_getattrs; dwarf_getelf; dwarf_getfuncs; - dwarf_getloclist; + dwarf_getlocation; + dwarf_getlocation_addr; dwarf_getmacros; dwarf_getpubnames; + dwarf_getscn_info; dwarf_getscopes; dwarf_getscopes_die; dwarf_getscopevar; - dwarf_getscn_info; dwarf_getsrc_die; dwarf_getsrc_file; dwarf_getsrcfiles; @@ -63,9 +61,9 @@ ELFUTILS_0.115 { dwarf_getstring; dwarf_hasattr; dwarf_hasattr_integrate; - dwarf_haspc; dwarf_haschildren; dwarf_hasform; + dwarf_haspc; dwarf_highpc; dwarf_lineaddr; dwarf_linebeginstatement; @@ -80,12 +78,13 @@ ELFUTILS_0.115 { dwarf_macro_opcode; dwarf_macro_param1; dwarf_macro_param2; + dwarf_new_oom_handler; + dwarf_nextcu; dwarf_offabbrev; dwarf_offdie; dwarf_onearange; dwarf_onesrcline; - dwarf_nextcu; - dwarf_new_oom_handler; + dwarf_ranges; dwarf_siblingof; dwarf_srclang; dwarf_tag; diff --git a/elfutils/libdw/libdwP.h b/elfutils/libdw/libdwP.h index 37f28721..436287d8 100644 --- a/elfutils/libdw/libdwP.h +++ b/elfutils/libdw/libdwP.h @@ -32,11 +32,11 @@ #define CIE_VERSION 1 -/* Known location lists. */ +/* Known location expressions already decoded. */ struct loc_s { void *addr; - Dwarf_Loc *loc; + Dwarf_Op *loc; size_t nloc; }; @@ -247,14 +247,13 @@ struct Dwarf_CU void *locs; }; - -/* Function information. */ -struct Dwarf_Func_s -{ - // XXX If we want to cache functions, we need to change this struct. - Dwarf_Die *die; - Dwarf_Die *cudie; -}; +#define CUDIE(fromcu) \ + ((Dwarf_Die) \ + { \ + .cu = (fromcu), \ + .addr = ((char *) (fromcu)->dbg->sectiondata[IDX_debug_info]->d_buf \ + + (fromcu)->start + 3 * (fromcu)->offset_size - 4 + 3), \ + }) /* Macro information. */ @@ -339,7 +338,7 @@ extern unsigned char *__libdw_find_attr (Dwarf_Die *die, __nonnull_attribute__ (1) internal_function; /* Helper function to access integer attribute. */ -extern int __libdw_func_intval (Dwarf_Func *func, int *linep, int attval) +extern int __libdw_attr_intval (Dwarf_Die *die, int *valp, int attval) __nonnull_attribute__ (1, 2) internal_function; /* Helper function to walk scopes. */ @@ -373,6 +372,7 @@ INTDECL (dwarf_child) INTDECL (dwarf_dieoffset) INTDECL (dwarf_diename) INTDECL (dwarf_end) +INTDECL (dwarf_entrypc) INTDECL (dwarf_errmsg) INTDECL (dwarf_formaddr) INTDECL (dwarf_formblock) @@ -393,6 +393,7 @@ INTDECL (dwarf_highpc) INTDECL (dwarf_lowpc) INTDECL (dwarf_nextcu) INTDECL (dwarf_offdie) +INTDECL (dwarf_ranges) INTDECL (dwarf_siblingof) INTDECL (dwarf_tag) diff --git a/elfutils/libdwfl/ChangeLog b/elfutils/libdwfl/ChangeLog index efffa616..60bd68b3 100644 --- a/elfutils/libdwfl/ChangeLog +++ b/elfutils/libdwfl/ChangeLog @@ -1,3 +1,21 @@ +2005-10-20 Roland McGrath <roland@redhat.com> + + * libdwflP.h (DWFL_ERRORS): New error UNKNOWN_MACHINE. + * relocate.c (__libdwfl_relocate): Return DWFL_E_UNKNOWN_MACHINE + instead of DWFL_E_BADRELTYPE if ebl_get_elfmachine yields EM_NONE. + +2005-10-01 Roland McGrath <roland@redhat.com> + + * linux-kernel-modules.c (report_kernel): Return ENOENT if we fail + with errno 0. + +2005-09-19 Roland McGrath <roland@redhat.com> + + * linux-kernel-modules.c (dwfl_linux_kernel_report_modules): Use + PRIx64 instead of PRIi64, lest addresses with high bits set overflow + the signed integer reading; they will just have to be in hexadecimal. + (dwfl_linux_kernel_module_section_address): Likewise. + 2005-08-28 Ulrich Drepper <drepper@redhat.com> * Makefile.am (%.os): Use COMPILE.os. diff --git a/elfutils/libdwfl/libdwflP.h b/elfutils/libdwfl/libdwflP.h index ae8985db..c4f303ed 100644 --- a/elfutils/libdwfl/libdwflP.h +++ b/elfutils/libdwfl/libdwflP.h @@ -38,6 +38,7 @@ DWFL_ERROR (LIBELF, N_("See elf_errno")) \ DWFL_ERROR (LIBDW, N_("See dwarf_errno")) \ DWFL_ERROR (LIBEBL, N_("See ebl_errno (XXX missing)")) \ + DWFL_ERROR (UNKNOWN_MACHINE, N_("no support library found for machine")) \ DWFL_ERROR (NOREL, N_("Callbacks missing for ET_REL file")) \ DWFL_ERROR (BADRELTYPE, N_("Unsupported relocation type")) \ DWFL_ERROR (BADRELOFF, N_("r_offset is bogus")) \ diff --git a/elfutils/libdwfl/linux-kernel-modules.c b/elfutils/libdwfl/linux-kernel-modules.c index ba65c599..c219c330 100644 --- a/elfutils/libdwfl/linux-kernel-modules.c +++ b/elfutils/libdwfl/linux-kernel-modules.c @@ -88,7 +88,8 @@ report_kernel (Dwfl *dwfl, const char *release, int result = 0; if (fd < 0) - result = (predicate != NULL && !(*predicate) ("kernel", NULL)) ? 0 : errno; + result = ((predicate != NULL && !(*predicate) ("kernel", NULL)) + ? 0 : errno ?: ENOENT); else { bool report = true; @@ -398,7 +399,7 @@ dwfl_linux_kernel_module_section_address (void) __fsetlocking (f, FSETLOCKING_BYCALLER); - int result = (fscanf (f, "%" PRIi64 "\n", addr) == 1 ? 0 + int result = (fscanf (f, "%" PRIx64 "\n", addr) == 1 ? 0 : ferror_unlocked (f) ? errno : ENOEXEC); fclose (f); @@ -423,7 +424,7 @@ dwfl_linux_kernel_report_modules (Dwfl *dwfl) Dwarf_Addr modaddr; unsigned long int modsz; char modname[128]; - while (fscanf (f, "%128s %lu %*s %*s %*s %" PRIi64 "\n", + while (fscanf (f, "%128s %lu %*s %*s %*s %" PRIx64 "\n", modname, &modsz, &modaddr) == 3) if (INTUSE(dwfl_report_module) (dwfl, modname, modaddr, modaddr + modsz) == NULL) diff --git a/elfutils/libdwfl/relocate.c b/elfutils/libdwfl/relocate.c index fe03d397..8644fb77 100644 --- a/elfutils/libdwfl/relocate.c +++ b/elfutils/libdwfl/relocate.c @@ -168,20 +168,24 @@ __libdwfl_relocate (Dwfl_Module *mod, Elf *debugfile) } /* These are the types we can relocate. */ -#define TYPES DO_TYPE (BYTE, Byte) DO_TYPE (HALF, Half) \ - DO_TYPE (WORD, Word) DO_TYPE (SWORD, Sword) \ - DO_TYPE (XWORD, Xword) DO_TYPE (SXWORD, Sxword) +#define TYPES DO_TYPE (BYTE, Byte); DO_TYPE (HALF, Half); \ + DO_TYPE (WORD, Word); DO_TYPE (SWORD, Sword); \ + DO_TYPE (XWORD, Xword); DO_TYPE (SXWORD, Sxword) size_t size; Elf_Type type = ebl_reloc_simple_type (mod->ebl, rtype); switch (type) { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - size = sizeof (GElf_##Name); \ - break; - TYPES +#define DO_TYPE(NAME, Name) \ + case ELF_T_##NAME: \ + size = sizeof (GElf_##Name); \ + break + TYPES; #undef DO_TYPE - default: + default: + /* This might be because ebl_openbackend failed to find + any libebl_CPU.so library. Diagnose that clearly. */ + if (ebl_get_elfmachine (mod->ebl) == EM_NONE) + return DWFL_E_UNKNOWN_MACHINE; return DWFL_E_BADRELTYPE; } @@ -189,7 +193,7 @@ __libdwfl_relocate (Dwfl_Module *mod, Elf *debugfile) return DWFL_E_BADRELOFF; #define DO_TYPE(NAME, Name) GElf_##Name Name; - union { TYPES } tmpbuf; + union { TYPES; } tmpbuf; #undef DO_TYPE Elf_Data tmpdata = { @@ -213,13 +217,13 @@ __libdwfl_relocate (Dwfl_Module *mod, Elf *debugfile) value += *addend; switch (type) { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - tmpbuf.Name = value; \ - break; - TYPES +#define DO_TYPE(NAME, Name) \ + case ELF_T_##NAME: \ + tmpbuf.Name = value; \ + break + TYPES; #undef DO_TYPE - default: + default: abort (); } } @@ -233,13 +237,13 @@ __libdwfl_relocate (Dwfl_Module *mod, Elf *debugfile) assert (d == &tmpdata); switch (type) { -#define DO_TYPE(NAME, Name) \ - case ELF_T_##NAME: \ - tmpbuf.Name += (GElf_##Name) value; \ - break; - TYPES +#define DO_TYPE(NAME, Name) \ + case ELF_T_##NAME: \ + tmpbuf.Name += (GElf_##Name) value; \ + break + TYPES; #undef DO_TYPE - default: + default: abort (); } } diff --git a/elfutils/libelf-po/libelf.pot b/elfutils/libelf-po/libelf.pot index e9f4cf43..9c820a44 100644 --- a/elfutils/libelf-po/libelf.pot +++ b/elfutils/libelf-po/libelf.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-09-02 13:30-0700\n" +"POT-Creation-Date: 2005-10-31 12:22-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" diff --git a/elfutils/libelf/ChangeLog b/elfutils/libelf/ChangeLog index bd710aee..35667cee 100644 --- a/elfutils/libelf/ChangeLog +++ b/elfutils/libelf/ChangeLog @@ -1,3 +1,8 @@ +2005-09-09 Roland McGrath <roland@redhat.com> + + * elf_update.c (write_file): Stat the file and fchmod it after update + if its mode had S_ISUID or S_ISGID bits set. + 2005-08-28 Ulrich Drepper <drepper@redhat.com> * elf32_getphdr.c: Include <system.h>. Use pread_retry instead of diff --git a/elfutils/libelf/elf_update.c b/elfutils/libelf/elf_update.c index 5d6c6b7a..f380e2b9 100644 --- a/elfutils/libelf/elf_update.c +++ b/elfutils/libelf/elf_update.c @@ -22,6 +22,7 @@ #include <libelf.h> #include <unistd.h> #include <sys/mman.h> +#include <sys/stat.h> #include "libelfP.h" @@ -31,6 +32,14 @@ write_file (Elf *elf, off_t size, int change_bo, size_t shnum) { int class = elf->class; + /* Check the mode bits now, before modification might change them. */ + struct stat st; + if (unlikely (fstat (elf->fildes, &st) != 0)) + { + __libelf_seterrno (ELF_E_WRITE_ERROR); + return -1; + } + /* Adjust the size in any case. We do this even if we use `write'. We cannot do this if this file is in an archive. We also don't do it *now* if we are shortening the file since this would @@ -87,6 +96,18 @@ write_file (Elf *elf, off_t size, int change_bo, size_t shnum) size = -1; } + /* POSIX says that ftruncate and write may clear the S_ISUID and S_ISGID + mode bits. So make sure we restore them afterwards if they were set. + This is not atomic if someone else chmod's the file while we operate. */ + if (size != -1 + && unlikely (st.st_mode & (S_ISUID | S_ISGID)) + /* fchmod ignores the bits we cannot change. */ + && unlikely (fchmod (elf->fildes, st.st_mode) != 0)) + { + __libelf_seterrno (ELF_E_WRITE_ERROR); + size = -1; + } + if (size != -1 && elf->parent == NULL) elf->maximum_size = size; diff --git a/elfutils/po/elfutils.pot b/elfutils/po/elfutils.pot index dab6c0c3..14d3f43c 100644 --- a/elfutils/po/elfutils.pot +++ b/elfutils/po/elfutils.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2005-09-02 13:30-0700\n" +"POT-Creation-Date: 2005-10-31 12:22-0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -60,11 +60,7 @@ msgstr "" msgid "error during output of data" msgstr "" -#: libasm/asm_error.c:150 -msgid "Unknown error" -msgstr "" - -#: libdw/dwarf_error.c:76 +#: libasm/asm_error.c:150 libdw/dwarf_error.c:76 msgid "unknown error" msgstr "" @@ -295,7 +291,7 @@ msgstr "" #: src/nm.c:241 src/readelf.c:356 src/size.c:207 src/strip.c:191 src/ld.c:857 #: src/elflint.c:220 src/addr2line.c:168 src/findtextrel.c:156 -#: src/elfcmp.c:493 src/ranlib.c:134 src/strings.c:215 +#: src/elfcmp.c:494 src/ranlib.c:134 src/strings.c:215 #, c-format msgid "" "Copyright (C) %s Red Hat, Inc.\n" @@ -305,20 +301,21 @@ msgstr "" #: src/nm.c:246 src/readelf.c:361 src/size.c:212 src/strip.c:196 src/ld.c:862 #: src/elflint.c:225 src/addr2line.c:173 src/findtextrel.c:161 -#: src/elfcmp.c:498 src/ranlib.c:139 src/strings.c:220 +#: src/elfcmp.c:499 src/ranlib.c:139 src/strings.c:220 #, c-format msgid "Written by %s.\n" msgstr "" -#: src/nm.c:351 src/strip.c:418 src/strip.c:453 src/findtextrel.c:215 +#: src/nm.c:351 src/size.c:289 src/strip.c:418 src/strip.c:453 +#: src/ldgeneric.c:1593 src/findtextrel.c:215 src/elfcmp.c:542 #: src/ranlib.c:288 src/strings.c:171 #, c-format msgid "cannot open '%s'" msgstr "" -#: src/nm.c:368 src/nm.c:380 src/size.c:309 +#: src/nm.c:368 src/nm.c:380 src/size.c:305 src/size.c:388 src/strip.c:1748 #, c-format -msgid "while close '%s'" +msgid "while closing '%s'" msgstr "" #: src/nm.c:390 src/strip.c:346 @@ -357,11 +354,11 @@ msgstr "" msgid "cannot create search tree" msgstr "" -#: src/nm.c:716 src/nm.c:961 src/readelf.c:671 src/readelf.c:814 -#: src/readelf.c:967 src/readelf.c:1151 src/readelf.c:1370 src/readelf.c:1529 -#: src/readelf.c:1702 src/readelf.c:1957 src/readelf.c:2023 src/readelf.c:2102 -#: src/readelf.c:2384 src/readelf.c:2510 src/readelf.c:4823 src/size.c:414 -#: src/size.c:489 src/strip.c:468 +#: src/nm.c:716 src/nm.c:961 src/readelf.c:664 src/readelf.c:803 +#: src/readelf.c:944 src/readelf.c:1126 src/readelf.c:1334 src/readelf.c:1488 +#: src/readelf.c:1655 src/readelf.c:1909 src/readelf.c:1975 src/readelf.c:2053 +#: src/readelf.c:2320 src/readelf.c:2439 src/readelf.c:4752 src/size.c:406 +#: src/size.c:480 src/strip.c:468 #, c-format msgid "cannot get section header string table index" msgstr "" @@ -521,249 +518,249 @@ msgstr "" msgid "Not an ELF file - it has the wrong magic bytes at the start" msgstr "" -#: src/readelf.c:456 +#: src/readelf.c:455 #, c-format msgid "cannot read ELF header: %s" msgstr "" -#: src/readelf.c:463 +#: src/readelf.c:462 #, c-format msgid "cannot create EBL handle" msgstr "" -#: src/readelf.c:470 src/strip.c:528 src/ldgeneric.c:592 src/ldgeneric.c:1026 +#: src/readelf.c:469 src/strip.c:528 src/ldgeneric.c:592 src/ldgeneric.c:1026 #, c-format msgid "cannot determine number of sections: %s" msgstr "" -#: src/readelf.c:512 +#: src/readelf.c:511 msgid "NONE (None)" msgstr "" -#: src/readelf.c:513 +#: src/readelf.c:512 msgid "REL (Relocatable file)" msgstr "" -#: src/readelf.c:514 +#: src/readelf.c:513 msgid "EXEC (Executable file)" msgstr "" -#: src/readelf.c:515 +#: src/readelf.c:514 msgid "DYN (Shared object file)" msgstr "" -#: src/readelf.c:516 +#: src/readelf.c:515 msgid "CORE (Core file)" msgstr "" -#: src/readelf.c:521 +#: src/readelf.c:520 #, c-format msgid "OS Specific: (%x)\n" msgstr "" -#: src/readelf.c:523 +#: src/readelf.c:522 #, c-format msgid "Processor Specific: (%x)\n" msgstr "" -#: src/readelf.c:536 +#: src/readelf.c:532 msgid "" "ELF Header:\n" " Magic: " msgstr "" -#: src/readelf.c:540 +#: src/readelf.c:536 #, c-format msgid "" "\n" " Class: %s\n" msgstr "" -#: src/readelf.c:545 +#: src/readelf.c:541 #, c-format msgid " Data: %s\n" msgstr "" -#: src/readelf.c:551 +#: src/readelf.c:547 #, c-format msgid " Version: %hhd %s\n" msgstr "" -#: src/readelf.c:553 src/readelf.c:569 +#: src/readelf.c:549 src/readelf.c:566 msgid "(current)" msgstr "" -#: src/readelf.c:556 +#: src/readelf.c:553 #, c-format msgid " OS/ABI: %s\n" msgstr "" -#: src/readelf.c:559 +#: src/readelf.c:556 #, c-format msgid " ABI Version: %hhd\n" msgstr "" -#: src/readelf.c:562 +#: src/readelf.c:559 msgid " Type: " msgstr "" -#: src/readelf.c:565 +#: src/readelf.c:562 #, c-format msgid " Machine: %s\n" msgstr "" -#: src/readelf.c:567 +#: src/readelf.c:564 #, c-format msgid " Version: %d %s\n" msgstr "" -#: src/readelf.c:571 +#: src/readelf.c:568 #, c-format msgid " Entry point address: %#<PRIx64>\n" msgstr "" -#: src/readelf.c:574 +#: src/readelf.c:571 #, c-format msgid " Start of program headers: %<PRId64> %s\n" msgstr "" -#: src/readelf.c:575 src/readelf.c:578 +#: src/readelf.c:572 src/readelf.c:575 msgid "(bytes into file)" msgstr "" -#: src/readelf.c:577 +#: src/readelf.c:574 #, c-format msgid " Start of section headers: %<PRId64> %s\n" msgstr "" -#: src/readelf.c:580 +#: src/readelf.c:577 #, c-format msgid " Flags: %s\n" msgstr "" -#: src/readelf.c:583 +#: src/readelf.c:580 #, c-format msgid " Size of this header: %<PRId16> %s\n" msgstr "" -#: src/readelf.c:584 src/readelf.c:587 src/readelf.c:593 +#: src/readelf.c:581 src/readelf.c:584 src/readelf.c:590 msgid "(bytes)" msgstr "" -#: src/readelf.c:586 +#: src/readelf.c:583 #, c-format msgid " Size of program header entries: %<PRId16> %s\n" msgstr "" -#: src/readelf.c:589 +#: src/readelf.c:586 #, c-format msgid " Number of program headers entries: %<PRId16>\n" msgstr "" -#: src/readelf.c:592 +#: src/readelf.c:589 #, c-format msgid " Size of section header entries: %<PRId16> %s\n" msgstr "" -#: src/readelf.c:595 +#: src/readelf.c:592 #, c-format msgid " Number of section headers entries: %<PRId16>" msgstr "" -#: src/readelf.c:604 +#: src/readelf.c:599 #, c-format msgid " (%<PRIu32> in [0].sh_size)" msgstr "" -#: src/readelf.c:607 src/readelf.c:623 +#: src/readelf.c:602 src/readelf.c:616 msgid " ([0] not available)" msgstr "" -#: src/readelf.c:619 +#: src/readelf.c:612 #, c-format msgid " (%<PRIu32> in [0].sh_link)" msgstr "" -#: src/readelf.c:627 +#: src/readelf.c:620 #, c-format msgid "" " Section header string table index: XINDEX%s\n" "\n" msgstr "" -#: src/readelf.c:631 +#: src/readelf.c:624 #, c-format msgid "" " Section header string table index: %<PRId16>\n" "\n" msgstr "" -#: src/readelf.c:663 +#: src/readelf.c:656 #, c-format msgid "" "There are %d section headers, starting at offset %#<PRIx64>:\n" "\n" msgstr "" -#: src/readelf.c:673 +#: src/readelf.c:666 msgid "Section Headers:" msgstr "" -#: src/readelf.c:676 +#: src/readelf.c:669 msgid "" "[Nr] Name Type Addr Off Size ES Flags Lk " "Inf Al" msgstr "" -#: src/readelf.c:678 +#: src/readelf.c:671 msgid "" "[Nr] Name Type Addr Off Size ES " "Flags Lk Inf Al" msgstr "" -#: src/readelf.c:690 src/readelf.c:843 +#: src/readelf.c:678 src/readelf.c:827 #, c-format msgid "cannot get section: %s" msgstr "" -#: src/readelf.c:696 src/readelf.c:850 +#: src/readelf.c:685 src/readelf.c:835 #, c-format msgid "cannot get section header: %s" msgstr "" -#: src/readelf.c:755 +#: src/readelf.c:743 msgid "Program Headers:" msgstr "" -#: src/readelf.c:757 +#: src/readelf.c:745 msgid "" " Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align" msgstr "" -#: src/readelf.c:760 +#: src/readelf.c:748 msgid "" " Type Offset VirtAddr PhysAddr FileSiz " "MemSiz Flg Align" msgstr "" -#: src/readelf.c:800 +#: src/readelf.c:788 #, c-format msgid "\t[Requesting program interpreter: %s]\n" msgstr "" -#: src/readelf.c:816 +#: src/readelf.c:805 msgid "" "\n" " Section to Segment mapping:\n" " Segment Sections..." msgstr "" -#: src/readelf.c:829 +#: src/readelf.c:816 #, c-format msgid "cannot get program header: %s" msgstr "" -#: src/readelf.c:972 +#: src/readelf.c:950 #, c-format msgid "" "\n" @@ -774,7 +771,7 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:977 +#: src/readelf.c:955 #, c-format msgid "" "\n" @@ -785,20 +782,15 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:985 +#: src/readelf.c:963 msgid "<INVALID SYMBOL>" msgstr "" -#: src/readelf.c:997 -#, c-format -msgid " [%2u] <INVALID SECTION>\n" -msgstr "" - -#: src/readelf.c:1002 +#: src/readelf.c:977 msgid "<INVALID SECTION>" msgstr "" -#: src/readelf.c:1153 +#: src/readelf.c:1128 #, c-format msgid "" "\n" @@ -811,43 +803,43 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1165 +#: src/readelf.c:1140 msgid " Type Value\n" msgstr "" -#: src/readelf.c:1191 +#: src/readelf.c:1164 #, c-format msgid "Shared library: [%s]\n" msgstr "" -#: src/readelf.c:1196 +#: src/readelf.c:1169 #, c-format msgid "Library soname: [%s]\n" msgstr "" -#: src/readelf.c:1201 +#: src/readelf.c:1174 #, c-format msgid "Library rpath: [%s]\n" msgstr "" -#: src/readelf.c:1206 +#: src/readelf.c:1179 #, c-format msgid "Library runpath: [%s]\n" msgstr "" -#: src/readelf.c:1226 +#: src/readelf.c:1199 #, c-format msgid "%<PRId64> (bytes)\n" msgstr "" -#: src/readelf.c:1345 src/readelf.c:1502 +#: src/readelf.c:1309 src/readelf.c:1463 #, c-format msgid "" "\n" "Invalid symbol table at offset %#0<PRIx64>\n" msgstr "" -#: src/readelf.c:1373 +#: src/readelf.c:1337 #, c-format msgid "" "\n" @@ -860,7 +852,7 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1388 +#: src/readelf.c:1352 #, c-format msgid "" "\n" @@ -871,28 +863,28 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1398 +#: src/readelf.c:1362 msgid " Offset Type Value Name\n" msgstr "" -#: src/readelf.c:1400 +#: src/readelf.c:1364 msgid " Offset Type Value Name\n" msgstr "" -#: src/readelf.c:1427 src/readelf.c:1438 src/readelf.c:1456 src/readelf.c:1468 -#: src/readelf.c:1571 src/readelf.c:1583 src/readelf.c:1602 src/readelf.c:1615 +#: src/readelf.c:1388 src/readelf.c:1399 src/readelf.c:1417 src/readelf.c:1429 +#: src/readelf.c:1529 src/readelf.c:1541 src/readelf.c:1560 src/readelf.c:1573 msgid "<INVALID RELOC>" msgstr "" -#: src/readelf.c:1428 src/readelf.c:1572 +#: src/readelf.c:1389 src/readelf.c:1530 msgid "INVALID SYMBOL" msgstr "" -#: src/readelf.c:1457 src/readelf.c:1603 +#: src/readelf.c:1418 src/readelf.c:1561 msgid "INVALID SECTION" msgstr "" -#: src/readelf.c:1531 +#: src/readelf.c:1490 #, c-format msgid "" "\n" @@ -905,15 +897,15 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1543 +#: src/readelf.c:1502 msgid " Offset Type Value Addend Name\n" msgstr "" -#: src/readelf.c:1545 +#: src/readelf.c:1504 msgid " Offset Type Value Addend Name\n" msgstr "" -#: src/readelf.c:1708 +#: src/readelf.c:1662 #, c-format msgid "" "\n" @@ -924,40 +916,40 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1713 +#: src/readelf.c:1668 #, c-format msgid " %lu local symbol String table: [%2u] '%s'\n" msgid_plural " %lu local symbols String table: [%2u] '%s'\n" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1723 +#: src/readelf.c:1678 msgid " Num: Value Size Type Bind Vis Ndx Name\n" msgstr "" -#: src/readelf.c:1725 +#: src/readelf.c:1680 msgid " Num: Value Size Type Bind Vis Ndx Name\n" msgstr "" -#: src/readelf.c:1745 +#: src/readelf.c:1700 #, c-format msgid "%5u: %0*<PRIx64> %6<PRId64> %-7s %-6s %-9s %6s %s" msgstr "" -#: src/readelf.c:1835 +#: src/readelf.c:1788 #, c-format msgid "bad dynamic symbol" msgstr "" -#: src/readelf.c:1918 +#: src/readelf.c:1870 msgid "none" msgstr "" -#: src/readelf.c:1935 +#: src/readelf.c:1887 msgid "| <unknown>" msgstr "" -#: src/readelf.c:1960 +#: src/readelf.c:1912 #, c-format msgid "" "\n" @@ -970,17 +962,17 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:1983 +#: src/readelf.c:1935 #, c-format msgid " %#06x: Version: %hu File: %s Cnt: %hu\n" msgstr "" -#: src/readelf.c:1996 +#: src/readelf.c:1948 #, c-format msgid " %#06x: Name: %s Flags: %s Version: %hu\n" msgstr "" -#: src/readelf.c:2027 +#: src/readelf.c:1979 #, c-format msgid "" "\n" @@ -993,17 +985,17 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:2057 +#: src/readelf.c:2009 #, c-format msgid " %#06x: Version: %hd Flags: %s Index: %hd Cnt: %hd Name: %s\n" msgstr "" -#: src/readelf.c:2072 +#: src/readelf.c:2024 #, c-format msgid " %#06x: Parent %d: %s\n" msgstr "" -#: src/readelf.c:2316 +#: src/readelf.c:2256 #, c-format msgid "" "\n" @@ -1016,20 +1008,20 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:2348 +#: src/readelf.c:2286 msgid " 0 *local* " msgstr "" -#: src/readelf.c:2353 +#: src/readelf.c:2291 msgid " 1 *global* " msgstr "" -#: src/readelf.c:2409 +#: src/readelf.c:2334 #, c-format msgid "cannot get data for section %d: %s" msgstr "" -#: src/readelf.c:2419 +#: src/readelf.c:2345 #, c-format msgid "" "\n" @@ -1044,29 +1036,29 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:2464 +#: src/readelf.c:2391 #, c-format -msgid " Length Number % of total Coverage" +msgid " Length Number % of total Coverage\n" msgstr "" -#: src/readelf.c:2465 +#: src/readelf.c:2393 #, c-format msgid " 0 %6<PRIu32> %5.1f%%\n" msgstr "" -#: src/readelf.c:2471 +#: src/readelf.c:2400 #, c-format msgid "%7d %6<PRIu32> %5.1f%% %5.1f%%\n" msgstr "" -#: src/readelf.c:2485 +#: src/readelf.c:2414 #, c-format msgid "" " Average number of tests: successful lookup: %f\n" " unsuccessful lookup: %f\n" msgstr "" -#: src/readelf.c:2520 +#: src/readelf.c:2449 #, c-format msgid "" "\n" @@ -1077,38 +1069,38 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:2534 +#: src/readelf.c:2463 msgid "" " Library Time Stamp Checksum Version " "Flags" msgstr "" -#: src/readelf.c:2657 +#: src/readelf.c:2586 #, c-format msgid "unknown tag %hx" msgstr "" -#: src/readelf.c:2659 +#: src/readelf.c:2588 #, c-format msgid "unknown user tag %hx" msgstr "" -#: src/readelf.c:2855 +#: src/readelf.c:2784 #, c-format msgid "unknown attribute %hx" msgstr "" -#: src/readelf.c:2858 +#: src/readelf.c:2787 #, c-format msgid "unknown user attribute %hx" msgstr "" -#: src/readelf.c:2904 +#: src/readelf.c:2833 #, c-format msgid "unknown form %<PRIx64>" msgstr "" -#: src/readelf.c:3454 +#: src/readelf.c:3383 #, c-format msgid "" "\n" @@ -1116,37 +1108,37 @@ msgid "" " [ Code]\n" msgstr "" -#: src/readelf.c:3461 +#: src/readelf.c:3390 #, c-format msgid "" "\n" "Abbreviation section at offset %<PRIu64>:\n" msgstr "" -#: src/readelf.c:3474 +#: src/readelf.c:3403 #, c-format msgid " *** error while reading abbreviation: %s\n" msgstr "" -#: src/readelf.c:3490 +#: src/readelf.c:3419 #, c-format msgid " [%5u] offset: %<PRId64>, children: %s, tag: %s\n" msgstr "" -#: src/readelf.c:3493 +#: src/readelf.c:3422 msgid "yes" msgstr "" -#: src/readelf.c:3493 +#: src/readelf.c:3422 msgid "no" msgstr "" -#: src/readelf.c:3529 +#: src/readelf.c:3458 #, c-format msgid "cannot get .debug_aranges content: %s" msgstr "" -#: src/readelf.c:3534 +#: src/readelf.c:3463 #, c-format msgid "" "\n" @@ -1157,46 +1149,46 @@ msgid_plural "" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:3564 +#: src/readelf.c:3493 #, c-format msgid " [%*zu] ???\n" msgstr "" -#: src/readelf.c:3566 +#: src/readelf.c:3495 #, c-format msgid "" " [%*zu] start: %0#*<PRIx64>, length: %5<PRIu64>, CU DIE offset: %6<PRId64>\n" msgstr "" -#: src/readelf.c:3584 +#: src/readelf.c:3513 #, c-format msgid "cannot get .debug_ranges content: %s" msgstr "" -#: src/readelf.c:3589 src/readelf.c:4066 src/readelf.c:4491 src/readelf.c:4581 -#: src/readelf.c:4753 +#: src/readelf.c:3518 src/readelf.c:3995 src/readelf.c:4420 src/readelf.c:4510 +#: src/readelf.c:4682 #, c-format msgid "" "\n" "DWARF section '%s' at offset %#<PRIx64>:\n" msgstr "" -#: src/readelf.c:3673 +#: src/readelf.c:3602 #, c-format msgid "cannot get attribute code: %s" msgstr "" -#: src/readelf.c:3681 +#: src/readelf.c:3610 #, c-format msgid "cannot get attribute form: %s" msgstr "" -#: src/readelf.c:3693 +#: src/readelf.c:3622 #, c-format msgid "cannot get attribute value: %s" msgstr "" -#: src/readelf.c:3859 +#: src/readelf.c:3788 #, c-format msgid "" "\n" @@ -1204,7 +1196,7 @@ msgid "" " [Offset]\n" msgstr "" -#: src/readelf.c:3884 +#: src/readelf.c:3813 #, c-format msgid "" " Compilation unit at offset %<PRIu64>:\n" @@ -1212,49 +1204,49 @@ msgid "" "<PRIu8>, Offset size: %<PRIu8>\n" msgstr "" -#: src/readelf.c:3901 +#: src/readelf.c:3830 #, c-format msgid "cannot get DIE at offset %<PRIu64> in section '%s': %s" msgstr "" -#: src/readelf.c:3912 +#: src/readelf.c:3841 #, c-format msgid "cannot get DIE offset: %s" msgstr "" -#: src/readelf.c:3920 +#: src/readelf.c:3849 #, c-format msgid "cannot get tag of DIE at offset %<PRIu64> in section '%s': %s" msgstr "" -#: src/readelf.c:4037 +#: src/readelf.c:3966 #, c-format msgid "cannot get next DIE: %s\n" msgstr "" -#: src/readelf.c:4044 +#: src/readelf.c:3973 #, c-format msgid "cannot get next DIE: %s" msgstr "" -#: src/readelf.c:4078 +#: src/readelf.c:4007 #, c-format msgid "cannot get line data section data: %s" msgstr "" -#: src/readelf.c:4091 +#: src/readelf.c:4020 #, c-format msgid "" "\n" "Table at offset %Zu:\n" msgstr "" -#: src/readelf.c:4100 +#: src/readelf.c:4029 #, c-format msgid "invalid data in section [%zu] '%s'" msgstr "" -#: src/readelf.c:4143 +#: src/readelf.c:4072 #, c-format msgid "" "\n" @@ -1270,139 +1262,139 @@ msgid "" "Opcodes:\n" msgstr "" -#: src/readelf.c:4169 +#: src/readelf.c:4098 #, c-format msgid " [%*<PRIuFAST8>] %hhu argument\n" msgid_plural " [%*<PRIuFAST8>] %hhu arguments\n" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:4177 +#: src/readelf.c:4106 msgid "" "\n" "Directory table:" msgstr "" -#: src/readelf.c:4193 +#: src/readelf.c:4122 msgid "" "\n" "File name table:\n" " Entry Dir Time Size Name" msgstr "" -#: src/readelf.c:4222 +#: src/readelf.c:4151 msgid "" "\n" "Line number statements:" msgstr "" -#: src/readelf.c:4282 +#: src/readelf.c:4211 #, c-format msgid " special opcode %u: address+%u = %#<PRIx64>, line%+d = %zu\n" msgstr "" -#: src/readelf.c:4302 +#: src/readelf.c:4231 #, c-format msgid " extended opcode %u: " msgstr "" -#: src/readelf.c:4307 +#: src/readelf.c:4236 msgid "end of sequence" msgstr "" -#: src/readelf.c:4320 +#: src/readelf.c:4249 #, c-format msgid "set address to %#<PRIx64>\n" msgstr "" -#: src/readelf.c:4340 +#: src/readelf.c:4269 #, c-format msgid "define new file: dir=%u, mtime=%<PRIu64>, length=%<PRIu64>, name=%s\n" msgstr "" -#: src/readelf.c:4349 +#: src/readelf.c:4278 msgid "unknown opcode" msgstr "" -#: src/readelf.c:4361 +#: src/readelf.c:4290 msgid " copy" msgstr "" -#: src/readelf.c:4369 +#: src/readelf.c:4298 #, c-format msgid " advance address by %u to %#<PRIx64>\n" msgstr "" -#: src/readelf.c:4379 +#: src/readelf.c:4308 #, c-format msgid " advance line by constant %d to %<PRId64>\n" msgstr "" -#: src/readelf.c:4387 +#: src/readelf.c:4316 #, c-format msgid " set file to %<PRIu64>\n" msgstr "" -#: src/readelf.c:4397 +#: src/readelf.c:4326 #, c-format msgid " set column to %<PRIu64>\n" msgstr "" -#: src/readelf.c:4404 +#: src/readelf.c:4333 #, c-format msgid " set '%s' to %<PRIuFAST8>\n" msgstr "" -#: src/readelf.c:4410 +#: src/readelf.c:4339 msgid " set basic block flag" msgstr "" -#: src/readelf.c:4418 +#: src/readelf.c:4347 #, c-format msgid " advance address by constant %u to %#<PRIx64>\n" msgstr "" -#: src/readelf.c:4431 +#: src/readelf.c:4360 #, c-format msgid " advance address by fixed value %u to %#<PRIx64>\n" msgstr "" -#: src/readelf.c:4438 +#: src/readelf.c:4367 msgid " set prologue end flag" msgstr "" -#: src/readelf.c:4443 +#: src/readelf.c:4372 msgid " set epilogue begin flag" msgstr "" -#: src/readelf.c:4452 +#: src/readelf.c:4381 #, c-format msgid " unknown opcode with %<PRIu8> parameter:" msgid_plural " unknown opcode with %<PRIu8> parameters:" msgstr[0] "" msgstr[1] "" -#: src/readelf.c:4486 +#: src/readelf.c:4415 #, c-format msgid "cannot get .debug_loc content: %s" msgstr "" -#: src/readelf.c:4591 +#: src/readelf.c:4520 #, c-format msgid "cannot get macro information section data: %s" msgstr "" -#: src/readelf.c:4670 +#: src/readelf.c:4599 #, c-format msgid "%*s*** non-terminated string at end of section" msgstr "" -#: src/readelf.c:4738 +#: src/readelf.c:4667 #, c-format msgid " [%5d] DIE offset: %6<PRId64>, CU DIE offset: %6<PRId64>, name: %s\n" msgstr "" -#: src/readelf.c:4777 +#: src/readelf.c:4706 #, c-format msgid "" "\n" @@ -1410,33 +1402,33 @@ msgid "" " %*s String\n" msgstr "" -#: src/readelf.c:4790 +#: src/readelf.c:4719 #, c-format msgid " *** error while reading strings: %s\n" msgstr "" -#: src/readelf.c:4815 +#: src/readelf.c:4744 #, c-format msgid "cannot get debug context descriptor: %s" msgstr "" -#: src/readelf.c:4893 +#: src/readelf.c:4822 #, c-format msgid "" "\n" "Note segment of %<PRId64> bytes at offset %#0<PRIx64>:\n" msgstr "" -#: src/readelf.c:4900 +#: src/readelf.c:4829 #, c-format msgid "cannot get content of note section: %s" msgstr "" -#: src/readelf.c:4903 +#: src/readelf.c:4832 msgid " Owner Data size Type\n" msgstr "" -#: src/readelf.c:4943 +#: src/readelf.c:4872 #, c-format msgid " %-13.*s %9<PRId32> %s\n" msgstr "" @@ -1493,27 +1485,17 @@ msgstr "" msgid "Invalid radix: %s" msgstr "" -#: src/size.c:293 -#, c-format -msgid "cannot open '%s" -msgstr "" - -#: src/size.c:321 +#: src/size.c:317 #, c-format msgid "%s: file format not recognized" msgstr "" -#: src/size.c:392 -#, c-format -msgid "while closing `%s'" -msgstr "" - -#: src/size.c:433 src/size.c:574 +#: src/size.c:427 src/size.c:570 #, c-format msgid " (ex %s)" msgstr "" -#: src/size.c:599 +#: src/size.c:595 msgid "(TOTALS)\n" msgstr "" @@ -1575,12 +1557,12 @@ msgstr "" #: src/strip.c:285 src/strip.c:309 #, c-format -msgid "cannot stat input file \"%s\"" +msgid "cannot stat input file '%s'" msgstr "" #: src/strip.c:299 #, c-format -msgid "while opening \"%s\"" +msgid "while opening '%s'" msgstr "" #: src/strip.c:337 @@ -1663,11 +1645,6 @@ msgstr "" msgid "cannot set access and modification date of '%s'" msgstr "" -#: src/strip.c:1748 -#, c-format -msgid "while closing '%s'" -msgstr "" - #: src/ld.c:74 msgid "Include whole archives in the output from now on." msgstr "" @@ -1889,7 +1866,7 @@ msgstr "" #: src/ld.c:342 #, c-format -msgid "cannot open linker script \"%s\"" +msgid "cannot open linker script '%s'" msgstr "" #: src/ld.c:383 @@ -1914,7 +1891,7 @@ msgstr "" #: src/ld.c:582 #, c-format -msgid "invalid page size value \"%s\": ignored" +msgid "invalid page size value '%s': ignored" msgstr "" #: src/ld.c:692 @@ -1954,7 +1931,7 @@ msgstr "" #: src/ld.c:1338 #, c-format -msgid "cannot read version script \"%s\"" +msgid "cannot read version script '%s'" msgstr "" #: src/ld.c:1404 src/ld.c:1443 @@ -2059,11 +2036,6 @@ msgstr "" msgid "cannot get descriptor for ELF file (%s:%d): %s\n" msgstr "" -#: src/ldgeneric.c:1593 src/elfcmp.c:541 -#, c-format -msgid "cannot open \"%s\"" -msgstr "" - #: src/ldgeneric.c:1724 #, c-format msgid "cannot read archive `%s': %s" @@ -2126,7 +2098,7 @@ msgstr "" #: src/ldgeneric.c:3454 #, c-format -msgid "cannot find entry symbol \"%s\": defaulting to %#0*<PRIx64>" +msgid "cannot find entry symbol '%s': defaulting to %#0*<PRIx64>" msgstr "" #: src/ldgeneric.c:3460 @@ -2314,7 +2286,7 @@ msgstr "" #: src/elflint.c:364 #, c-format -msgid "unsupported OS ABI e_ident[%d] == \"%s\"\n" +msgid "unsupported OS ABI e_ident[%d] == '%s'\n" msgstr "" #: src/elflint.c:370 @@ -3500,7 +3472,7 @@ msgstr "" msgid "Locate source of text relocations in FILEs (a.out by default)." msgstr "" -#: src/findtextrel.c:222 src/ranlib.c:305 +#: src/findtextrel.c:222 src/elfcmp.c:546 src/ranlib.c:305 #, c-format msgid "cannot create ELF descriptor for '%s': %s" msgstr "" @@ -3614,7 +3586,7 @@ msgstr "" #: src/elfcmp.c:147 src/elfcmp.c:152 #, c-format -msgid "cannot get ELF header of \"%s\": %s" +msgid "cannot get ELF header of '%s': %s" msgstr "" #: src/elfcmp.c:169 @@ -3629,12 +3601,12 @@ msgstr "" #: src/elfcmp.c:253 src/elfcmp.c:259 #, c-format -msgid "cannot get content of section %zu in \"%s\": %s" +msgid "cannot get content of section %zu in '%s': %s" msgstr "" #: src/elfcmp.c:275 src/elfcmp.c:281 #, c-format -msgid "cannot get symbol in \"%s\": %s" +msgid "cannot get symbol in '%s': %s" msgstr "" #: src/elfcmp.c:302 @@ -3647,67 +3619,62 @@ msgstr "" msgid "%s %s differ: symbol table [%zu,%zu]" msgstr "" -#: src/elfcmp.c:346 +#: src/elfcmp.c:347 #, c-format msgid "%s %s differ: section [%zu] '%s' content" msgstr "" -#: src/elfcmp.c:351 +#: src/elfcmp.c:352 #, c-format msgid "%s %s differ: section [%zu,%zu] '%s' content" msgstr "" -#: src/elfcmp.c:367 +#: src/elfcmp.c:368 #, c-format msgid "%s %s differ: unequal amount of important sections" msgstr "" -#: src/elfcmp.c:401 src/elfcmp.c:406 +#: src/elfcmp.c:402 src/elfcmp.c:407 #, c-format -msgid "cannot load data of \"%s\": %s" +msgid "cannot load data of '%s': %s" msgstr "" -#: src/elfcmp.c:425 src/elfcmp.c:431 +#: src/elfcmp.c:426 src/elfcmp.c:432 #, c-format -msgid "cannot get program header entry %d of \"%s\": %s" +msgid "cannot get program header entry %d of '%s': %s" msgstr "" -#: src/elfcmp.c:437 +#: src/elfcmp.c:438 #, c-format msgid "%s %s differ: program header %d" msgstr "" -#: src/elfcmp.c:462 +#: src/elfcmp.c:463 #, c-format msgid "%s %s differ: gap" msgstr "" -#: src/elfcmp.c:521 -#, c-format -msgid "Invalid value \"%s\" for --gaps parameter." -msgstr "" - -#: src/elfcmp.c:545 +#: src/elfcmp.c:522 #, c-format -msgid "cannot create ELF descriptor for \"%s\": %s" +msgid "Invalid value '%s' for --gaps parameter." msgstr "" -#: src/elfcmp.c:550 +#: src/elfcmp.c:551 #, c-format -msgid "cannot create EBL descriptor for \"%s\"" +msgid "cannot create EBL descriptor for '%s'" msgstr "" -#: src/elfcmp.c:568 +#: src/elfcmp.c:569 #, c-format msgid "cannot get section header of section %zu: %s" msgstr "" -#: src/elfcmp.c:578 +#: src/elfcmp.c:579 #, c-format msgid "cannot get content of section %zu: %s" msgstr "" -#: src/elfcmp.c:588 src/elfcmp.c:602 +#: src/elfcmp.c:589 src/elfcmp.c:603 #, c-format msgid "cannot get relocation: %s" msgstr "" diff --git a/elfutils/src/ChangeLog b/elfutils/src/ChangeLog index 66b09544..2f7ba0f7 100644 --- a/elfutils/src/ChangeLog +++ b/elfutils/src/ChangeLog @@ -1,6 +1,22 @@ +2005-10-26 Roland McGrath <roland@redhat.com> + + * nm.c (get_var_range): dwarf_getloclist -> dwarf_getlocation. + +2005-09-03 Ulrich Drepper <drepper@redhat.com> + + * strip.c (handle_elf): Unify some error messages. + * ld.c (main): Likewise. + * ldgeneric.c (open_elf): Likewise. + * elfcmp.c (main): Likewise. + * elflint.c (check_elf_header): Likewise. + + * size.c (process_file): Fix typo in error message. + + * readelf.c: Lots of little cleanups. Use _unlocked functions. + 2005-09-02 Ulrich Drepper <drepper@redhat.com> - * strings.c (main): Reset elfmap variable afte rmunmap call. + * strings.c (main): Reset elfmap variable after munmap call. [_MUDFLAP] (map_file): Simplify mudflap debugging by not using mmap. 2005-08-28 Ulrich Drepper <drepper@redhat.com> diff --git a/elfutils/src/elfcmp.c b/elfutils/src/elfcmp.c index 1b34e6b7..32932a99 100644 --- a/elfutils/src/elfcmp.c +++ b/elfutils/src/elfcmp.c @@ -114,7 +114,7 @@ main (int argc, char *argv[]) (void) argp_parse (&argp, argc, argv, 0, &remaining, NULL); /* We expect exactly two non-option parameters. */ - if (remaining + 2 != argc) + if (unlikely (remaining + 2 != argc)) { fputs (gettext ("Invalid number of parameters.\n"), stderr); argp_help (&argp, stderr, ARGP_HELP_SEE, program_invocation_short_name); @@ -144,26 +144,26 @@ main (int argc, char *argv[]) GElf_Ehdr ehdr1_mem; GElf_Ehdr *ehdr1 = gelf_getehdr (elf1, &ehdr1_mem); if (ehdr1 == NULL) - error (EXIT_FAILURE, 0, gettext ("cannot get ELF header of \"%s\": %s"), + error (EXIT_FAILURE, 0, gettext ("cannot get ELF header of '%s': %s"), fname1, elf_errmsg (-1)); GElf_Ehdr ehdr2_mem; GElf_Ehdr *ehdr2 = gelf_getehdr (elf2, &ehdr2_mem); if (ehdr2 == NULL) - error (EXIT_FAILURE, 0, gettext ("cannot get ELF header of \"%s\": %s"), + error (EXIT_FAILURE, 0, gettext ("cannot get ELF header of '%s': %s"), fname2, elf_errmsg (-1)); /* Compare the ELF headers. */ - if (memcmp (ehdr1->e_ident, ehdr2->e_ident, EI_NIDENT) != 0 - || ehdr1->e_type != ehdr2->e_type - || ehdr1->e_machine != ehdr2->e_machine - || ehdr1->e_version != ehdr2->e_version - || ehdr1->e_entry != ehdr2->e_entry - || ehdr1->e_phoff != ehdr2->e_phoff - || ehdr1->e_flags != ehdr2->e_flags - || ehdr1->e_ehsize != ehdr2->e_ehsize - || ehdr1->e_phentsize != ehdr2->e_phentsize - || ehdr1->e_phnum != ehdr2->e_phnum - || ehdr1->e_shentsize != ehdr2->e_shentsize) + if (unlikely (memcmp (ehdr1->e_ident, ehdr2->e_ident, EI_NIDENT) != 0 + || ehdr1->e_type != ehdr2->e_type + || ehdr1->e_machine != ehdr2->e_machine + || ehdr1->e_version != ehdr2->e_version + || ehdr1->e_entry != ehdr2->e_entry + || ehdr1->e_phoff != ehdr2->e_phoff + || ehdr1->e_flags != ehdr2->e_flags + || ehdr1->e_ehsize != ehdr2->e_ehsize + || ehdr1->e_phentsize != ehdr2->e_phentsize + || ehdr1->e_phnum != ehdr2->e_phnum + || ehdr1->e_shentsize != ehdr2->e_shentsize)) { if (! quiet) error (0, 0, gettext ("%s %s diff: ELF header"), fname1, fname2); @@ -221,7 +221,7 @@ main (int argc, char *argv[]) /* Compare the headers. We allow the name to be at a different location. */ - if (strcmp (sname1, sname2) != 0) + if (unlikely (strcmp (sname1, sname2) != 0)) { header_mismatch: error (0, 0, gettext ("%s %s differ: section header"), @@ -250,13 +250,13 @@ main (int argc, char *argv[]) Elf_Data *data1 = elf_getdata (scn1, NULL); if (data1 == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot get content of section %zu in \"%s\": %s"), + gettext ("cannot get content of section %zu in '%s': %s"), elf_ndxscn (scn1), fname1, elf_errmsg (-1)); Elf_Data *data2 = elf_getdata (scn2, NULL); if (data2 == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot get content of section %zu in \"%s\": %s"), + gettext ("cannot get content of section %zu in '%s': %s"), elf_ndxscn (scn2), fname2, elf_errmsg (-1)); switch (shdr1->sh_type) @@ -272,26 +272,26 @@ main (int argc, char *argv[]) GElf_Sym *sym1 = gelf_getsym (data1, ndx, &sym1_mem); if (sym1 == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot get symbol in \"%s\": %s"), + gettext ("cannot get symbol in '%s': %s"), fname1, elf_errmsg (-1)); GElf_Sym sym2_mem; GElf_Sym *sym2 = gelf_getsym (data2, ndx, &sym2_mem); if (sym2 == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot get symbol in \"%s\": %s"), + gettext ("cannot get symbol in '%s': %s"), fname2, elf_errmsg (-1)); const char *name1 = elf_strptr (elf1, shdr1->sh_link, sym1->st_name); const char *name2 = elf_strptr (elf2, shdr2->sh_link, sym2->st_name); - if (strcmp (name1, name2) != 0 - || sym1->st_value != sym2->st_value - || (sym1->st_size != sym2->st_size - && sym1->st_shndx != SHN_UNDEF) - || sym1->st_info != sym2->st_info - || sym1->st_other != sym2->st_other - || sym1->st_shndx != sym1->st_shndx) + if (unlikely (strcmp (name1, name2) != 0 + || sym1->st_value != sym2->st_value + || (sym1->st_size != sym2->st_size + && sym1->st_shndx != SHN_UNDEF) + || sym1->st_info != sym2->st_info + || sym1->st_other != sym2->st_other + || sym1->st_shndx != sym1->st_shndx)) { // XXX Do we want to allow reordered symbol tables? symtab_mismatch: @@ -336,9 +336,10 @@ main (int argc, char *argv[]) assert (shdr2->sh_type == SHT_NOBITS || (data2->d_buf != NULL || data1->d_size == 0)); - if (data1->d_size != data2->d_size - || (shdr1->sh_type != SHT_NOBITS - && memcmp (data1->d_buf, data2->d_buf, data1->d_size) != 0)) + if (unlikely (data1->d_size != data2->d_size + || (shdr1->sh_type != SHT_NOBITS + && memcmp (data1->d_buf, data2->d_buf, + data1->d_size) != 0))) { if (! quiet) { @@ -360,7 +361,7 @@ main (int argc, char *argv[]) } } - if (scn1 != scn2) + if (unlikely (scn1 != scn2)) { if (! quiet) error (0, 0, @@ -398,12 +399,12 @@ main (int argc, char *argv[]) { raw1 = elf_rawfile (elf1, &size1); if (raw1 == NULL ) - error (EXIT_FAILURE, 0, gettext ("cannot load data of \"%s\": %s"), + error (EXIT_FAILURE, 0, gettext ("cannot load data of '%s': %s"), fname1, elf_errmsg (-1)); raw2 = elf_rawfile (elf2, &size2); if (raw2 == NULL ) - error (EXIT_FAILURE, 0, gettext ("cannot load data of \"%s\": %s"), + error (EXIT_FAILURE, 0, gettext ("cannot load data of '%s': %s"), fname2, elf_errmsg (-1)); for (size_t cnt = 0; cnt < nregions; ++cnt) @@ -422,16 +423,16 @@ main (int argc, char *argv[]) GElf_Phdr *phdr1 = gelf_getphdr (elf1, ndx, &phdr1_mem); if (ehdr1 == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot get program header entry %d of \"%s\": %s"), + gettext ("cannot get program header entry %d of '%s': %s"), ndx, fname1, elf_errmsg (-1)); GElf_Phdr phdr2_mem; GElf_Phdr *phdr2 = gelf_getphdr (elf2, ndx, &phdr2_mem); if (ehdr2 == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot get program header entry %d of \"%s\": %s"), + gettext ("cannot get program header entry %d of '%s': %s"), ndx, fname2, elf_errmsg (-1)); - if (memcmp (phdr1, phdr2, sizeof (GElf_Phdr)) != 0) + if (unlikely (memcmp (phdr1, phdr2, sizeof (GElf_Phdr)) != 0)) { if (! quiet) error (0, 0, gettext ("%s %s differ: program header %d"), @@ -454,8 +455,8 @@ main (int argc, char *argv[]) { /* Compare the [LAST,FROM) region. */ assert (gaps == gaps_match); - if (memcmp (raw1 + last, raw2 + last, - regionsarr[cnt].from - last) != 0) + if (unlikely (memcmp (raw1 + last, raw2 + last, + regionsarr[cnt].from - last) != 0)) { gapmismatch: if (!quiet) @@ -513,12 +514,12 @@ parse_opt (int key, char *arg, case OPT_GAPS: if (strcasecmp (arg, "ignore") == 0) gaps = gaps_ignore; - else if (strcasecmp (arg, "match") == 0) + else if (likely (strcasecmp (arg, "match") == 0)) gaps = gaps_match; else { fprintf (stderr, - gettext ("Invalid value \"%s\" for --gaps parameter."), + gettext ("Invalid value '%s' for --gaps parameter."), arg); argp_help (&argp, stderr, ARGP_HELP_SEE, program_invocation_short_name); @@ -538,16 +539,16 @@ open_file (const char *fname, int *fdp, Ebl **eblp) { int fd = open (fname, O_RDONLY); if (unlikely (fd == -1)) - error (EXIT_FAILURE, errno, gettext ("cannot open \"%s\""), fname); + error (EXIT_FAILURE, errno, gettext ("cannot open '%s'"), fname); Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL); if (elf == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot create ELF descriptor for \"%s\": %s"), + gettext ("cannot create ELF descriptor for '%s': %s"), fname, elf_errmsg (-1)); Ebl *ebl = ebl_openbackend (elf); if (ebl == NULL) error (EXIT_FAILURE, 0, - gettext ("cannot create EBL descriptor for \"%s\""), fname); + gettext ("cannot create EBL descriptor for '%s'"), fname); *fdp = fd; *eblp = ebl; diff --git a/elfutils/src/elflint.c b/elfutils/src/elflint.c index d91ac0f8..cf0f3ca4 100644 --- a/elfutils/src/elflint.c +++ b/elfutils/src/elflint.c @@ -361,7 +361,7 @@ check_elf_header (Ebl *ebl, GElf_Ehdr *ehdr, size_t size) /* We currently don't handle any OS ABIs. */ if (ehdr->e_ident[EI_OSABI] != ELFOSABI_NONE) - ERROR (gettext ("unsupported OS ABI e_ident[%d] == \"%s\"\n"), + ERROR (gettext ("unsupported OS ABI e_ident[%d] == '%s'\n"), EI_OSABI, ebl_osabi_name (ebl, ehdr->e_ident[EI_OSABI], buf, sizeof (buf))); diff --git a/elfutils/src/ld.c b/elfutils/src/ld.c index 2aece00e..74d1dfb4 100644 --- a/elfutils/src/ld.c +++ b/elfutils/src/ld.c @@ -339,7 +339,7 @@ main (int argc, char *argv[]) statements in the script. This simply must not happen. */ ldin = fopen (linker_script, "r"); if (ldin == NULL) - error (EXIT_FAILURE, errno, gettext ("cannot open linker script \"%s\""), + error (EXIT_FAILURE, errno, gettext ("cannot open linker script '%s'"), linker_script); /* No need for locking. */ __fsetlocking (ldin, FSETLOCKING_BYCALLER); @@ -579,7 +579,7 @@ parse_opt_1st (int key, char *arg, else { error (0, 0, - gettext ("invalid page size value \"%s\": ignored"), + gettext ("invalid page size value '%s': ignored"), arg); ld_state.pagesize = 0; } @@ -1335,7 +1335,7 @@ read_version_script (const char *fname) or absolute) path. No search along a path will be performed. */ ldin = fopen (fname, "r"); if (ldin == NULL) - error (EXIT_FAILURE, errno, gettext ("cannot read version script \"%s\""), + error (EXIT_FAILURE, errno, gettext ("cannot read version script '%s'"), fname); /* No need for locking. */ __fsetlocking (ldin, FSETLOCKING_BYCALLER); diff --git a/elfutils/src/ldgeneric.c b/elfutils/src/ldgeneric.c index 1b6c7207..6f8a042c 100644 --- a/elfutils/src/ldgeneric.c +++ b/elfutils/src/ldgeneric.c @@ -1590,7 +1590,7 @@ open_elf (struct usedfiles *fileinfo, Elf *elf) __fsetlocking (ldin, FSETLOCKING_BYCALLER); if (ldin == NULL) - error (EXIT_FAILURE, errno, gettext ("cannot open \"%s\""), + error (EXIT_FAILURE, errno, gettext ("cannot open '%s'"), fileinfo->rfname); /* Parse the file. If it is a linker script no problems will be @@ -3452,7 +3452,7 @@ find_entry_point (void) { if (ld_state.entry != NULL) error (0, 0, gettext ("\ -cannot find entry symbol \"%s\": defaulting to %#0*" PRIx64), +cannot find entry symbol '%s': defaulting to %#0*" PRIx64), ld_state.entry, xelf_getclass (ld_state.outelf) == ELFCLASS32 ? 10 : 18, (uint64_t) result); diff --git a/elfutils/src/nm.c b/elfutils/src/nm.c index 2e3d1615..d4d66be6 100644 --- a/elfutils/src/nm.c +++ b/elfutils/src/nm.c @@ -365,7 +365,7 @@ process_file (const char *fname, bool more_than_one) INTERNAL_ERROR (fname); if (close (fd) != 0) - error (EXIT_FAILURE, errno, gettext ("while close '%s'"), fname); + error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname); return result; } @@ -377,7 +377,7 @@ process_file (const char *fname, bool more_than_one) INTERNAL_ERROR (fname); if (close (fd) != 0) - error (EXIT_FAILURE, errno, gettext ("while close '%s'"), fname); + error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname); return result; } @@ -582,9 +582,9 @@ get_var_range (Dwarf_Die *die, Dwarf_Word *lowpc, Dwarf_Word *highpc) if (locattr == NULL) return 1; - Dwarf_Loc *loc; + Dwarf_Op *loc; size_t nloc; - if (dwarf_getloclist (locattr, &loc, &nloc) != 0) + if (dwarf_getlocation (locattr, &loc, &nloc) != 0) return 1; /* Interpret the location expressions. */ diff --git a/elfutils/src/readelf.c b/elfutils/src/readelf.c index ac902cd3..1902ef18 100644 --- a/elfutils/src/readelf.c +++ b/elfutils/src/readelf.c @@ -380,8 +380,6 @@ process_file (int fd, Elf *elf, const char *prefix, const char *fname, case ELF_K_AR: { - Elf *subelf; - Elf_Cmd cmd = ELF_C_READ_MMAP; size_t prefix_len = prefix == NULL ? 0 : strlen (prefix); size_t fname_len = strlen (fname) + 1; char new_prefix[prefix_len + 1 + fname_len]; @@ -396,6 +394,8 @@ process_file (int fd, Elf *elf, const char *prefix, const char *fname, memcpy (cp, fname, fname_len); /* It's an archive. We process each file in it. */ + Elf *subelf; + Elf_Cmd cmd = ELF_C_READ_MMAP; while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { kind = elf_kind (subelf); @@ -440,7 +440,6 @@ process_elf_file (Elf *elf, const char *prefix, const char *fname, { GElf_Ehdr ehdr_mem; GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); - Ebl *ebl; /* Print the file name. */ if (!only_one) @@ -457,7 +456,7 @@ process_elf_file (Elf *elf, const char *prefix, const char *fname, return; } - ebl = ebl_openbackend (elf); + Ebl *ebl = ebl_openbackend (elf); if (ebl == NULL) { error (0, errno, gettext ("cannot create EBL handle")); @@ -530,11 +529,8 @@ print_file_type (unsigned short int e_type) static void print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) { - char buf[512]; - size_t cnt; - fputs_unlocked (gettext ("ELF Header:\n Magic: "), stdout); - for (cnt = 0; cnt < EI_NIDENT; ++cnt) + for (size_t cnt = 0; cnt < EI_NIDENT; ++cnt) printf (" %02hhx", ehdr->e_ident[cnt]); printf (gettext ("\n Class: %s\n"), @@ -553,6 +549,7 @@ print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) ehdr->e_ident[EI_VERSION] == EV_CURRENT ? gettext ("(current)") : "(\?\?\?)"); + char buf[512]; printf (gettext (" OS/ABI: %s\n"), ebl_osabi_name (ebl, ehdr->e_ident[EI_OSABI], buf, sizeof (buf))); @@ -597,9 +594,7 @@ print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) if (ehdr->e_shnum == 0) { GElf_Shdr shdr_mem; - GElf_Shdr *shdr; - - shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); + GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); if (shdr != NULL) printf (gettext (" (%" PRIu32 " in [0].sh_size)"), (uint32_t) shdr->sh_size); @@ -611,9 +606,7 @@ print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) if (ehdr->e_shstrndx == SHN_XINDEX) { GElf_Shdr shdr_mem; - GElf_Shdr *shdr; - - shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); + GElf_Shdr *shdr = gelf_getshdr (elf_getscn (ebl->elf, 0), &shdr_mem); if (shdr != NULL) /* We managed to get the zeroth section. */ snprintf (buf, sizeof (buf), gettext (" (%" PRIu32 " in [0].sh_link)"), @@ -679,24 +672,21 @@ There are %d section headers, starting at offset %#" PRIx64 ":\n\ for (cnt = 0; cnt < shnum; ++cnt) { - char buf[128]; - char flagbuf[20]; - char *cp; Elf_Scn *scn = elf_getscn (ebl->elf, cnt); - GElf_Shdr shdr_mem; - GElf_Shdr *shdr; if (scn == NULL) error (EXIT_FAILURE, 0, gettext ("cannot get section: %s"), elf_errmsg (-1)); /* Get the section header. */ - shdr = gelf_getshdr (scn, &shdr_mem); + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); if (shdr == NULL) error (EXIT_FAILURE, 0, gettext ("cannot get section header: %s"), elf_errmsg (-1)); - cp = flagbuf; + char flagbuf[20]; + char *cp = flagbuf; if (shdr->sh_flags & SHF_WRITE) *cp++ = 'W'; if (shdr->sh_flags & SHF_ALLOC) @@ -723,6 +713,7 @@ There are %d section headers, starting at offset %#" PRIx64 ":\n\ *cp++ = 'E'; *cp = '\0'; + char buf[128]; printf ("[%2zu] %-20s %-12s %0*" PRIx64 " %0*" PRIx64 " %0*" PRIx64 " %2" PRId64 " %-5s %2" PRId32 " %3" PRId32 " %2" PRId64 "\n", @@ -745,9 +736,6 @@ There are %d section headers, starting at offset %#" PRIx64 ":\n\ static void print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) { - size_t cnt; - size_t shstrndx; - if (ehdr->e_phnum == 0) /* No program header, this is OK in relocatable objects. */ return; @@ -764,7 +752,7 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) bool has_relro = false; GElf_Addr relro_from = 0; GElf_Addr relro_to = 0; - for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) + for (size_t cnt = 0; cnt < ehdr->e_phnum; ++cnt) { char buf[128]; GElf_Phdr mem; @@ -809,21 +797,20 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) } /* Get the section header string table index. */ + size_t shstrndx; if (elf_getshstrndx (ebl->elf, &shstrndx) < 0) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); puts (gettext ("\n Section to Segment mapping:\n Segment Sections...")); - for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) + for (size_t cnt = 0; cnt < ehdr->e_phnum; ++cnt) { - GElf_Phdr phdr_mem; - GElf_Phdr *phdr = gelf_getphdr (ebl->elf, cnt, &phdr_mem); - size_t inner; - /* Print the segment number. */ printf (" %2.2zu ", cnt); + GElf_Phdr phdr_mem; + GElf_Phdr *phdr = gelf_getphdr (ebl->elf, cnt, &phdr_mem); /* This must not happen. */ if (phdr == NULL) error (EXIT_FAILURE, 0, gettext ("cannot get program header: %s"), @@ -832,19 +819,17 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) /* Iterate over the sections. */ bool in_relro = false; bool in_ro = false; - for (inner = 1; inner < shnum; ++inner) + for (size_t inner = 1; inner < shnum; ++inner) { Elf_Scn *scn = elf_getscn (ebl->elf, inner); - GElf_Shdr shdr_mem; - GElf_Shdr *shdr; - - /* It should not happen. */ + /* This should not happen. */ if (scn == NULL) error (EXIT_FAILURE, 0, gettext ("cannot get section: %s"), elf_errmsg (-1)); /* Get the section header. */ - shdr = gelf_getshdr (scn, &shdr_mem); + GElf_Shdr shdr_mem; + GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); if (shdr == NULL) error (EXIT_FAILURE, 0, gettext ("cannot get section header: %s"), @@ -940,34 +925,27 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) static void handle_scngrp (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { - Elf_Data *data; - Elf32_Word *grpref; - Elf_Scn *symscn; - GElf_Shdr symshdr_mem; - GElf_Shdr *symshdr; - Elf_Data *symdata; - GElf_Sym sym_mem; - size_t cnt; - size_t shstrndx; - /* Get the data of the section. */ - data = elf_getdata (scn, NULL); + Elf_Data *data = elf_getdata (scn, NULL); - symscn = elf_getscn (ebl->elf, shdr->sh_link); - symshdr = gelf_getshdr (symscn, &symshdr_mem); - symdata = elf_getdata (symscn, NULL); + Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); + GElf_Shdr symshdr_mem; + GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem); + Elf_Data *symdata = elf_getdata (symscn, NULL); if (data == NULL || data->d_size < sizeof (Elf32_Word) || symshdr == NULL || symdata == NULL) return; /* Get the section header string table index. */ + size_t shstrndx; if (elf_getshstrndx (ebl->elf, &shstrndx) < 0) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); - grpref = (Elf32_Word *) data->d_buf; + Elf32_Word *grpref = (Elf32_Word *) data->d_buf; + GElf_Sym sym_mem; printf ((grpref[0] & GRP_COMDAT) ? ngettext ("\ \nCOMDAT section group [%2zu] '%s' with signature '%s' contains %zu entry:\n", @@ -985,21 +963,18 @@ handle_scngrp (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) ?: gettext ("<INVALID SYMBOL>"), data->d_size / sizeof (Elf32_Word) - 1); - for (cnt = 1; cnt < data->d_size / sizeof (Elf32_Word); ++cnt) + for (size_t cnt = 1; cnt < data->d_size / sizeof (Elf32_Word); ++cnt) { GElf_Shdr grpshdr_mem; - GElf_Shdr *grpshdr; - - grpshdr = gelf_getshdr (elf_getscn (ebl->elf, grpref[cnt]), - &grpshdr_mem); - - if (grpshdr == NULL) - printf (gettext (" [%2u] <INVALID SECTION>\n"), grpref[cnt]); - else - printf (" [%2u] %s\n", - grpref[cnt], - elf_strptr (ebl->elf, shstrndx, grpshdr->sh_name) - ?: gettext ("<INVALID SECTION>")); + GElf_Shdr *grpshdr = gelf_getshdr (elf_getscn (ebl->elf, grpref[cnt]), + &grpshdr_mem); + + const char *str; + printf (" [%2u] %s\n", + grpref[cnt], + grpshdr != NULL + && (str = elf_strptr (ebl->elf, shstrndx, grpshdr->sh_name)) + ? str : gettext ("<INVALID SECTION>")); } } @@ -1166,14 +1141,12 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) for (cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) { - char buf[64]; GElf_Dyn dynmem; - GElf_Dyn *dyn; - - dyn = gelf_getdyn (data, cnt, &dynmem); + GElf_Dyn *dyn = gelf_getdyn (data, cnt, &dynmem); if (dyn == NULL) break; + char buf[64]; printf (" %-17s ", ebl_dynamic_tag_name (ebl, dyn->d_tag, buf, sizeof (buf))); @@ -1184,7 +1157,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) case DT_BIND_NOW: case DT_TEXTREL: /* No further output. */ - fputc ('\n', stdout); + fputc_unlocked ('\n', stdout); break; case DT_NEEDED: @@ -1314,31 +1287,22 @@ handle_relocs_rel (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { int class = gelf_getclass (ebl->elf); int nentries = shdr->sh_size / shdr->sh_entsize; - int cnt; - Elf_Data *data; - Elf_Scn *symscn; - GElf_Shdr symshdr_mem; - GElf_Shdr *symshdr; - Elf_Data *symdata; - GElf_Shdr destshdr_mem; - GElf_Shdr *destshdr; - Elf_Scn *xndxscn; - Elf_Data *xndxdata = NULL; - size_t shstrndx; /* Get the data of the section. */ - data = elf_getdata (scn, NULL); + Elf_Data *data = elf_getdata (scn, NULL); if (data == NULL) return; /* Get the symbol table information. */ - symscn = elf_getscn (ebl->elf, shdr->sh_link); - symshdr = gelf_getshdr (symscn, &symshdr_mem); - symdata = elf_getdata (symscn, NULL); + Elf_Scn *symscn = elf_getscn (ebl->elf, shdr->sh_link); + GElf_Shdr symshdr_mem; + GElf_Shdr *symshdr = gelf_getshdr (symscn, &symshdr_mem); + Elf_Data *symdata = elf_getdata (symscn, NULL); /* Get the section header of the section the relocations are for. */ - destshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_info), - &destshdr_mem); + GElf_Shdr destshdr_mem; + GElf_Shdr *destshdr = gelf_getshdr (elf_getscn (ebl->elf, shdr->sh_info), + &destshdr_mem); if (symshdr == NULL || symdata == NULL || destshdr == NULL) { @@ -1348,13 +1312,12 @@ handle_relocs_rel (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) } /* Search for the optional extended section index table. */ - xndxscn = NULL; + Elf_Scn *xndxscn = NULL; + Elf_Data *xndxdata = NULL; while ((xndxscn = elf_nextscn (ebl->elf, xndxscn)) != NULL) { GElf_Shdr xndxshdr_mem; - GElf_Shdr *xndxshdr; - - xndxshdr = gelf_getshdr (xndxscn, &xndxshdr_mem); + GElf_Shdr *xndxshdr = gelf_getshdr (xndxscn, &xndxshdr_mem); if (xndxshdr != NULL && xndxshdr->sh_type == SHT_SYMTAB_SHNDX && xndxshdr->sh_link == elf_ndxscn (symscn)) { @@ -1365,6 +1328,7 @@ handle_relocs_rel (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) } /* Get the section header string table index. */ + size_t shstrndx; if (elf_getshstrndx (ebl->elf, &shstrndx) < 0) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); @@ -1401,21 +1365,18 @@ handle_relocs_rel (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) Offset Type Value Name\n"), stdout); - for (cnt = 0; cnt < nentries; ++cnt) + for (int cnt = 0; cnt < nentries; ++cnt) { GElf_Rel relmem; - GElf_Rel *rel; - - rel = gelf_getrel (data, cnt, &relmem); + GElf_Rel *rel = gelf_getrel (data, cnt, &relmem); if (rel != NULL) { char buf[128]; GElf_Sym symmem; - GElf_Sym *sym; Elf32_Word xndx; - - sym = gelf_getsymshndx (symdata, xndxdata, GELF_R_SYM (rel->r_info), - &symmem, &xndx); + GElf_Sym *sym = gelf_getsymshndx (symdata, xndxdata, + GELF_R_SYM (rel->r_info), + &symmem, &xndx); if (sym == NULL) printf (" %#0*" PRIx64 " %-20s <%s %ld>\n", class == ELFCLASS32 ? 10 : 18, rel->r_offset, @@ -1510,9 +1471,7 @@ handle_relocs_rela (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) while ((xndxscn = elf_nextscn (ebl->elf, xndxscn)) != NULL) { GElf_Shdr xndxshdr_mem; - GElf_Shdr *xndxshdr; - - xndxshdr = gelf_getshdr (xndxscn, &xndxshdr_mem); + GElf_Shdr *xndxshdr = gelf_getshdr (xndxscn, &xndxshdr_mem); if (xndxshdr != NULL && xndxshdr->sh_type == SHT_SYMTAB_SHNDX && xndxshdr->sh_link == elf_ndxscn (symscn)) { @@ -1554,11 +1513,10 @@ handle_relocs_rela (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { char buf[64]; GElf_Sym symmem; - GElf_Sym *sym; Elf32_Word xndx; - - sym = gelf_getsymshndx (symdata, xndxdata, GELF_R_SYM (rel->r_info), - &symmem, &xndx); + GElf_Sym *sym = gelf_getsymshndx (symdata, xndxdata, + GELF_R_SYM (rel->r_info), + &symmem, &xndx); if (sym == NULL) printf (" %#0*" PRIx64 " %-15s <%s %ld>\n", @@ -1649,23 +1607,17 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) Elf_Data *verneed_data = NULL; Elf_Data *verdef_data = NULL; Elf_Data *xndx_data = NULL; - Elf_Scn *runscn; - Elf_Data *data; int class = gelf_getclass (ebl->elf); - unsigned int nsyms; - unsigned int cnt; Elf32_Word verneed_stridx = 0; Elf32_Word verdef_stridx = 0; - GElf_Shdr glink; - size_t shstrndx; /* Get the data of the section. */ - data = elf_getdata (scn, NULL); + Elf_Data *data = elf_getdata (scn, NULL); if (data == NULL) return; /* Find out whether we have other sections we might need. */ - runscn = NULL; + Elf_Scn *runscn = NULL; while ((runscn = elf_nextscn (ebl->elf, runscn)) != NULL) { GElf_Shdr runshdr_mem; @@ -1697,19 +1649,22 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) } /* Get the section header string table index. */ + size_t shstrndx; if (elf_getshstrndx (ebl->elf, &shstrndx) < 0) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); /* Now we can compute the number of entries in the section. */ - nsyms = data->d_size / (class == ELFCLASS32 - ? sizeof (Elf32_Sym) : sizeof (Elf64_Sym)); + unsigned int nsyms = data->d_size / (class == ELFCLASS32 + ? sizeof (Elf32_Sym) + : sizeof (Elf64_Sym)); printf (ngettext ("\nSymbol table [%2u] '%s' contains %u entry:\n", "\nSymbol table [%2u] '%s' contains %u entries:\n", nsyms), (unsigned int) elf_ndxscn (scn), elf_strptr (ebl->elf, shstrndx, shdr->sh_name), nsyms); + GElf_Shdr glink; printf (ngettext (" %lu local symbol String table: [%2u] '%s'\n", " %lu local symbols String table: [%2u] '%s'\n", shdr->sh_info), @@ -1726,7 +1681,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) Num: Value Size Type Bind Vis Ndx Name\n"), stdout); - for (cnt = 0; cnt < nsyms; ++cnt) + for (unsigned int cnt = 0; cnt < nsyms; ++cnt) { char typebuf[64]; char bindbuf[64]; @@ -1761,9 +1716,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { /* Get the version information. */ GElf_Versym versym_mem; - GElf_Versym *versym; - - versym = gelf_getversym (versym_data, cnt, &versym_mem); + GElf_Versym *versym = gelf_getversym (versym_data, cnt, &versym_mem); if (versym != NULL && ((*versym & 0x8000) != 0 || *versym > 1)) { @@ -1783,13 +1736,13 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) if (is_nobits || ! check_def) { /* We must test both. */ - GElf_Verneed verneed_mem; - GElf_Verneed *verneed; GElf_Vernaux vernaux_mem; GElf_Vernaux *vernaux = NULL; size_t vn_offset = 0; - verneed = gelf_getverneed (verneed_data, 0, &verneed_mem); + GElf_Verneed verneed_mem; + GElf_Verneed *verneed = gelf_getverneed (verneed_data, 0, + &verneed_mem); while (verneed != NULL) { size_t vna_offset = vn_offset; @@ -1840,11 +1793,11 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) if (check_def && *versym != 0x8001) { /* We must test both. */ - GElf_Verdef verdef_mem; - GElf_Verdef *verdef; size_t vd_offset = 0; - verdef = gelf_getverdef (verdef_data, 0, &verdef_mem); + GElf_Verdef verdef_mem; + GElf_Verdef *verdef = gelf_getverdef (verdef_data, 0, + &verdef_mem); while (verdef != NULL) { if (verdef->vd_ndx == (*versym & 0x7fff)) @@ -1861,11 +1814,10 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) if (verdef != NULL) { GElf_Verdaux verdaux_mem; - GElf_Verdaux *verdaux; - - verdaux = gelf_getverdaux (verdef_data, - vd_offset + verdef->vd_aux, - &verdaux_mem); + GElf_Verdaux *verdaux + = gelf_getverdaux (verdef_data, + vd_offset + verdef->vd_aux, + &verdaux_mem); if (verdaux != NULL) printf ((*versym & 0x8000) ? "@%s" : "@@%s", @@ -1876,7 +1828,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) } } - putchar ('\n'); + putchar_unlocked ('\n'); } } @@ -2086,7 +2038,6 @@ static void handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { int class = gelf_getclass (ebl->elf); - GElf_Shdr glink; const char **vername; const char **filename; @@ -2234,18 +2185,15 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) for (unsigned int cnt = 0; cnt < defshdr->sh_info; ++cnt) { - GElf_Verdef defmem; - GElf_Verdef *def; - GElf_Verdaux auxmem; - GElf_Verdaux *aux; /* Get the data at the next offset. */ - def = gelf_getverdef (defdata, offset, &defmem); - if (def == NULL) - break; - - aux = gelf_getverdaux (defdata, offset + def->vd_aux, &auxmem); - if (aux == NULL) + GElf_Verdef defmem; + GElf_Verdef *def = gelf_getverdef (defdata, offset, &defmem); + GElf_Verdaux auxmem; + GElf_Verdaux *aux = gelf_getverdaux (defdata, + offset + def->vd_aux, + &auxmem); + if (def == NULL || aux == NULL) break; vername[def->vd_ndx & 0x7fff] @@ -2258,38 +2206,29 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) if (needscn != NULL) { unsigned int offset = 0; - Elf_Data *needdata; - GElf_Shdr needshdrmem; - GElf_Shdr *needshdr; - - needdata = elf_getdata (needscn, NULL); - if (needdata == NULL) - return; - needshdr = gelf_getshdr (needscn, &needshdrmem); - if (needshdr == NULL) + Elf_Data *needdata = elf_getdata (needscn, NULL); + GElf_Shdr needshdrmem; + GElf_Shdr *needshdr = gelf_getshdr (needscn, &needshdrmem); + if (needdata == NULL || needshdr == NULL) return; for (unsigned int cnt = 0; cnt < needshdr->sh_info; ++cnt) { - GElf_Verneed needmem; - GElf_Verneed *need; - unsigned int auxoffset; - int cnt2; - /* Get the data at the next offset. */ - need = gelf_getverneed (needdata, offset, &needmem); + GElf_Verneed needmem; + GElf_Verneed *need = gelf_getverneed (needdata, offset, + &needmem); if (need == NULL) break; /* Run through the auxiliary entries. */ - auxoffset = offset + need->vn_aux; - for (cnt2 = need->vn_cnt; --cnt2 >= 0; ) + unsigned int auxoffset = offset + need->vn_aux; + for (int cnt2 = need->vn_cnt; --cnt2 >= 0; ) { GElf_Vernaux auxmem; - GElf_Vernaux *aux; - - aux = gelf_getvernaux (needdata, auxoffset, &auxmem); + GElf_Vernaux *aux = gelf_getvernaux (needdata, auxoffset, + &auxmem); if (aux == NULL) break; @@ -2313,6 +2252,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) } /* Print the header. */ + GElf_Shdr glink; printf (ngettext ("\ \nVersion symbols section [%2u] '%s' contains %d entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'", "\ @@ -2331,19 +2271,17 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) /* Now we can finally look at the actual contents of this section. */ for (unsigned int cnt = 0; cnt < shdr->sh_size / shdr->sh_entsize; ++cnt) { - GElf_Versym symmem; - GElf_Versym *sym; - ssize_t n; - if (cnt % 2 == 0) printf ("\n %4d:", cnt); - sym = gelf_getversym (data, cnt, &symmem); + GElf_Versym symmem; + GElf_Versym *sym = gelf_getversym (data, cnt, &symmem); if (sym == NULL) break; switch (*sym) { + ssize_t n; case 0: fputs_unlocked (gettext (" 0 *local* "), stdout); @@ -2366,23 +2304,22 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) break; } } - putchar ('\n'); + putchar_unlocked ('\n'); } +/* Find the symbol table(s). For this we have to search through the + section table. */ static void handle_hash (Ebl *ebl) { - /* Find the symbol table(s). For this we have to search through the - section table. */ - Elf_Scn *scn = NULL; - size_t shstrndx; - /* Get the section header string table index. */ + size_t shstrndx; if (elf_getshstrndx (ebl->elf, &shstrndx) < 0) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); + Elf_Scn *scn = NULL; while ((scn = elf_nextscn (ebl->elf, scn)) != NULL) { /* Handle the section if it is a symbol table. */ @@ -2392,18 +2329,6 @@ handle_hash (Ebl *ebl) if (shdr != NULL && shdr->sh_type == SHT_HASH) { Elf_Data *data = elf_getdata (scn, NULL); - Elf32_Word nbucket; - Elf32_Word nchain; - Elf32_Word *bucket; - Elf32_Word *chain; - uint32_t *lengths; - uint32_t *counts; - Elf32_Word cnt; - Elf32_Word maxlength = 0; - Elf32_Word nsyms = 0; - uint64_t nzero_counts = 0; - GElf_Shdr glink; - if (data == NULL) { error (0, 0, gettext ("cannot get data for section %d: %s"), @@ -2411,11 +2336,12 @@ handle_hash (Ebl *ebl) continue; } - nbucket = ((Elf32_Word *) data->d_buf)[0]; - nchain = ((Elf32_Word *) data->d_buf)[1]; - bucket = &((Elf32_Word *) data->d_buf)[2]; - chain = &((Elf32_Word *) data->d_buf)[2 + nbucket]; + Elf32_Word nbucket = ((Elf32_Word *) data->d_buf)[0]; + Elf32_Word nchain = ((Elf32_Word *) data->d_buf)[1]; + Elf32_Word *bucket = &((Elf32_Word *) data->d_buf)[2]; + Elf32_Word *chain = &((Elf32_Word *) data->d_buf)[2 + nbucket]; + GElf_Shdr glink; printf (ngettext ("\ \nHistogram for bucket list length in section [%2u] '%s' (total of %d bucket):\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 " Link to section: [%2u] '%s'\n", "\ @@ -2433,14 +2359,15 @@ handle_hash (Ebl *ebl) shdr->sh_link), &glink)->sh_name)); - lengths = (uint32_t *) xcalloc (nbucket, sizeof (uint32_t)); + uint32_t *lengths = (uint32_t *) xcalloc (nbucket, + sizeof (uint32_t)); - for (cnt = 0; cnt < nbucket; ++cnt) + Elf32_Word maxlength = 0; + Elf32_Word nsyms = 0; + for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt) if (bucket[cnt] != 0) { - Elf32_Word inner; - - inner = bucket[cnt]; + Elf32_Word inner = bucket[cnt]; while (inner > 0 && inner < nchain) { ++nsyms; @@ -2451,21 +2378,23 @@ handle_hash (Ebl *ebl) } } - counts = (uint32_t *) xcalloc (maxlength + 1, sizeof (uint32_t)); + uint32_t *counts = (uint32_t *) xcalloc (maxlength + 1, + sizeof (uint32_t)); - for (cnt = 0; cnt < nbucket; ++cnt) + for (Elf32_Word cnt = 0; cnt < nbucket; ++cnt) ++counts[lengths[cnt]]; if (nbucket > 0) { uint64_t success = 0; - Elf32_Word acc; - puts (gettext (" Length Number % of total Coverage")); + fputs_unlocked (gettext ("\ + Length Number % of total Coverage\n"), stdout); printf (gettext (" 0 %6" PRIu32 " %5.1f%%\n"), counts[0], (counts[0] * 100.0) / nbucket); - for (cnt = 1; cnt <= maxlength; ++cnt) + uint64_t nzero_counts = 0; + for (Elf32_Word cnt = 1; cnt <= maxlength; ++cnt) { nzero_counts += counts[cnt] * cnt; printf (gettext ("\ @@ -2475,8 +2404,8 @@ handle_hash (Ebl *ebl) (nzero_counts * 100.0) / nsyms); } - acc = 0; - for (cnt = 1; cnt <= maxlength; ++cnt) + Elf32_Word acc = 0; + for (Elf32_Word cnt = 1; cnt <= maxlength; ++cnt) { acc += cnt; success += counts[cnt] * acc; diff --git a/elfutils/src/size.c b/elfutils/src/size.c index 4dc7baf3..bb0584f4 100644 --- a/elfutils/src/size.c +++ b/elfutils/src/size.c @@ -251,7 +251,7 @@ parse_opt (int key, char *arg, case OPT_FORMAT: if (strcmp (arg, "bsd") == 0 || strcmp (arg, "berkeley") == 0) format = format_bsd; - else if (strcmp (arg, "sysv") == 0) + else if (likely (strcmp (arg, "sysv") == 0)) format = format_sysv; else error (EXIT_FAILURE, 0, gettext ("Invalid format: %s"), arg); @@ -279,42 +279,38 @@ parse_opt (int key, char *arg, } +/* Open the file and determine the type. */ static int process_file (const char *fname) { - /* Open the file and determine the type. */ - int fd; - Elf *elf; - - /* Open the file. */ - fd = open (fname, O_RDONLY); - if (fd == -1) + int fd = open (fname, O_RDONLY); + if (unlikely (fd == -1)) { - error (0, errno, gettext ("cannot open '%s"), fname); + error (0, errno, gettext ("cannot open '%s'"), fname); return 1; } /* Now get the ELF descriptor. */ - elf = elf_begin (fd, ELF_C_READ_MMAP, NULL); - if (elf != NULL) + Elf *elf = elf_begin (fd, ELF_C_READ_MMAP, NULL); + if (likely (elf != NULL)) { if (elf_kind (elf) == ELF_K_ELF) { handle_elf (elf, NULL, fname); - if (elf_end (elf) != 0) + if (unlikely (elf_end (elf) != 0)) INTERNAL_ERROR (fname); - if (close (fd) != 0) - error (EXIT_FAILURE, errno, gettext ("while close '%s'"), fname); + if (unlikely (close (fd) != 0)) + error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname); return 0; } - else + else if (likely (elf_kind (elf) == ELF_K_AR)) return handle_ar (fd, elf, NULL, fname); /* We cannot handle this type. Close the descriptor anyway. */ - if (elf_end (elf) != 0) + if (unlikely (elf_end (elf) != 0)) INTERNAL_ERROR (fname); } @@ -351,12 +347,9 @@ print_header (Elf *elf) static int handle_ar (int fd, Elf *elf, const char *prefix, const char *fname) { - Elf *subelf; - Elf_Cmd cmd = ELF_C_READ_MMAP; size_t prefix_len = prefix == NULL ? 0 : strlen (prefix); size_t fname_len = strlen (fname) + 1; char new_prefix[prefix_len + 1 + fname_len]; - int result = 0; char *cp = new_prefix; /* Create the full name of the file. */ @@ -368,6 +361,9 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname) memcpy (cp, fname, fname_len); /* Process all the files contained in the archive. */ + int result = 0; + Elf *subelf; + Elf_Cmd cmd = ELF_C_READ_MMAP; while ((subelf = elf_begin (fd, cmd, elf)) != NULL) { /* The the header for this element. */ @@ -375,21 +371,21 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname) if (elf_kind (subelf) == ELF_K_ELF) handle_elf (subelf, new_prefix, arhdr->ar_name); - else if (elf_kind (subelf) == ELF_K_AR) + else if (likely (elf_kind (subelf) == ELF_K_AR)) result |= handle_ar (fd, subelf, new_prefix, arhdr->ar_name); /* else signal error??? */ /* Get next archive element. */ cmd = elf_next (subelf); - if (elf_end (subelf) != 0) + if (unlikely (elf_end (subelf) != 0)) INTERNAL_ERROR (fname); } - if (elf_end (elf) != 0) + if (unlikely (elf_end (elf) != 0)) INTERNAL_ERROR (fname); - if (close (fd) != 0) - error (EXIT_FAILURE, errno, gettext ("while closing `%s'"), fname); + if (unlikely (close (fd) != 0)) + error (EXIT_FAILURE, errno, gettext ("while closing '%s'"), fname); return result; } @@ -400,22 +396,20 @@ static void show_sysv (Elf *elf, const char *prefix, const char *fname, const char *fullname) { - size_t shstrndx; - Elf_Scn *scn = NULL; - GElf_Shdr shdr_mem; int maxlen = 10; - int digits = length_map[gelf_getclass (elf) - 1][radix]; - const char *fmtstr; - GElf_Off total = 0; + const int digits = length_map[gelf_getclass (elf) - 1][radix]; /* Get the section header string table index. */ - if (elf_getshstrndx (elf, &shstrndx) < 0) + size_t shstrndx; + if (unlikely (elf_getshstrndx (elf, &shstrndx) < 0)) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); /* First round over the sections: determine the longest section name. */ + Elf_Scn *scn = NULL; while ((scn = elf_nextscn (elf, scn)) != NULL) { + GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); if (shdr == NULL) @@ -436,6 +430,7 @@ show_sysv (Elf *elf, const char *prefix, const char *fname, digits - 2, sgettext ("sysv|size"), digits, sgettext ("sysv|addr")); + const char *fmtstr; if (radix == radix_hex) fmtstr = "%-*s %*" PRIx64 " %*" PRIx64 "\n"; else if (radix == radix_decimal) @@ -444,8 +439,10 @@ show_sysv (Elf *elf, const char *prefix, const char *fname, fmtstr = "%-*s %*" PRIo64 " %*" PRIo64 "\n"; /* Iterate over all sections. */ + GElf_Off total = 0; while ((scn = elf_nextscn (elf, scn)) != NULL) { + GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); /* Ignore all sections which are not used at runtime. */ @@ -476,18 +473,13 @@ show_sysv (Elf *elf, const char *prefix, const char *fname, static void show_sysv_one_line (Elf *elf) { - size_t shstrndx; - Elf_Scn *scn = NULL; - GElf_Shdr shdr_mem; - const char *fmtstr; - GElf_Off total = 0; - int first = 1; - /* Get the section header string table index. */ - if (elf_getshstrndx (elf, &shstrndx) < 0) + size_t shstrndx; + if (unlikely (elf_getshstrndx (elf, &shstrndx) < 0)) error (EXIT_FAILURE, 0, gettext ("cannot get section header string table index")); + const char *fmtstr; if (radix == radix_hex) fmtstr = "%" PRIx64 "(%s)"; else if (radix == radix_decimal) @@ -496,8 +488,12 @@ show_sysv_one_line (Elf *elf) fmtstr = "%" PRIo64 "(%s)"; /* Iterate over all sections. */ + GElf_Off total = 0; + bool first = true; + Elf_Scn *scn = NULL; while ((scn = elf_nextscn (elf, scn)) != NULL) { + GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); /* Ignore all sections which are not used at runtime. */ @@ -506,7 +502,7 @@ show_sysv_one_line (Elf *elf) if (! first) fputs_unlocked (" + ", stdout); - first = 0; + first = false; printf (fmtstr, shdr->sh_size, elf_strptr (elf, shstrndx, shdr->sh_name)); @@ -534,17 +530,17 @@ static void show_bsd (Elf *elf, const char *prefix, const char *fname, const char *fullname) { - Elf_Scn *scn = NULL; - GElf_Shdr shdr_mem; GElf_Off textsize = 0; GElf_Off datasize = 0; GElf_Off bsssize = 0; - int ddigits = length_map[gelf_getclass (elf) - 1][radix_decimal]; - int xdigits = length_map[gelf_getclass (elf) - 1][radix_hex]; + const int ddigits = length_map[gelf_getclass (elf) - 1][radix_decimal]; + const int xdigits = length_map[gelf_getclass (elf) - 1][radix_hex]; /* Iterate over all sections. */ + Elf_Scn *scn = NULL; while ((scn = elf_nextscn (elf, scn)) != NULL) { + GElf_Shdr shdr_mem; GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem); if (shdr == NULL) @@ -605,16 +601,13 @@ static void show_segments (Elf *elf, const char *fullname) { GElf_Ehdr ehdr_mem; - GElf_Ehdr *ehdr; - size_t cnt; - GElf_Off total = 0; - int first = 1; - - ehdr = gelf_getehdr (elf, &ehdr_mem); + GElf_Ehdr *ehdr = gelf_getehdr (elf, &ehdr_mem); if (ehdr == NULL) INTERNAL_ERROR (fullname); - for (cnt = 0; cnt < ehdr->e_phnum; ++cnt) + GElf_Off total = 0; + bool first = true; + for (size_t cnt = 0; cnt < ehdr->e_phnum; ++cnt) { GElf_Phdr phdr_mem; GElf_Phdr *phdr; @@ -629,7 +622,7 @@ show_segments (Elf *elf, const char *fullname) if (! first) fputs_unlocked (" + ", stdout); - first = 0; + first = false; printf (radix == radix_hex ? "%" PRIx64 "(%c%c%c)" : (radix == radix_decimal ? "%" PRId64 "(%c%c%c)" diff --git a/elfutils/src/strip.c b/elfutils/src/strip.c index 42e13b46..97078d6b 100644 --- a/elfutils/src/strip.c +++ b/elfutils/src/strip.c @@ -282,7 +282,7 @@ process_file (const char *fname) { if (stat64 (fname, &pre_st) != 0) { - error (0, errno, gettext ("cannot stat input file \"%s\""), fname); + error (0, errno, gettext ("cannot stat input file '%s'"), fname); return 1; } @@ -296,7 +296,7 @@ process_file (const char *fname) int fd = open (fname, output_fname == NULL ? O_RDWR : O_RDONLY); if (fd == -1) { - error (0, errno, gettext ("while opening \"%s\""), fname); + error (0, errno, gettext ("while opening '%s'"), fname); return 1; } @@ -306,7 +306,7 @@ process_file (const char *fname) struct stat64 st; if (fstat64 (fd, &st) != 0) { - error (0, errno, gettext ("cannot stat input file \"%s\""), fname); + error (0, errno, gettext ("cannot stat input file '%s'"), fname); return 1; } /* Paranoid mode on. */ diff --git a/elfutils/tests/ChangeLog b/elfutils/tests/ChangeLog index ec47a31d..aa6d650d 100644 --- a/elfutils/tests/ChangeLog +++ b/elfutils/tests/ChangeLog @@ -1,3 +1,23 @@ +2005-10-27 Roland McGrath <roland@redhat.com> + + * allfcts.c (cb): Update for dwarf_func_* -> dwarf_decl_* changes. + * funcscopes.c (handle_function): Likewise. + * dwflmodtest.c (print_inline, print_func): Likewise. + * find-prologues.c (handle_function): Likewise. + +2005-10-27 Roland McGrath <roland@redhat.com> + + * run-find-prologues.sh: New file. + * Makefile.am (TESTS, EXTRA_DIST): Add it. + + * find-prologues.c (handle_function): Skip inlines. + +2005-10-25 Roland McGrath <roland@redhat.com> + + * find-prologues.c: New file. + * Makefile.am (noinst_PROGRAMS): Add it. + (find_prologues_LDADD): New variable. + 2005-09-02 Ulrich Drepper <drepper@redhat.com> * run-strings-test.sh: Remove strings.out in the end. diff --git a/elfutils/tests/Makefile.am b/elfutils/tests/Makefile.am index 119e11d7..01d7b6ad 100644 --- a/elfutils/tests/Makefile.am +++ b/elfutils/tests/Makefile.am @@ -33,7 +33,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ get-aranges allfcts line2addr addrscopes funcscopes \ show-abbrev hash asm-tst1 asm-tst2 asm-tst3 \ asm-tst4 asm-tst5 asm-tst6 asm-tst7 asm-tst8 asm-tst9 \ - msg_tst newscn ecp dwflmodtest + msg_tst newscn ecp dwflmodtest find-prologues # get-ciefde TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ @@ -47,7 +47,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \ run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ - run-addrscopes.sh run-strings-test.sh run-funcscopes.sh + run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ + run-find-prologues.sh # run-show-ciefde.sh EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ @@ -64,6 +65,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ + run-find-prologues.sh \ testfile15.bz2 testfile15.debug.bz2 \ testfile16.bz2 testfile16.debug.bz2 \ testfile17.bz2 testfile17.debug.bz2 \ @@ -116,6 +118,7 @@ line2addr_no_Wformat = yes line2addr_LDADD = $(libdw) $(libmudflap) addrscopes_LDADD = $(libdw) $(libmudflap) funcscopes_LDADD = $(libdw) $(libmudflap) +find_prologues_LDADD = $(libdw) $(libmudflap) #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf) $(libmudflap) asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl diff --git a/elfutils/tests/Makefile.in b/elfutils/tests/Makefile.in index 0c9d1d95..4c92cabc 100644 --- a/elfutils/tests/Makefile.in +++ b/elfutils/tests/Makefile.in @@ -48,7 +48,7 @@ noinst_PROGRAMS = arextract$(EXEEXT) arsymtest$(EXEEXT) \ asm-tst4$(EXEEXT) asm-tst5$(EXEEXT) asm-tst6$(EXEEXT) \ asm-tst7$(EXEEXT) asm-tst8$(EXEEXT) asm-tst9$(EXEEXT) \ msg_tst$(EXEEXT) newscn$(EXEEXT) ecp$(EXEEXT) \ - dwflmodtest$(EXEEXT) + dwflmodtest$(EXEEXT) find-prologues$(EXEEXT) subdir = tests DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -125,6 +125,10 @@ dwflmodtest_DEPENDENCIES = $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_2) \ ecp_SOURCES = ecp.c ecp_OBJECTS = ecp.$(OBJEXT) ecp_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_4) +find_prologues_SOURCES = find-prologues.c +find_prologues_OBJECTS = find-prologues.$(OBJEXT) +find_prologues_DEPENDENCIES = $(am__DEPENDENCIES_3) \ + $(am__DEPENDENCIES_4) funcscopes_SOURCES = funcscopes.c funcscopes_OBJECTS = funcscopes.$(OBJEXT) funcscopes_DEPENDENCIES = $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) @@ -206,19 +210,19 @@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = addrscopes.c allfcts.c arextract.c arsymtest.c asm-tst1.c \ asm-tst2.c asm-tst3.c asm-tst4.c asm-tst5.c asm-tst6.c \ asm-tst7.c asm-tst8.c asm-tst9.c dwflmodtest.c ecp.c \ - funcscopes.c get-aranges.c get-files.c get-lines.c \ - get-pubnames.c hash.c line2addr.c msg_tst.c newfile.c newscn.c \ - saridx.c scnnames.c sectiondump.c show-abbrev.c \ - show-die-info.c showptable.c test-nlist.c update1.c update2.c \ - update3.c update4.c + find-prologues.c funcscopes.c get-aranges.c get-files.c \ + get-lines.c get-pubnames.c hash.c line2addr.c msg_tst.c \ + newfile.c newscn.c saridx.c scnnames.c sectiondump.c \ + show-abbrev.c show-die-info.c showptable.c test-nlist.c \ + update1.c update2.c update3.c update4.c DIST_SOURCES = addrscopes.c allfcts.c arextract.c arsymtest.c \ asm-tst1.c asm-tst2.c asm-tst3.c asm-tst4.c asm-tst5.c \ asm-tst6.c asm-tst7.c asm-tst8.c asm-tst9.c dwflmodtest.c \ - ecp.c funcscopes.c get-aranges.c get-files.c get-lines.c \ - get-pubnames.c hash.c line2addr.c msg_tst.c newfile.c newscn.c \ - saridx.c scnnames.c sectiondump.c show-abbrev.c \ - show-die-info.c showptable.c test-nlist.c update1.c update2.c \ - update3.c update4.c + ecp.c find-prologues.c funcscopes.c get-aranges.c get-files.c \ + get-lines.c get-pubnames.c hash.c line2addr.c msg_tst.c \ + newfile.c newscn.c saridx.c scnnames.c sectiondump.c \ + show-abbrev.c show-die-info.c showptable.c test-nlist.c \ + update1.c update2.c update3.c update4.c ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -351,7 +355,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-strip-test6.sh run-ecp-test.sh run-ecp-test2.sh \ run-elflint-test.sh run-elflint-self.sh run-ranlib-test.sh \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ - run-addrscopes.sh run-strings-test.sh run-funcscopes.sh + run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ + run-find-prologues.sh # run-show-ciefde.sh EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ @@ -368,6 +373,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ run-elflint-self.sh run-ranlib-test.sh run-ranlib-test2.sh \ run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ + run-find-prologues.sh \ testfile15.bz2 testfile15.debug.bz2 \ testfile16.bz2 testfile16.debug.bz2 \ testfile17.bz2 testfile17.debug.bz2 \ @@ -413,6 +419,7 @@ line2addr_no_Wformat = yes line2addr_LDADD = $(libdw) $(libmudflap) addrscopes_LDADD = $(libdw) $(libmudflap) funcscopes_LDADD = $(libdw) $(libmudflap) +find_prologues_LDADD = $(libdw) $(libmudflap) #show_ciefde_LDADD = ../libdwarf/libdwarf.so $(libelf) $(libmudflap) asm_tst1_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl asm_tst2_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl @@ -506,6 +513,9 @@ dwflmodtest$(EXEEXT): $(dwflmodtest_OBJECTS) $(dwflmodtest_DEPENDENCIES) ecp$(EXEEXT): $(ecp_OBJECTS) $(ecp_DEPENDENCIES) @rm -f ecp$(EXEEXT) $(LINK) $(ecp_LDFLAGS) $(ecp_OBJECTS) $(ecp_LDADD) $(LIBS) +find-prologues$(EXEEXT): $(find_prologues_OBJECTS) $(find_prologues_DEPENDENCIES) + @rm -f find-prologues$(EXEEXT) + $(LINK) $(find_prologues_LDFLAGS) $(find_prologues_OBJECTS) $(find_prologues_LDADD) $(LIBS) funcscopes$(EXEEXT): $(funcscopes_OBJECTS) $(funcscopes_DEPENDENCIES) @rm -f funcscopes$(EXEEXT) $(LINK) $(funcscopes_LDFLAGS) $(funcscopes_OBJECTS) $(funcscopes_LDADD) $(LIBS) @@ -591,6 +601,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm-tst9.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwflmodtest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find-prologues.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/funcscopes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get-aranges.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get-files.Po@am__quote@ diff --git a/elfutils/tests/allfcts.c b/elfutils/tests/allfcts.c index 147ebc2c..f414983c 100644 --- a/elfutils/tests/allfcts.c +++ b/elfutils/tests/allfcts.c @@ -5,12 +5,12 @@ static int -cb (Dwarf_Func *func, void *arg __attribute__ ((unused))) +cb (Dwarf_Die *func, void *arg __attribute__ ((unused))) { - const char *file = dwarf_func_file (func); + const char *file = dwarf_decl_file (func); int line = -1; - dwarf_func_line (func, &line); - const char *fct = dwarf_func_name (func); + dwarf_decl_line (func, &line); + const char *fct = dwarf_diename (func); printf ("%s:%d:%s\n", file, line, fct); diff --git a/elfutils/tests/dwflmodtest.c b/elfutils/tests/dwflmodtest.c index 5155f6cb..77d437aa 100644 --- a/elfutils/tests/dwflmodtest.c +++ b/elfutils/tests/dwflmodtest.c @@ -100,21 +100,21 @@ print_instance (Dwarf_Die *instance, void *arg) } static void -print_inline (Dwarf_Func *func, void *arg) +print_inline (Dwarf_Die *func, void *arg) { if (dwarf_func_inline_instances (func, &print_instance, arg) != 0) printf (" error finding instances: %s\n", dwarf_errmsg (-1)); } static int -print_func (Dwarf_Func *func, void *arg) +print_func (Dwarf_Die *func, void *arg) { const struct info *info = arg; - const char *file = dwarf_func_file (func); + const char *file = dwarf_decl_file (func); int line = -1; - dwarf_func_line (func, &line); - const char *fct = dwarf_func_name (func); + dwarf_decl_line (func, &line); + const char *fct = dwarf_diename (func); printf (" %s:%d: %s:", file, line, fct); @@ -127,15 +127,15 @@ print_func (Dwarf_Func *func, void *arg) else { Dwarf_Addr lo = -1, hi = -1, entry = -1; - if (dwarf_func_lowpc (func, &lo) == 0) + if (dwarf_lowpc (func, &lo) == 0) lo += info->dwbias; else printf (" (lowpc => %s)", dwarf_errmsg (-1)); - if (dwarf_func_highpc (func, &hi) == 0) + if (dwarf_highpc (func, &hi) == 0) hi += info->dwbias; else printf (" (highpc => %s)", dwarf_errmsg (-1)); - if (dwarf_func_entrypc (func, &entry) == 0) + if (dwarf_entrypc (func, &entry) == 0) entry += info->dwbias; else printf (" (entrypc => %s)", dwarf_errmsg (-1)); diff --git a/elfutils/tests/find-prologues.c b/elfutils/tests/find-prologues.c new file mode 100644 index 00000000..0a2e86e0 --- /dev/null +++ b/elfutils/tests/find-prologues.c @@ -0,0 +1,102 @@ +/* Test program for dwarf_entry_breakpoints. + Copyright (C) 2005 Red Hat, Inc. + + This program is Open Source software; you can redistribute it and/or + modify it under the terms of the Open Software License version 1.0 as + published by the Open Source Initiative. + + You should have received a copy of the Open Software License along + with this program; if not, you may obtain a copy of the Open Software + License version 1.0 from http://www.opensource.org/licenses/osl.php or + by writing the Open Source Initiative c/o Lawrence Rosen, Esq., + 3001 King Ranch Road, Ukiah, CA 95482. */ + +#include <config.h> +#include <assert.h> +#include <inttypes.h> +#include <libdwfl.h> +#include <dwarf.h> +#include <argp.h> +#include <stdio.h> +#include <stdio_ext.h> +#include <locale.h> +#include <stdlib.h> +#include <error.h> +#include <string.h> +#include <fnmatch.h> + + +struct args +{ + Dwfl *dwfl; + Dwarf_Die *cu; + Dwarf_Addr dwbias; + char **argv; +}; + +static int +handle_function (Dwarf_Die *func, void *arg) +{ + struct args *a = arg; + + const char *name = dwarf_diename (func); + char **argv = a->argv; + if (argv[0] != NULL) + { + bool match; + do + match = fnmatch (*argv, name, 0) == 0; + while (!match && *++argv); + if (!match) + return 0; + } + + if (dwarf_func_inline (func)) + return 0; + + Dwarf_Addr entrypc; + if (dwarf_entrypc (func, &entrypc) != 0) + error (EXIT_FAILURE, 0, "dwarf_entrypc: %s: %s", + dwarf_diename (func), dwarf_errmsg (-1)); + entrypc += a->dwbias; + + printf ("%-16s %#.16" PRIx64, dwarf_diename (func), entrypc); + + Dwarf_Addr *bkpts = NULL; + int result = dwarf_entry_breakpoints (func, &bkpts); + if (result <= 0) + printf ("\t%s\n", dwarf_errmsg (-1)); + else + { + for (int i = 0; i < result; ++i) + printf (" %#.16" PRIx64 "%s", bkpts[i] + a->dwbias, + i == result - 1 ? "\n" : ""); + free (bkpts); + } + + return 0; +} + + +int +main (int argc, char *argv[]) +{ + int remaining; + + /* Set locale. */ + (void) setlocale (LC_ALL, ""); + + struct args a = { .dwfl = NULL, .cu = NULL }; + + (void) argp_parse (dwfl_standard_argp (), argc, argv, 0, &remaining, + &a.dwfl); + assert (a.dwfl != NULL); + a.argv = &argv[remaining]; + + int result = 0; + + while ((a.cu = dwfl_nextcu (a.dwfl, a.cu, &a.dwbias)) != NULL) + dwarf_getfuncs (a.cu, &handle_function, &a, 0); + + return result; +} diff --git a/elfutils/tests/funcscopes.c b/elfutils/tests/funcscopes.c index a74e8d87..3318f311 100644 --- a/elfutils/tests/funcscopes.c +++ b/elfutils/tests/funcscopes.c @@ -98,11 +98,11 @@ struct args }; static int -handle_function (Dwarf_Func *func, void *arg) +handle_function (Dwarf_Die *funcdie, void *arg) { struct args *a = arg; - const char *name = dwarf_func_name (func); + const char *name = dwarf_diename (funcdie); char **argv = a->argv; if (argv[0] != NULL) { @@ -114,10 +114,6 @@ handle_function (Dwarf_Func *func, void *arg) return 0; } - Dwarf_Die funcdie_mem; - Dwarf_Die *funcdie = dwarf_func_die (func, &funcdie_mem); - assert (funcdie == &funcdie_mem); - Dwarf_Die *scopes; int n = dwarf_getscopes_die (funcdie, &scopes); if (n <= 0) diff --git a/elfutils/tests/run-find-prologues.sh b/elfutils/tests/run-find-prologues.sh new file mode 100755 index 00000000..3e43fc53 --- /dev/null +++ b/elfutils/tests/run-find-prologues.sh @@ -0,0 +1,65 @@ +#! /bin/sh +# Copyright (C) 2005 Red Hat, Inc. +# +# This program is Open Source software; you can redistribute it and/or +# modify it under the terms of the Open Software License version 1.0 as +# published by the Open Source Initiative. +# +# You should have received a copy of the Open Software License along +# with this program; if not, you may obtain a copy of the Open Software +# License version 1.0 from http://www.opensource.org/licenses/osl.php or +# by writing the Open Source Initiative c/o Lawrence Rosen, Esq., +# 3001 King Ranch Road, Ukiah, CA 95482. +set -e + +files="testfile testfile11 testfile22 testfile24 \ +testfile25 testfile3 testfile4 testfile5 testfile6" + +for file in $files; do + # Don't fail if we cannot decompress the file. + bunzip2 -c $srcdir/$file.bz2 > $file 2>/dev/null || exit 77 +done + +for file in $files; do + ./find-prologues -e $file || : +done > find-prologues-test.out 2>&1 + +diff -Bbu find-prologues-test.out - <<\EOF +main 0x000000000804842c 0x0000000008048432 +bar 0x000000000804845c 0x000000000804845f +foo 0x0000000008048468 0x000000000804846b +main 0x00000000080489b8 0x00000000080489cd +gnu_obj_2 0x0000000008048c9e 0x0000000008048ca4 +gnu_obj_3 0x0000000008048cd8 0x0000000008048cde +gnu_obj_2 0x0000000008048cf4 0x0000000008048cfa +~invalid_argument 0x0000000008048d2e 0x0000000008048d34 +gnu_obj_1 0x0000000008048d62 0x0000000008048d65 +gnu_obj_1 0x0000000008048d8a 0x0000000008048d8d +~invalid_argument 0x0000000008048db2 0x0000000008048db8 +function 0x0000000008048348 0x000000000804834e +main 0x000000000804835b 0x0000000008048377 +incr 0x0000000008048348 0x000000000804834e +main 0x0000000008048354 0x0000000008048360 +incr 0x0000000008048348 0x000000000804834c +main 0x000000000804842c 0x0000000008048433 +bar 0x0000000008048458 0x000000000804845b +foo 0x0000000008048464 0x0000000008048467 +get 0x00000000080493fc 0x0000000008049402 +main 0x0000000008049498 0x000000000804949e +a 0x000000000804d85c 0x000000000804d85c +__tfPCc 0x000000000804d86c 0x000000000804d872 +__tfCc 0x000000000804d8a4 0x000000000804d8a4 +bar 0x000000000804842c 0x000000000804842f +foo 0x0000000008048438 0x000000000804843b +main 0x0000000008048444 0x000000000804844a +main 0x00000000080489b8 0x00000000080489cd +gnu_obj_2 0x0000000008048c9e 0x0000000008048ca4 +gnu_obj_3 0x0000000008048cd8 0x0000000008048cde +gnu_obj_2 0x0000000008048cf4 0x0000000008048cfa +~invalid_argument 0x0000000008048d2e 0x0000000008048d34 +gnu_obj_1 0x0000000008048d62 0x0000000008048d65 +gnu_obj_1 0x0000000008048d8a 0x0000000008048d8d +~invalid_argument 0x0000000008048db2 0x0000000008048db8 +EOF + +rm -f find-prologues-test.out $files |