diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-10-30 09:35:42 +0000 |
---|---|---|
committer | <> | 2015-01-09 11:51:27 +0000 |
commit | c27a97d04853380f1e80525391b3f0d156ed4c84 (patch) | |
tree | 68ffaade7c605bc80cffa18360799c98a810976f /libiberty | |
parent | 6af3fdec2262dd94954acc5e426ef71cbd4521d3 (diff) | |
download | gcc-tarball-c27a97d04853380f1e80525391b3f0d156ed4c84.tar.gz |
Imported from /home/lorry/working-area/delta_gcc-tarball/gcc-4.9.2.tar.bz2.gcc-4.9.2
Diffstat (limited to 'libiberty')
37 files changed, 2617 insertions, 416 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 60265f8e16..2c84de15de 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,11 +1,270 @@ -2013-04-11 Release Manager +2014-10-30 Release Manager - * GCC 4.7.3 released. + * GCC 4.9.2 released. -2013-02-19 Jakub Jelinek <jakub@redhat.com> +2014-07-16 Release Manager - Backported from mainline - 2013-02-09 Jakub Jelinek <jakub@redhat.com> + * GCC 4.9.1 released. + +2014-04-22 Release Manager + + * GCC 4.9.0 released. + +2014-04-01 Richard Biener <rguenther@suse.de> + + * simple-object.c (simple_object_internal_write): Handle + EINTR and short writes. + +2014-03-28 Richard Biener <rguenther@suse.de> + + * simple-object.c (simple_object_internal_read): Handle + EINTR and short reads. + +2014-03-13 Uros Bizjak <ubizjak@gmail.com> + + * regex.c (bzero) [!_LIBC]: Define without coma expression. + (regerror): Cast the call to memcpy to (void) to avoid unused + value warnings. + +2014-01-28 Thomas Schwinge <thomas@codesourcery.com> + + * cp-demangle.c (d_demangle_callback): Put an abort call in place, + to help the compiler. + +2014-01-21 Tom Tromey <tromey@redhat.com> + + * _doprint.c (checkit): Use stdarg, not VA_* macros. + * asprintf.c (asprintf): Use stdarg, not VA_* macros. + * concat.c (concat_length, concat_copy, concat_copy2, concat) + (reconcat): Use stdarg, not VA_* macros. + * snprintf.c (snprintf): Use stdarg, not VA_* macros. + * vasprintf.c (checkit): Use stdarg, not VA_* macros. + * vsnprintf.c (checkit): Use stdarg, not VA_* macros. + +2014-01-06 Mike Frysinger <vapier@gentoo.org> + + PR other/56780 + * configure.ac: Delete target_header_dir assignment. + * configure: Regenerated. + +2014-01-06 Gary Benson <gbenson@redhat.com> + + * cp-demangle.c (struct d_print_info): New fields + next_saved_scope, copy_templates, next_copy_template and + num_copy_templates. + (d_count_templates): New function. + (d_print_init): New parameter "dc". + Estimate numbers of templates and scopes required. + (d_print_free): Removed function. + (cplus_demangle_print_callback): Allocate stack for + templates and scopes. Removed call to d_print_free. + (d_copy_templates): Removed function. + (d_save_scope): New function. + (d_get_saved_scope): Likewise. + (d_print_comp): Replace state saving/restoring code with + calls to d_save_scope and d_get_saved_scope. + +2013-12-23 Bill Maddox <maddox@google.com> + + * cp-demangle.c (cplus_demangle_fill_ctor,cplus_demangle_fill_dtor): + Handle unified ctor/dtor. + (d_ctor_dtor_name): Handle unified ctor/dtor. + +2013-11-22 Cary Coutant <ccoutant@google.com> + + PR other/59195 + * cp-demangle.c (struct d_info_checkpoint): New struct. + (struct d_print_info): Add current_template field. + (d_operator_name): Set flag when processing a conversion + operator. + (cplus_demangle_type): When processing <template-args> for + a conversion operator, backtrack if necessary. + (d_expression_1): Renamed from d_expression. + (d_expression): New wrapper around d_expression_1. + (d_checkpoint): New function. + (d_backtrack): New function. + (d_print_init): Initialize current_template. + (d_print_comp): Set current_template. + (d_print_cast): Put current_template in scope for + printing conversion operator name. + (cplus_demangle_init_info): Initialize is_expression and + is_conversion. + * cp-demangle.h (struct d_info): Add is_expression and + is_conversion fields. + * testsuite/demangle-expected: New test cases. + +2013-11-15 Andreas Schwab <schwab@linux-m68k.org> + + * configure: Regenerate. + +2013-11-12 Uros Bizjak <ubizjak@gmail.com> + + * cp-demangle.c (d_copy_templates): Cast result of malloc + to (struct d_print_template *). + (d_print_comp): Cast result of realloc to (struct d_saved scope *). + +2013-10-29 Marc Glisse <marc.glisse@inria.fr> + + PR tree-optimization/58689 + * concat.c: Remove note about xmalloc. + +2013-10-27 Gerald Pfeifer <gerald@pfeifer.com> + + * testsuite/test-demangle.c: Include unistd.h. + +2013-10-25 Gary Benson <gbenson@redhat.com> + + * cp-demangle.c (struct d_saved_scope): New structure. + (struct d_print_info): New fields saved_scopes and + num_saved_scopes. + (d_print_init): Initialize the above. + (d_print_free): New function. + (cplus_demangle_print_callback): Call the above. + (d_copy_templates): New function. + (d_print_comp): New variables saved_templates and + need_template_restore. + [DEMANGLE_COMPONENT_REFERENCE, DEMANGLE_COMPONENT_RVALUE_REFERENCE]: + Capture scope the first time the component is traversed, and use the + captured scope for subsequent traversals. + * testsuite/demangle-expected: Add regression test. + +2013-10-23 Gerald Pfeifer <gerald@pfeifer.com> + + * testsuite/test-expandargv.c: Include unistd.h. + +2013-10-15 David Malcolm <dmalcolm@redhat.com> + + * configure.ac: If --enable-host-shared, use -fPIC. + * configure: Regenerate. + +2013-10-11 Paul Pluzhnikov <ppluzhnikov@google.com> + + * cp-demangle.c (d_name): Demangle local-source-names. + * testsuite/demangle-expected: New test. + +2013-09-10 Paolo Carlini <paolo.carlini@oracle.com> + + PR bootstrap/58386 + Revert: + + 2013-09-10 Gary Benson <gbenson@redhat.com> + + * cp-demangle.c: Include hashtab.h. + (struct d_print_info): New field saved_scopes. + (d_print_init): Initialize the above. + (d_print_free): New function. + (cplus_demangle_print_callback): Call the above. + (struct d_saved_scope): New structure. + (d_store_scope): New function. + (d_free_scope) Likewise. + (d_restore_scope) Likewise. + (d_hash_saved_scope) Likewise. + (d_equal_saved_scope) Likewise. + (d_print_comp): New variable saved_scope. + [DEMANGLE_COMPONENT_REFERENCE, + DEMANGLE_COMPONENT_RVALUE_REFERENCE]: Capture scope the first + time the component is traversed, and use the captured scope for + subsequent traversals. + * testsuite/demangle-expected: Add regression test. + +2013-09-10 Gary Benson <gbenson@redhat.com> + + * cp-demangle.c: Include hashtab.h. + (struct d_print_info): New field saved_scopes. + (d_print_init): Initialize the above. + (d_print_free): New function. + (cplus_demangle_print_callback): Call the above. + (struct d_saved_scope): New structure. + (d_store_scope): New function. + (d_free_scope) Likewise. + (d_restore_scope) Likewise. + (d_hash_saved_scope) Likewise. + (d_equal_saved_scope) Likewise. + (d_print_comp): New variable saved_scope. + [DEMANGLE_COMPONENT_REFERENCE, + DEMANGLE_COMPONENT_RVALUE_REFERENCE]: Capture scope the first + time the component is traversed, and use the captured scope for + subsequent traversals. + * testsuite/demangle-expected: Add regression test. + +2013-08-20 Alan Modra <amodra@gmail.com> + + * floatformat.c (floatformat_ibm_long_double): Rename to.. + (floatformat_ibm_long_double_big): ..this. + (floatformat_ibm_long_double_little): New. + +2013-07-09 Tristan Gingold <gingold@adacore.com> + + * makefile.vms (OBJS): Add dwarfnames.obj + +2013-05-31 Matt Burgess <matthew@linuxfromscratch.org> + + PR other/56780 + * libiberty/configure.ac: Move test for --enable-install-libiberty + outside of the 'with_target_subdir' test so that it actually gets + run. Add output messages to show the test result. + * libiberty/configure: Regenerate. + * libiberty/Makefile.in (install_to_libdir): Place the + installation of the libiberty library in the same guard as that + used for the headers to prevent it being installed unless + requested via --enable-install-libiberty. + +2013-05-06 David Edelsohn <dje.gcc@gmail.com> + Peter Bergner <bergner@vnet.ibm.com> + Segher Boessenkool <segher@kernel.crashing.org> + Jakub Jelinek <jakub@redhat.com> + + * hashtab.c (hash_pointer): Remove conditional and avoid + unexecuted shift equal to wordsize. + +2013-04-22 Andi Kleen <ak@linux.intel.com> + + * hashtab.c (hash_pointer): Move to end of file and reimplement. + +2013-04-03 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (cplus_demangle_type): Fix function quals. + (d_pointer_to_member_type): Simplify. + + Demangle C++11 ref-qualifier. + * cp-demangle.c (d_ref_qualifier): New. + (d_nested_name, d_function_type): Use it. + (d_parmlist): Don't get confused by a ref-qualifier. + (cplus_demangle_type): Reorder ref-qualifier. + (d_pointer_to_member_type): Likewise. + (d_dump): Handle DEMANGLE_COMPONENT_REFERENCE_THIS and + DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS. + (d_make_comp, has_return_type, d_encoding): Likewise. + (d_print_comp, d_print_mod_list, d_print_mod): Likewise. + (d_print_function_type, is_ctor_or_dtor): Likewise. + +2013-03-27 Kai Tietz <ktietz@redhat.com> + + * configure: Regenerated. + +2013-03-06 Tobias Burnus <burnus@net-b.de> + + * libiberty.texi: Update comment, remove lowersections. + * obstacks.texi: Regenerate. + +2013-03-05 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/56526 + * simple-object-mach-o.c (simple_object_mach_o_segment): Initialize + wrapper_sect_offset to avoid a warning. + +2013-03-01 Andreas Schwab <schwab@linux-m68k.org> + + * obstacks.texi (Obstacks): Trim @node to only contain the + node name. + * libiberty.texi (Obstacks): Lower section. + +2013-02-14 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_DEFAULT_ARG. + (d_print_comp): Likewise. + +2013-02-09 Jakub Jelinek <jakub@redhat.com> PR other/56245 * regex.c (PTR_INT_TYPE): Define. @@ -13,48 +272,139 @@ 2013-01-31 Kai Tietz <ktietz@redhat.com> - Merged from trunk PR other/54620 * sha1.c (sha1_process_block): Handle case that size_t is a wider-integer-scalar as a 32-bit unsigned integer. - Merged from trunk. PR other/53413 * md5.c (md5_process_block): Handle case that size_t is a wider-integer-scalar a 32-bit unsigned integer. - 2012-07-31 Mike Frysinger <vapier@gentoo.org> +2013-01-04 Ian Lance Taylor <iant@google.com> + + PR other/54800 + * simple-object-mach-o.c (simple_object_mach_o_segment): Don't + bother to zero out a buffer we are about to set anyhow. + +2013-01-01 David Edelsohn <dje.gcc@gmail.com> + + * simple-object-xcoff.c: New file. + * Makefile.in: Add it to build machinery. + * simple-object-common.h (simple_object_xcoff_functions): Declare. + * simple-object.c (format_functions): Add + simple_object_xcoff_functions. + +2012-11-10 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (d_unqualified_name): Handle abi tags here. + (d_name): Not here. + +2012-11-09 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_TAGGED_NAME. + (d_make_comp, d_find_pack, d_print_comp): Likewise. + (d_abi_tags): New. + (d_name): Call it. + +2012-10-08 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (d_special_name, d_dump): Handle TH and TW. + (d_make_comp, d_print_comp): Likewise. + +2012-09-18 Ian Lance Taylor <iant@google.com> + + * strnlen.c: New file. + * configure.ac: Check for strnlen, add it to AC_LIBOBJ if it's not + present. + * Makefile.in: Rebuild dependencies. + (CFILES): Add strnlen.c. + (CONFIGURED_OFILES): Add ./strnlen.$(objext). + * configure, config.in, functions.texi: Rebuild. + + * maint-tool: Accept .def files in the include directory. + +2012-09-18 Florian Weimer <fweimer@redhat.com> + + PR other/54411 + * objalloc.c (_objalloc_alloc): Add overflow check covering + alignment and CHUNK_HEADER_SIZE addition. + +2011-08-28 H.J. Lu <hongjiu.lu@intel.com> + + * argv.c (dupargv): Replace malloc with xmalloc. Don't check + xmalloc return. + (buildargv): Likewise. Also replace strdup with xstrdup. + (expandargv): Don't check dupargv return. + +2011-08-28 H.J. Lu <hongjiu.lu@intel.com> + + PR binutils/14526 + * argv.c (buildargv): Replace alloca with xmalloc/free. + +2012-08-17 Andreas Schwab <schwab@linux-m68k.org> + + * floatformat.c (floatformat_to_double): Correctly handle numbers + between 1 and 2. Simplify handling of denormal number. + (main): Test with 1.1. + +2012-07-31 Mike Frysinger <vapier@gentoo.org> - Merged from trunk. - PR other/53285 * md5.c (md5_finish_ctx): Declare swap_bytes. Assign SWAP() output to swap_bytes, and then call memcpy to move it to ctx->buffer. -2012-09-20 Release Manager +2012-07-26 Kazu Hirata <kazu@codesourcery.com> + Sandra Loosemore <sandra@codesourcery.com> - * GCC 4.7.2 released. + * pex-win32.c (pex_win32_exec_child): Only close original file + descriptors if child is launched successfully. -2012-06-14 Release Manager +2012-07-18 Jason Merrill <jason@redhat.com> - * GCC 4.7.1 released. + * cp-demangle.c (cplus_demangle_operators): Add *_cast. + (op_is_new_cast): New. + (d_expression, d_print_comp): Check it. -2012-03-24 H.J. Lu <hongjiu.lu@intel.com> +2012-07-13 Doug Evans <dje@google.com> - * testsuite/demangle-expected: Fix a typo. + * filename_cmp.c (filename_hash, filename_eq): New functions. -2012-03-22 Jason Merrill <jason@redhat.com> +2012-06-29 Andreas Schwab <schwab@linux-m68k.org> - * cp-demangle.c (cplus_demangle_operators): Add li. - (d_unqualified_name): Handle it specially. + * copying-lib.texi (Library Copying): Don't use @heading inside + @enumerate. + +2012-05-22 Tom Tromey <tromey@redhat.com> + + http://sourceware.org/bugzilla/show_bug.cgi?id=14065 + * testsuite/demangle-expected: Add regression test. + * cp-demangle.c (d_find_pack): Return NULL for + DEMANGLE_COMPONENT_UNNAMED_TYPE. + +2012-04-27 Tom Tromey <tromey@redhat.com> + + * dwarfnames.c: New file. + * Makefile.in (CFILES): Add dwarfnames. + (REQUIRED_OFILES): Add dwarfnames. + (./dwarfnames.$(objext)): New target. -2012-03-22 Release Manager +2012-04-04 Tristan Gingold <gingold@adacore.com> - * GCC 4.7.0 released. + * pex-unix.c (to_ptr32): Fix style. + +2012-04-02 Tristan Gingold <gingold@adacore.com> + + * stack-limit.c: Includes ansidecl.h. + (stack_limit_increase): Add ATTRIBUTE_UNUSED 2012-03-20 Jason Merrill <jason@redhat.com> * cp-demangle.c (cplus_demangle_type): Handle 'auto'. +2012-03-07 Jason Merrill <jason@redhat.com> + + * cp-demangle.c (cplus_demangle_operators): Add li. + (d_unqualified_name): Handle it specially. + 2012-01-26 Jakub Jelinek <jakub@redhat.com> * make-relative-prefix.c (make_relative_prefix_1): Avoid warning @@ -441,12 +791,12 @@ * aclocal.m4 (AC_LANG_FUNC_LINK_TRY(C)): Delete. * configure: Regenerate. -2010-10-07 Andi Kleen <ak@linux.intel.com> +2010-10-07 Andi Kleen <ak@linux.intel.com> * configure: Regenerate. * configure.ac: Turn PR_SET_NAME check into link check. -2010-10-06 Andi Kleen <ak@linux.intel.com> +2010-10-06 Andi Kleen <ak@linux.intel.com> * Makefile.in (CFILES): Add setproctitle. (CONFIGURED_OFILES): Add setproctitle. diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 5280bc1585..75ff82d984 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -2,7 +2,7 @@ # Originally written by K. Richard Pixley <rich@cygnus.com>. # # Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, -# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 +# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 # Free Software Foundation # # This file is part of the libiberty library. @@ -126,7 +126,7 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \ basename.c bcmp.c bcopy.c bsearch.c bzero.c \ calloc.c choose-temp.c clock.c concat.c cp-demangle.c \ cp-demint.c cplus-dem.c crc32.c \ - dyn-string.c \ + dwarfnames.c dyn-string.c \ fdmatch.c ffs.c fibheap.c filename_cmp.c floatformat.c \ fnmatch.c fopen_unlocked.c \ getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c \ @@ -146,12 +146,12 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \ random.c regex.c rename.c rindex.c \ safe-ctype.c setenv.c setproctitle.c sha1.c sigsetmask.c \ simple-object.c simple-object-coff.c simple-object-elf.c \ - simple-object-mach-o.c \ + simple-object-mach-o.c simple-object-xcoff.c \ snprintf.c sort.c \ spaces.c splay-tree.c stack-limit.c stpcpy.c stpncpy.c \ strcasecmp.c strchr.c strdup.c strerror.c strncasecmp.c \ strncmp.c strrchr.c strsignal.c strstr.c strtod.c strtol.c \ - strtoul.c strndup.c strverscmp.c \ + strtoul.c strndup.c strnlen.c strverscmp.c \ timeval-utils.c tmpnam.c \ unlink-if-ordinary.c \ vasprintf.c vfork.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \ @@ -166,7 +166,8 @@ REQUIRED_OFILES = \ ./md5.$(objext) ./sha1.$(objext) ./alloca.$(objext) \ ./argv.$(objext) \ ./choose-temp.$(objext) ./concat.$(objext) \ - ./cp-demint.$(objext) ./crc32.$(objext) ./dyn-string.$(objext) \ + ./cp-demint.$(objext) ./crc32.$(objext) \ + ./dwarfnames.$(objext) ./dyn-string.$(objext) \ ./fdmatch.$(objext) ./fibheap.$(objext) \ ./filename_cmp.$(objext) ./floatformat.$(objext) \ ./fnmatch.$(objext) ./fopen_unlocked.$(objext) \ @@ -182,6 +183,7 @@ REQUIRED_OFILES = \ ./safe-ctype.$(objext) \ ./simple-object.$(objext) ./simple-object-coff.$(objext) \ ./simple-object-elf.$(objext) ./simple-object-mach-o.$(objext) \ + ./simple-object-xcoff.$(objext) \ ./sort.$(objext) ./spaces.$(objext) \ ./splay-tree.$(objext) ./stack-limit.$(objext) \ ./strerror.$(objext) ./strsignal.$(objext) \ @@ -214,9 +216,9 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./atexit.$(objext) \ ./sigsetmask.$(objext) ./snprintf.$(objext) \ ./stpcpy.$(objext) ./stpncpy.$(objext) ./strcasecmp.$(objext) \ ./strchr.$(objext) ./strdup.$(objext) ./strncasecmp.$(objext) \ - ./strncmp.$(objext) ./strndup.$(objext) ./strrchr.$(objext) \ - ./strstr.$(objext) ./strtod.$(objext) ./strtol.$(objext) \ - ./strtoul.$(objext) ./strverscmp.$(objext) \ + ./strncmp.$(objext) ./strndup.$(objext) ./strnlen.$(objext) \ + ./strrchr.$(objext) ./strstr.$(objext) ./strtod.$(objext) \ + ./strtol.$(objext) ./strtoul.$(objext) ./strverscmp.$(objext) \ ./tmpnam.$(objext) \ ./vasprintf.$(objext) ./vfork.$(objext) ./vfprintf.$(objext) \ ./vprintf.$(objext) ./vsnprintf.$(objext) ./vsprintf.$(objext) \ @@ -353,19 +355,19 @@ install-strip: install # since it will be passed the multilib flags. MULTIOSDIR = `$(CC) $(CFLAGS) -print-multi-os-directory` install_to_libdir: all - ${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR) - $(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n - ( cd $(DESTDIR)$(libdir)/$(MULTIOSDIR) ; chmod 644 $(TARGETLIB)n ;$(RANLIB) $(TARGETLIB)n ) - mv -f $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB) if test -n "${target_header_dir}"; then \ - case "${target_header_dir}" in \ - /*) thd=${target_header_dir};; \ - *) thd=${includedir}/${target_header_dir};; \ - esac; \ - ${mkinstalldirs} $(DESTDIR)$${thd}; \ - for h in ${INSTALLED_HEADERS}; do \ - ${INSTALL_DATA} $$h $(DESTDIR)$${thd}; \ - done; \ + ${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR); \ + $(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n; \ + ( cd $(DESTDIR)$(libdir)/$(MULTIOSDIR) ; chmod 644 $(TARGETLIB)n ;$(RANLIB) $(TARGETLIB)n ); \ + mv -f $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB); \ + case "${target_header_dir}" in \ + /*) thd=${target_header_dir};; \ + *) thd=${includedir}/${target_header_dir};; \ + esac; \ + ${mkinstalldirs} $(DESTDIR)$${thd}; \ + for h in ${INSTALLED_HEADERS}; do \ + ${INSTALL_DATA} $$h $(DESTDIR)$${thd}; \ + done; \ fi @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install @@ -621,6 +623,13 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/crc32.c $(OUTPUT_OPTION) +./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.def \ + $(INCDIR)/dwarf2.h + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/dwarfnames.c -o pic/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/dwarfnames.c $(OUTPUT_OPTION) + ./dyn-string.$(objext): $(srcdir)/dyn-string.c config.h $(INCDIR)/ansidecl.h \ $(INCDIR)/dyn-string.h $(INCDIR)/libiberty.h if [ x"$(PICFLAG)" != x ]; then \ @@ -648,7 +657,8 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION) -./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/filenames.h \ +./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/filename_cmp.c -o pic/$@; \ @@ -749,7 +759,7 @@ $(CONFIGURED_OFILES): stamp-picdir $(COMPILE.c) $(srcdir)/insque.c $(OUTPUT_OPTION) ./lbasename.$(objext): $(srcdir)/lbasename.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/lbasename.c -o pic/$@; \ @@ -1000,6 +1010,14 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/simple-object-mach-o.c $(OUTPUT_OPTION) +./simple-object-xcoff.$(objext): $(srcdir)/simple-object-xcoff.c config.h \ + $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \ + $(srcdir)/simple-object-common.h $(INCDIR)/simple-object.h + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/simple-object-xcoff.c -o pic/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/simple-object-xcoff.c $(OUTPUT_OPTION) + ./simple-object.$(objext): $(srcdir)/simple-object.c config.h \ $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \ $(srcdir)/simple-object-common.h $(INCDIR)/simple-object.h @@ -1035,7 +1053,7 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/splay-tree.c $(OUTPUT_OPTION) -./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h +./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/stack-limit.c -o pic/$@; \ else true; fi @@ -1096,6 +1114,12 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/strndup.c $(OUTPUT_OPTION) +./strnlen.$(objext): $(srcdir)/strnlen.c config.h + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/strnlen.c -o pic/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/strnlen.c $(OUTPUT_OPTION) + ./strrchr.$(objext): $(srcdir)/strrchr.c $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/strrchr.c -o pic/$@; \ diff --git a/libiberty/_doprnt.c b/libiberty/_doprnt.c index ca97bc8c5d..9723f32e6c 100644 --- a/libiberty/_doprnt.c +++ b/libiberty/_doprnt.c @@ -222,11 +222,11 @@ static int checkit (const char* format, ...) { int result; - VA_OPEN (args, format); - VA_FIXEDARG (args, char *, format); + va_list args; + va_start (args, format); result = _doprnt (format, args, stdout); - VA_CLOSE (args); + va_end (args); return result; } diff --git a/libiberty/argv.c b/libiberty/argv.c index ca53f91493..f2727e8de9 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -1,5 +1,5 @@ /* Create and destroy argument vectors (argv's) - Copyright (C) 1992, 2001, 2010 Free Software Foundation, Inc. + Copyright (C) 1992, 2001, 2010, 2012 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support This file is part of the libiberty library. @@ -72,20 +72,13 @@ dupargv (char **argv) /* the vector */ for (argc = 0; argv[argc] != NULL; argc++); - copy = (char **) malloc ((argc + 1) * sizeof (char *)); - if (copy == NULL) - return NULL; - + copy = (char **) xmalloc ((argc + 1) * sizeof (char *)); + /* the strings */ for (argc = 0; argv[argc] != NULL; argc++) { int len = strlen (argv[argc]); - copy[argc] = (char *) malloc (len + 1); - if (copy[argc] == NULL) - { - freeargv (copy); - return NULL; - } + copy[argc] = (char *) xmalloc (len + 1); strcpy (copy[argc], argv[argc]); } copy[argc] = NULL; @@ -149,7 +142,7 @@ remains unchanged. The last element of the vector is followed by a @code{NULL} element. All of the memory for the pointer array and copies of the string -is obtained from @code{malloc}. All of the memory can be returned to the +is obtained from @code{xmalloc}. All of the memory can be returned to the system with the single function call @code{freeargv}, which takes the returned result of @code{buildargv}, as it's argument. @@ -191,7 +184,7 @@ char **buildargv (const char *input) if (input != NULL) { - copybuf = (char *) alloca (strlen (input) + 1); + copybuf = (char *) xmalloc (strlen (input) + 1); /* Is a do{}while to always execute the loop once. Always return an argv, even for null strings. See NOTES above, test case below. */ do @@ -205,21 +198,12 @@ char **buildargv (const char *input) if (argv == NULL) { maxargc = INITIAL_MAXARGC; - nargv = (char **) malloc (maxargc * sizeof (char *)); + nargv = (char **) xmalloc (maxargc * sizeof (char *)); } else { maxargc *= 2; - nargv = (char **) realloc (argv, maxargc * sizeof (char *)); - } - if (nargv == NULL) - { - if (argv != NULL) - { - freeargv (argv); - argv = NULL; - } - break; + nargv = (char **) xrealloc (argv, maxargc * sizeof (char *)); } argv = nargv; argv[argc] = NULL; @@ -284,19 +268,15 @@ char **buildargv (const char *input) } } *arg = EOS; - argv[argc] = strdup (copybuf); - if (argv[argc] == NULL) - { - freeargv (argv); - argv = NULL; - break; - } + argv[argc] = xstrdup (copybuf); argc++; argv[argc] = NULL; consume_whitespace (&input); } while (*input != EOS); + + free (copybuf); } return (argv); } @@ -455,14 +435,7 @@ expandargv (int *argcp, char ***argvp) file_argv = buildargv (buffer); /* If *ARGVP is not already dynamically allocated, copy it. */ if (!argv_dynamic) - { - *argvp = dupargv (*argvp); - if (!*argvp) - { - fputs ("\nout of memory\n", stderr); - xexit (1); - } - } + *argvp = dupargv (*argvp); /* Count the number of arguments. */ file_argc = 0; while (file_argv[file_argc]) diff --git a/libiberty/asprintf.c b/libiberty/asprintf.c index 3cf5052660..961ad4dbb0 100644 --- a/libiberty/asprintf.c +++ b/libiberty/asprintf.c @@ -1,6 +1,6 @@ /* Like sprintf but provides a pointer to malloc'd storage, which must be freed by the caller. - Copyright (C) 1997, 2003 Free Software Foundation, Inc. + Copyright (C) 1997, 2003, 2013 Free Software Foundation, Inc. Contributed by Cygnus Solutions. This file is part of the libiberty library. @@ -47,10 +47,9 @@ int asprintf (char **buf, const char *fmt, ...) { int status; - VA_OPEN (ap, fmt); - VA_FIXEDARG (ap, char **, buf); - VA_FIXEDARG (ap, const char *, fmt); + va_list ap; + va_start (ap, fmt); status = vasprintf (buf, fmt, ap); - VA_CLOSE (ap); + va_end (ap); return status; } diff --git a/libiberty/concat.c b/libiberty/concat.c index 9779d5663b..7846a19393 100644 --- a/libiberty/concat.c +++ b/libiberty/concat.c @@ -1,5 +1,5 @@ /* Concatenate variable number of strings. - Copyright (C) 1991, 1994, 2001, 2011 Free Software Foundation, Inc. + Copyright (C) 1991, 1994, 2001, 2011, 2013 Free Software Foundation, Inc. Written by Fred Fish @ Cygnus Support This file is part of the libiberty library. @@ -25,23 +25,11 @@ Boston, MA 02110-1301, USA. */ @dots{}, @code{NULL}) Concatenate zero or more of strings and return the result in freshly -@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is -available. The argument list is terminated by the first @code{NULL} -pointer encountered. Pointers to empty strings are ignored. +@code{xmalloc}ed memory. The argument list is terminated by the first +@code{NULL} pointer encountered. Pointers to empty strings are ignored. @end deftypefn -NOTES - - This function uses xmalloc() which is expected to be a front end - function to malloc() that deals with low memory situations. In - typical use, if malloc() returns NULL then xmalloc() diverts to an - error handler routine which never returns, and thus xmalloc will - never return a NULL pointer. If the client application wishes to - deal with low memory situations itself, it should supply an xmalloc - that just directly invokes malloc and blindly returns whatever - malloc returns. - */ @@ -102,11 +90,11 @@ unsigned long concat_length (const char *first, ...) { unsigned long length; + va_list args; - VA_OPEN (args, first); - VA_FIXEDARG (args, const char *, first); + va_start (args, first); length = vconcat_length (first, args); - VA_CLOSE (args); + va_end (args); return length; } @@ -117,13 +105,12 @@ char * concat_copy (char *dst, const char *first, ...) { char *save_dst; + va_list args; - VA_OPEN (args, first); - VA_FIXEDARG (args, char *, dst); - VA_FIXEDARG (args, const char *, first); + va_start (args, first); vconcat_copy (dst, first, args); save_dst = dst; /* With K&R C, dst goes out of scope here. */ - VA_CLOSE (args); + va_end (args); return save_dst; } @@ -141,10 +128,10 @@ char *libiberty_concat_ptr; char * concat_copy2 (const char *first, ...) { - VA_OPEN (args, first); - VA_FIXEDARG (args, const char *, first); + va_list args; + va_start (args, first); vconcat_copy (libiberty_concat_ptr, first, args); - VA_CLOSE (args); + va_end (args); return libiberty_concat_ptr; } @@ -153,18 +140,17 @@ char * concat (const char *first, ...) { char *newstr; + va_list args; /* First compute the size of the result and get sufficient memory. */ - VA_OPEN (args, first); - VA_FIXEDARG (args, const char *, first); + va_start (args, first); newstr = XNEWVEC (char, vconcat_length (first, args) + 1); - VA_CLOSE (args); + va_end (args); /* Now copy the individual pieces to the result string. */ - VA_OPEN (args, first); - VA_FIXEDARG (args, const char *, first); + va_start (args, first); vconcat_copy (newstr, first, args); - VA_CLOSE (args); + va_end (args); return newstr; } @@ -191,22 +177,19 @@ char * reconcat (char *optr, const char *first, ...) { char *newstr; + va_list args; /* First compute the size of the result and get sufficient memory. */ - VA_OPEN (args, first); - VA_FIXEDARG (args, char *, optr); - VA_FIXEDARG (args, const char *, first); + va_start (args, first); newstr = XNEWVEC (char, vconcat_length (first, args) + 1); - VA_CLOSE (args); + va_end (args); /* Now copy the individual pieces to the result string. */ - VA_OPEN (args, first); - VA_FIXEDARG (args, char *, optr); - VA_FIXEDARG (args, const char *, first); + va_start (args, first); vconcat_copy (newstr, first, args); if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C. */ free (optr); - VA_CLOSE (args); + va_end (args); return newstr; } diff --git a/libiberty/config.in b/libiberty/config.in index 17c4c2e441..1cf9c11b6e 100644 --- a/libiberty/config.in +++ b/libiberty/config.in @@ -262,6 +262,9 @@ /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP +/* Define to 1 if you have the `strnlen' function. */ +#undef HAVE_STRNLEN + /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR diff --git a/libiberty/configure b/libiberty/configure index 6e98352f35..7bde9b38f1 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -675,8 +675,8 @@ with_cross_host with_newlib enable_maintainer_mode enable_multilib -enable_largefile enable_install_libiberty +enable_largefile ' ac_precious_vars='build_alias host_alias @@ -1303,8 +1303,8 @@ Optional Features: enable make rules and dependencies not useful (and sometimes confusing) to the casual installer --enable-multilib build many library versions (default) + --enable-install-libiberty Install headers and library for end users --disable-largefile omit support for large files - --enable-install-libiberty Install headers for end users Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -2784,6 +2784,35 @@ if test $cross_compiling = no && test $multilib = yes \ cross_compiling=maybe fi +# We may wish to install the target headers somewhere. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to install libiberty headers and static library" >&5 +$as_echo_n "checking whether to install libiberty headers and static library... " >&6; } + +# Check whether --enable-install-libiberty was given. +if test "${enable_install_libiberty+set}" = set; then : + enableval=$enable_install_libiberty; enable_install_libiberty=$enableval +else + enable_install_libiberty=no +fi + +# Option parsed, now set things appropriately. +case x"$enable_install_libiberty" in + xyes|x) + target_header_dir=libiberty + ;; + xno) + target_header_dir= + ;; + *) + # This could be sanity-checked in various ways... + target_header_dir="${enable_install_libiberty}" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_install_libiberty" >&5 +$as_echo "$enable_install_libiberty" >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: target_header_dir = $target_header_dir" >&5 +$as_echo "$as_me: target_header_dir = $target_header_dir" >&6;} + ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -4865,7 +4894,9 @@ case "${host}" in hppa*64*-*-hpux*) # PIC is the default for 64-bit PA HP-UX. ;; - i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*) + i[34567]86-*-cygwin* | x86_64-*-cygwin*) + ;; + i[34567]86-*-mingw* | x86_64-*-mingw*) ;; i[34567]86-*-interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. @@ -4896,9 +4927,6 @@ case "${host}" in i[34567]86-*-* | x86_64-*-*) PICFLAG=-fpic ;; - m68k-*-*) - PICFLAG=-fpic - ;; # FIXME: Override -fPIC default in libgcc only? sh-*-linux* | sh[2346lbe]*-*-linux*) PICFLAG=-fpic @@ -4932,6 +4960,12 @@ case "${enable_shared}" in "") shared=no ;; *) shared=yes ;; esac + +# ...unless --enable-host-shared was passed from top-level config: +if [ "${enable_host_shared}" = "yes" ]; then + shared=yes +fi + if [ "${shared}" != "yes" ]; then PICFLAG= fi @@ -5340,6 +5374,7 @@ funcs="$funcs strchr" funcs="$funcs strdup" funcs="$funcs strncasecmp" funcs="$funcs strndup" +funcs="$funcs strnlen" funcs="$funcs strrchr" funcs="$funcs strstr" funcs="$funcs strtod" @@ -5380,8 +5415,8 @@ if test "x" = "y"; then random realpath rename rindex \ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \ stpcpy stpncpy strcasecmp strchr strdup \ - strerror strncasecmp strndup strrchr strsignal strstr strtod strtol \ - strtoul strverscmp sysconf sysctl sysmp \ + strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \ + strtol strtoul strverscmp sysconf sysctl sysmp \ table times tmpnam \ vasprintf vfprintf vprintf vsprintf \ wait3 wait4 waitpid @@ -5475,7 +5510,6 @@ fi setobjs= CHECK= -target_header_dir= if test -n "${with_target_subdir}"; then # We are being configured as a target library. AC_REPLACE_FUNCS @@ -5663,6 +5697,12 @@ esac esac case " $LIBOBJS " in + *" strnlen.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strnlen.$ac_objext" + ;; +esac + + case " $LIBOBJS " in *" strverscmp.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strverscmp.$ac_objext" ;; @@ -5683,7 +5723,7 @@ esac for f in $funcs; do case "$f" in - asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid) + asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid) ;; *) n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` @@ -5752,29 +5792,6 @@ _ACEOF esac - # We may wish to install the target headers somewhere. - # Check whether --enable-install-libiberty was given. -if test "${enable_install_libiberty+set}" = set; then : - enableval=$enable_install_libiberty; enable_install_libiberty=$enableval -else - enable_install_libiberty=no -fi - - # Option parsed, now set things appropriately. - case x"$enable_install_libiberty" in - xyes|x) - target_header_dir=libiberty - ;; - xno) - target_header_dir= - ;; - *) - # This could be sanity-checked in various ways... - target_header_dir="${enable_install_libiberty}" - ;; - esac - - else # Not a target library, so we set things up to run the test suite. diff --git a/libiberty/configure.ac b/libiberty/configure.ac index 754b66a061..d6180bcddd 100644 --- a/libiberty/configure.ac +++ b/libiberty/configure.ac @@ -128,6 +128,31 @@ if test $cross_compiling = no && test $multilib = yes \ cross_compiling=maybe fi +# We may wish to install the target headers somewhere. +AC_MSG_CHECKING([whether to install libiberty headers and static library]) +dnl install-libiberty is disabled by default + +AC_ARG_ENABLE(install-libiberty, +[ --enable-install-libiberty Install headers and library for end users], +enable_install_libiberty=$enableval, +enable_install_libiberty=no)dnl + +# Option parsed, now set things appropriately. +case x"$enable_install_libiberty" in + xyes|x) + target_header_dir=libiberty + ;; + xno) + target_header_dir= + ;; + *) + # This could be sanity-checked in various ways... + target_header_dir="${enable_install_libiberty}" + ;; +esac +AC_MSG_RESULT($enable_install_libiberty) +AC_MSG_NOTICE([target_header_dir = $target_header_dir]) + GCC_NO_EXECUTABLES AC_PROG_CC AC_SYS_LARGEFILE @@ -200,6 +225,12 @@ case "${enable_shared}" in "") shared=no ;; *) shared=yes ;; esac + +# ...unless --enable-host-shared was passed from top-level config: +if [[ "${enable_host_shared}" = "yes" ]]; then + shared=yes +fi + if [[ "${shared}" != "yes" ]]; then PICFLAG= fi @@ -322,6 +353,7 @@ funcs="$funcs strchr" funcs="$funcs strdup" funcs="$funcs strncasecmp" funcs="$funcs strndup" +funcs="$funcs strnlen" funcs="$funcs strrchr" funcs="$funcs strstr" funcs="$funcs strtod" @@ -362,8 +394,8 @@ if test "x" = "y"; then random realpath rename rindex \ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \ stpcpy stpncpy strcasecmp strchr strdup \ - strerror strncasecmp strndup strrchr strsignal strstr strtod strtol \ - strtoul strverscmp sysconf sysctl sysmp \ + strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \ + strtol strtoul strverscmp sysconf sysctl sysmp \ table times tmpnam \ vasprintf vfprintf vprintf vsprintf \ wait3 wait4 waitpid) @@ -379,7 +411,6 @@ fi setobjs= CHECK= -target_header_dir= if test -n "${with_target_subdir}"; then # We are being configured as a target library. AC_REPLACE_FUNCS @@ -442,13 +473,14 @@ if test -n "${with_target_subdir}"; then AC_LIBOBJ([stpcpy]) AC_LIBOBJ([stpncpy]) AC_LIBOBJ([strndup]) + AC_LIBOBJ([strnlen]) AC_LIBOBJ([strverscmp]) AC_LIBOBJ([vasprintf]) AC_LIBOBJ([waitpid]) for f in $funcs; do case "$f" in - asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid) + asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid) ;; *) n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` @@ -490,27 +522,6 @@ if test -n "${with_target_subdir}"; then esac - # We may wish to install the target headers somewhere. - AC_ARG_ENABLE(install-libiberty, - [ --enable-install-libiberty Install headers for end users], - enable_install_libiberty=$enableval, - enable_install_libiberty=no)dnl - - # Option parsed, now set things appropriately. - case x"$enable_install_libiberty" in - xyes|x) - target_header_dir=libiberty - ;; - xno) - target_header_dir= - ;; - *) - # This could be sanity-checked in various ways... - target_header_dir="${enable_install_libiberty}" - ;; - esac - - else # Not a target library, so we set things up to run the test suite. diff --git a/libiberty/copying-lib.texi b/libiberty/copying-lib.texi index 79e1038783..31ef68bf49 100644 --- a/libiberty/copying-lib.texi +++ b/libiberty/copying-lib.texi @@ -476,12 +476,7 @@ decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. -@iftex -@heading NO WARRANTY -@end iftex -@ifinfo @center NO WARRANTY -@end ifinfo @item BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c index d95b56c71a..3d5d33ef59 100644 --- a/libiberty/cp-demangle.c +++ b/libiberty/cp-demangle.c @@ -1,5 +1,5 @@ /* Demangler for g++ V3 ABI. - Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2014 Free Software Foundation, Inc. Written by Ian Lance Taylor <ian@wasabisystems.com>. @@ -275,6 +275,31 @@ struct d_growable_string int allocation_failure; }; +/* A demangle component and some scope captured when it was first + traversed. */ + +struct d_saved_scope +{ + /* The component whose scope this is. */ + const struct demangle_component *container; + /* The list of templates, if any, that was current when this + scope was captured. */ + struct d_print_template *templates; +}; + +/* Checkpoint structure to allow backtracking. This holds copies + of the fields of struct d_info that need to be restored + if a trial parse needs to be backtracked over. */ + +struct d_info_checkpoint +{ + const char *n; + int next_comp; + int next_sub; + int did_subs; + int expansion; +}; + enum { D_PRINT_BUFFER_LENGTH = 256 }; struct d_print_info { @@ -302,6 +327,20 @@ struct d_print_info int pack_index; /* Number of d_print_flush calls so far. */ unsigned long int flush_count; + /* Array of saved scopes for evaluating substitutions. */ + struct d_saved_scope *saved_scopes; + /* Index of the next unused saved scope in the above array. */ + int next_saved_scope; + /* Number of saved scopes in the above array. */ + int num_saved_scopes; + /* Array of templates for saving into scopes. */ + struct d_print_template *copy_templates; + /* Index of the next unused copy template in the above array. */ + int next_copy_template; + /* Number of copy templates in the above array. */ + int num_copy_templates; + /* The nearest enclosing template, if any. */ + const struct demangle_component *current_template; }; #ifdef CP_DEMANGLE_DEBUG @@ -382,6 +421,9 @@ static struct demangle_component ** d_cv_qualifiers (struct d_info *, struct demangle_component **, int); static struct demangle_component * +d_ref_qualifier (struct d_info *, struct demangle_component *); + +static struct demangle_component * d_function_type (struct d_info *); static struct demangle_component * @@ -425,6 +467,10 @@ d_add_substitution (struct d_info *, struct demangle_component *); static struct demangle_component *d_substitution (struct d_info *, int); +static void d_checkpoint (struct d_info *, struct d_info_checkpoint *); + +static void d_backtrack (struct d_info *, struct d_info_checkpoint *); + static void d_growable_string_init (struct d_growable_string *, size_t); static inline void @@ -437,7 +483,8 @@ static void d_growable_string_callback_adapter (const char *, size_t, void *); static void -d_print_init (struct d_print_info *, demangle_callbackref, void *); +d_print_init (struct d_print_info *, demangle_callbackref, void *, + const struct demangle_component *); static inline void d_print_error (struct d_print_info *); @@ -508,6 +555,11 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_NAME: printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s); return; + case DEMANGLE_COMPONENT_TAGGED_NAME: + printf ("tagged name\n"); + d_dump (dc->u.s_binary.left, indent + 2); + d_dump (dc->u.s_binary.right, indent + 2); + return; case DEMANGLE_COMPONENT_TEMPLATE_PARAM: printf ("template parameter %ld\n", dc->u.s_number.number); return; @@ -609,6 +661,12 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_CONST_THIS: printf ("const this\n"); break; + case DEMANGLE_COMPONENT_REFERENCE_THIS: + printf ("reference this\n"); + break; + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: + printf ("rvalue reference this\n"); + break; case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: printf ("vendor type qualifier\n"); break; @@ -696,6 +754,20 @@ d_dump (struct demangle_component *dc, int indent) case DEMANGLE_COMPONENT_PACK_EXPANSION: printf ("pack expansion\n"); break; + case DEMANGLE_COMPONENT_TLS_INIT: + printf ("tls init function\n"); + break; + case DEMANGLE_COMPONENT_TLS_WRAPPER: + printf ("tls wrapper function\n"); + break; + case DEMANGLE_COMPONENT_DEFAULT_ARG: + printf ("default argument %d\n", dc->u.s_unary_num.num); + d_dump (dc->u.s_unary_num.sub, indent+2); + return; + case DEMANGLE_COMPONENT_LAMBDA: + printf ("lambda %d\n", dc->u.s_unary_num.num); + d_dump (dc->u.s_unary_num.sub, indent+2); + return; } d_dump (d_left (dc), indent + 2); @@ -803,6 +875,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_QUAL_NAME: case DEMANGLE_COMPONENT_LOCAL_NAME: case DEMANGLE_COMPONENT_TYPED_NAME: + case DEMANGLE_COMPONENT_TAGGED_NAME: case DEMANGLE_COMPONENT_TEMPLATE: case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: @@ -832,6 +905,8 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_COVARIANT_THUNK: case DEMANGLE_COMPONENT_JAVA_CLASS: case DEMANGLE_COMPONENT_GUARD: + case DEMANGLE_COMPONENT_TLS_INIT: + case DEMANGLE_COMPONENT_TLS_WRAPPER: case DEMANGLE_COMPONENT_REFTEMP: case DEMANGLE_COMPONENT_HIDDEN_ALIAS: case DEMANGLE_COMPONENT_TRANSACTION_CLONE: @@ -871,6 +946,8 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_REFERENCE_THIS: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: break; @@ -1109,6 +1186,8 @@ has_return_type (struct demangle_component *dc) case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_REFERENCE_THIS: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: return has_return_type (d_left (dc)); } } @@ -1164,7 +1243,9 @@ d_encoding (struct d_info *di, int top_level) v2 demangler without DMGL_PARAMS. */ while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS || dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS - || dc->type == DEMANGLE_COMPONENT_CONST_THIS) + || dc->type == DEMANGLE_COMPONENT_CONST_THIS + || dc->type == DEMANGLE_COMPONENT_REFERENCE_THIS + || dc->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS) dc = d_left (dc); /* If the top level is a DEMANGLE_COMPONENT_LOCAL_NAME, then @@ -1178,7 +1259,9 @@ d_encoding (struct d_info *di, int top_level) dcr = d_right (dc); while (dcr->type == DEMANGLE_COMPONENT_RESTRICT_THIS || dcr->type == DEMANGLE_COMPONENT_VOLATILE_THIS - || dcr->type == DEMANGLE_COMPONENT_CONST_THIS) + || dcr->type == DEMANGLE_COMPONENT_CONST_THIS + || dcr->type == DEMANGLE_COMPONENT_REFERENCE_THIS + || dcr->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS) dcr = d_left (dcr); dc->u.s_binary.right = dcr; } @@ -1194,6 +1277,23 @@ d_encoding (struct d_info *di, int top_level) } } +/* <tagged-name> ::= <name> B <source-name> */ + +static struct demangle_component * +d_abi_tags (struct d_info *di, struct demangle_component *dc) +{ + char peek; + while (peek = d_peek_char (di), + peek == 'B') + { + struct demangle_component *tag; + d_advance (di, 1); + tag = d_source_name (di); + dc = d_make_comp (di, DEMANGLE_COMPONENT_TAGGED_NAME, dc, tag); + } + return dc; +} + /* <name> ::= <nested-name> ::= <unscoped-name> ::= <unscoped-template-name> <template-args> @@ -1220,7 +1320,6 @@ d_name (struct d_info *di) case 'Z': return d_local_name (di); - case 'L': case 'U': return d_unqualified_name (di); @@ -1267,6 +1366,7 @@ d_name (struct d_info *di) return dc; } + case 'L': default: dc = d_unqualified_name (di); if (d_peek_char (di) == 'I') @@ -1283,8 +1383,8 @@ d_name (struct d_info *di) } } -/* <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E - ::= N [<CV-qualifiers>] <template-prefix> <template-args> E +/* <nested-name> ::= N [<CV-qualifiers>] [<ref-qualifier>] <prefix> <unqualified-name> E + ::= N [<CV-qualifiers>] [<ref-qualifier>] <template-prefix> <template-args> E */ static struct demangle_component * @@ -1292,6 +1392,7 @@ d_nested_name (struct d_info *di) { struct demangle_component *ret; struct demangle_component **pret; + struct demangle_component *rqual; if (! d_check_char (di, 'N')) return NULL; @@ -1300,10 +1401,20 @@ d_nested_name (struct d_info *di) if (pret == NULL) return NULL; + /* Parse the ref-qualifier now and then attach it + once we have something to attach it to. */ + rqual = d_ref_qualifier (di, NULL); + *pret = d_prefix (di); if (*pret == NULL) return NULL; + if (rqual) + { + d_left (rqual) = ret; + ret = rqual; + } + if (! d_check_char (di, 'E')) return NULL; @@ -1408,15 +1519,14 @@ d_prefix (struct d_info *di) static struct demangle_component * d_unqualified_name (struct d_info *di) { + struct demangle_component *ret; char peek; peek = d_peek_char (di); if (IS_DIGIT (peek)) - return d_source_name (di); + ret = d_source_name (di); else if (IS_LOWER (peek)) { - struct demangle_component *ret; - ret = d_operator_name (di); if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) { @@ -1425,14 +1535,11 @@ d_unqualified_name (struct d_info *di) ret = d_make_comp (di, DEMANGLE_COMPONENT_UNARY, ret, d_source_name (di)); } - return ret; } else if (peek == 'C' || peek == 'D') - return d_ctor_dtor_name (di); + ret = d_ctor_dtor_name (di); else if (peek == 'L') { - struct demangle_component * ret; - d_advance (di, 1); ret = d_source_name (di); @@ -1440,22 +1547,27 @@ d_unqualified_name (struct d_info *di) return NULL; if (! d_discriminator (di)) return NULL; - return ret; } else if (peek == 'U') { switch (d_peek_next_char (di)) { case 'l': - return d_lambda (di); + ret = d_lambda (di); + break; case 't': - return d_unnamed_type (di); + ret = d_unnamed_type (di); + break; default: return NULL; } } else return NULL; + + if (d_peek_char (di) == 'B') + ret = d_abi_tags (di, ret); + return ret; } /* <source-name> ::= <(positive length) number> <identifier> */ @@ -1582,11 +1694,13 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "an", NL ("&"), 2 }, { "at", NL ("alignof "), 1 }, { "az", NL ("alignof "), 1 }, + { "cc", NL ("const_cast"), 2 }, { "cl", NL ("()"), 2 }, { "cm", NL (","), 2 }, { "co", NL ("~"), 1 }, { "dV", NL ("/="), 2 }, { "da", NL ("delete[] "), 1 }, + { "dc", NL ("dynamic_cast"), 2 }, { "de", NL ("*"), 1 }, { "dl", NL ("delete "), 1 }, { "ds", NL (".*"), 2 }, @@ -1626,8 +1740,10 @@ const struct demangle_operator_info cplus_demangle_operators[] = { "qu", NL ("?"), 3 }, { "rM", NL ("%="), 2 }, { "rS", NL (">>="), 2 }, + { "rc", NL ("reinterpret_cast"), 2 }, { "rm", NL ("%"), 2 }, { "rs", NL (">>"), 2 }, + { "sc", NL ("static_cast"), 2 }, { "st", NL ("sizeof "), 1 }, { "sz", NL ("sizeof "), 1 }, { "tr", NL ("throw"), 0 }, @@ -1646,8 +1762,15 @@ d_operator_name (struct d_info *di) if (c1 == 'v' && IS_DIGIT (c2)) return d_make_extended_operator (di, c2 - '0', d_source_name (di)); else if (c1 == 'c' && c2 == 'v') - return d_make_comp (di, DEMANGLE_COMPONENT_CAST, - cplus_demangle_type (di), NULL); + { + struct demangle_component *type; + int was_conversion = di->is_conversion; + + di->is_conversion = ! di->is_expression; + type = cplus_demangle_type (di); + di->is_conversion = was_conversion; + return d_make_comp (di, DEMANGLE_COMPONENT_CAST, type, NULL); + } else { /* LOW is the inclusive lower bound. */ @@ -1863,6 +1986,14 @@ d_special_name (struct d_info *di) return d_make_comp (di, DEMANGLE_COMPONENT_JAVA_CLASS, cplus_demangle_type (di), NULL); + case 'H': + return d_make_comp (di, DEMANGLE_COMPONENT_TLS_INIT, + d_name (di), NULL); + + case 'W': + return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER, + d_name (di), NULL); + default: return NULL; } @@ -1985,6 +2116,9 @@ d_ctor_dtor_name (struct d_info *di) case '3': kind = gnu_v3_complete_object_allocating_ctor; break; + case '4': + kind = gnu_v3_unified_ctor; + break; case '5': kind = gnu_v3_object_ctor_group; break; @@ -2010,6 +2144,10 @@ d_ctor_dtor_name (struct d_info *di) case '2': kind = gnu_v3_base_object_dtor; break; + /* digit '3' is not used */ + case '4': + kind = gnu_v3_unified_dtor; + break; case '5': kind = gnu_v3_object_dtor_group; break; @@ -2118,8 +2256,28 @@ cplus_demangle_type (struct d_info *di) pret = d_cv_qualifiers (di, &ret, 0); if (pret == NULL) return NULL; - *pret = cplus_demangle_type (di); - if (! *pret || ! d_add_substitution (di, ret)) + if (d_peek_char (di) == 'F') + { + /* cv-qualifiers before a function type apply to 'this', + so avoid adding the unqualified function type to + the substitution list. */ + *pret = d_function_type (di); + } + else + *pret = cplus_demangle_type (di); + if (!*pret) + return NULL; + if ((*pret)->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS + || (*pret)->type == DEMANGLE_COMPONENT_REFERENCE_THIS) + { + /* Move the ref-qualifier outside the cv-qualifiers so that + they are printed in the right order. */ + struct demangle_component *fn = d_left (*pret); + d_left (*pret) = ret; + ret = *pret; + *pret = fn; + } + if (! d_add_substitution (di, ret)) return NULL; return ret; } @@ -2168,13 +2326,61 @@ cplus_demangle_type (struct d_info *di) ret = d_template_param (di); if (d_peek_char (di) == 'I') { - /* This is <template-template-param> <template-args>. The - <template-template-param> part is a substitution + /* This may be <template-template-param> <template-args>. + If this is the type for a conversion operator, we can + have a <template-template-param> here only by following + a derivation like this: + + <nested-name> + -> <template-prefix> <template-args> + -> <prefix> <template-unqualified-name> <template-args> + -> <unqualified-name> <template-unqualified-name> <template-args> + -> <source-name> <template-unqualified-name> <template-args> + -> <source-name> <operator-name> <template-args> + -> <source-name> cv <type> <template-args> + -> <source-name> cv <template-template-param> <template-args> <template-args> + + where the <template-args> is followed by another. + Otherwise, we must have a derivation like this: + + <nested-name> + -> <template-prefix> <template-args> + -> <prefix> <template-unqualified-name> <template-args> + -> <unqualified-name> <template-unqualified-name> <template-args> + -> <source-name> <template-unqualified-name> <template-args> + -> <source-name> <operator-name> <template-args> + -> <source-name> cv <type> <template-args> + -> <source-name> cv <template-param> <template-args> + + where we need to leave the <template-args> to be processed + by d_prefix (following the <template-prefix>). + + The <template-template-param> part is a substitution candidate. */ - if (! d_add_substitution (di, ret)) - return NULL; - ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, - d_template_args (di)); + if (! di->is_conversion) + { + if (! d_add_substitution (di, ret)) + return NULL; + ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, + d_template_args (di)); + } + else + { + struct demangle_component *args; + struct d_info_checkpoint checkpoint; + + d_checkpoint (di, &checkpoint); + args = d_template_args (di); + if (d_peek_char (di) == 'I') + { + if (! d_add_substitution (di, ret)) + return NULL; + ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, + args); + } + else + d_backtrack (di, &checkpoint); + } } break; @@ -2422,7 +2628,38 @@ d_cv_qualifiers (struct d_info *di, return pret; } -/* <function-type> ::= F [Y] <bare-function-type> E */ +/* <ref-qualifier> ::= R + ::= O */ + +static struct demangle_component * +d_ref_qualifier (struct d_info *di, struct demangle_component *sub) +{ + struct demangle_component *ret = sub; + char peek; + + peek = d_peek_char (di); + if (peek == 'R' || peek == 'O') + { + enum demangle_component_type t; + if (peek == 'R') + { + t = DEMANGLE_COMPONENT_REFERENCE_THIS; + di->expansion += sizeof "&"; + } + else + { + t = DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS; + di->expansion += sizeof "&&"; + } + d_advance (di, 1); + + ret = d_make_comp (di, t, ret, NULL); + } + + return ret; +} + +/* <function-type> ::= F [Y] <bare-function-type> [<ref-qualifier>] E */ static struct demangle_component * d_function_type (struct d_info *di) @@ -2438,6 +2675,8 @@ d_function_type (struct d_info *di) d_advance (di, 1); } ret = d_bare_function_type (di, 1); + ret = d_ref_qualifier (di, ret); + if (! d_check_char (di, 'E')) return NULL; return ret; @@ -2460,6 +2699,10 @@ d_parmlist (struct d_info *di) char peek = d_peek_char (di); if (peek == '\0' || peek == 'E' || peek == '.') break; + if ((peek == 'R' || peek == 'O') + && d_peek_next_char (di) == 'E') + /* Function ref-qualifier, not a ref prefix for a parameter type. */ + break; type = cplus_demangle_type (di); if (type == NULL) return NULL; @@ -2610,41 +2853,32 @@ d_pointer_to_member_type (struct d_info *di) { struct demangle_component *cl; struct demangle_component *mem; - struct demangle_component **pmem; if (! d_check_char (di, 'M')) return NULL; cl = cplus_demangle_type (di); - - /* The ABI specifies that any type can be a substitution source, and - that M is followed by two types, and that when a CV-qualified - type is seen both the base type and the CV-qualified types are - substitution sources. The ABI also specifies that for a pointer - to a CV-qualified member function, the qualifiers are attached to - the second type. Given the grammar, a plain reading of the ABI - suggests that both the CV-qualified member function and the - non-qualified member function are substitution sources. However, - g++ does not work that way. g++ treats only the CV-qualified - member function as a substitution source. FIXME. So to work - with g++, we need to pull off the CV-qualifiers here, in order to - avoid calling add_substitution() in cplus_demangle_type(). But - for a CV-qualified member which is not a function, g++ does - follow the ABI, so we need to handle that case here by calling - d_add_substitution ourselves. */ - - pmem = d_cv_qualifiers (di, &mem, 1); - if (pmem == NULL) - return NULL; - *pmem = cplus_demangle_type (di); - if (*pmem == NULL) + if (cl == NULL) return NULL; - if (pmem != &mem && (*pmem)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE) - { - if (! d_add_substitution (di, mem)) - return NULL; - } + /* The ABI says, "The type of a non-static member function is considered + to be different, for the purposes of substitution, from the type of a + namespace-scope or static member function whose type appears + similar. The types of two non-static member functions are considered + to be different, for the purposes of substitution, if the functions + are members of different classes. In other words, for the purposes of + substitution, the class of which the function is a member is + considered part of the type of function." + + For a pointer to member function, this call to cplus_demangle_type + will end up adding a (possibly qualified) non-member function type to + the substitution table, which is not correct; however, the member + function type will never be used in a substitution, so putting the + wrong type in the substitution table is harmless. */ + + mem = cplus_demangle_type (di); + if (mem == NULL) + return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_PTRMEM_TYPE, cl, mem); } @@ -2809,6 +3043,18 @@ d_exprlist (struct d_info *di, char terminator) return list; } +/* Returns nonzero iff OP is an operator for a C++ cast: const_cast, + dynamic_cast, static_cast or reinterpret_cast. */ + +static int +op_is_new_cast (struct demangle_component *op) +{ + const char *code = op->u.s_operator.op->code; + return (code[1] == 'c' + && (code[0] == 's' || code[0] == 'd' + || code[0] == 'c' || code[0] == 'r')); +} + /* <expression> ::= <(unary) operator-name> <expression> ::= <(binary) operator-name> <expression> <expression> ::= <(trinary) operator-name> <expression> <expression> <expression> @@ -2820,8 +3066,8 @@ d_exprlist (struct d_info *di, char terminator) ::= <expr-primary> */ -static struct demangle_component * -d_expression (struct d_info *di) +static inline struct demangle_component * +d_expression_1 (struct d_info *di) { char peek; @@ -2849,7 +3095,7 @@ d_expression (struct d_info *di) { d_advance (di, 2); return d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, - d_expression (di), NULL); + d_expression_1 (di), NULL); } else if (peek == 'f' && d_peek_next_char (di) == 'p') { @@ -2954,7 +3200,7 @@ d_expression (struct d_info *di) && d_check_char (di, '_')) operand = d_exprlist (di, 'E'); else - operand = d_expression (di); + operand = d_expression_1 (di); if (suffix) /* Indicate the suffix variant for d_print_comp. */ @@ -2971,7 +3217,10 @@ d_expression (struct d_info *di) struct demangle_component *left; struct demangle_component *right; - left = d_expression (di); + if (op_is_new_cast (op)) + left = cplus_demangle_type (di); + else + left = d_expression_1 (di); if (!strcmp (code, "cl")) right = d_exprlist (di, 'E'); else if (!strcmp (code, "dt") || !strcmp (code, "pt")) @@ -2982,7 +3231,7 @@ d_expression (struct d_info *di) right, d_template_args (di)); } else - right = d_expression (di); + right = d_expression_1 (di); return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, d_make_comp (di, @@ -2998,9 +3247,9 @@ d_expression (struct d_info *di) if (!strcmp (code, "qu")) { /* ?: expression. */ - first = d_expression (di); - second = d_expression (di); - third = d_expression (di); + first = d_expression_1 (di); + second = d_expression_1 (di); + third = d_expression_1 (di); } else if (code[0] == 'n') { @@ -3024,7 +3273,7 @@ d_expression (struct d_info *di) else if (d_peek_char (di) == 'i' && d_peek_next_char (di) == 'l') /* initializer-list. */ - third = d_expression (di); + third = d_expression_1 (di); else return NULL; } @@ -3044,6 +3293,18 @@ d_expression (struct d_info *di) } } +static struct demangle_component * +d_expression (struct d_info *di) +{ + struct demangle_component *ret; + int was_expression = di->is_expression; + + di->is_expression = 1; + ret = d_expression_1 (di); + di->is_expression = was_expression; + return ret; +} + /* <expr-primary> ::= L <type> <(value) number> E ::= L <type> <(value) float> E ::= L <mangled-name> E @@ -3109,6 +3370,7 @@ d_expr_primary (struct d_info *di) /* <local-name> ::= Z <(function) encoding> E <(entity) name> [<discriminator>] ::= Z <(function) encoding> E s [<discriminator>] + ::= Z <(function) encoding> E d [<parameter> number>] _ <entity name> */ static struct demangle_component * @@ -3428,6 +3690,26 @@ d_substitution (struct d_info *di, int prefix) } } +static void +d_checkpoint (struct d_info *di, struct d_info_checkpoint *checkpoint) +{ + checkpoint->n = di->n; + checkpoint->next_comp = di->next_comp; + checkpoint->next_sub = di->next_sub; + checkpoint->did_subs = di->did_subs; + checkpoint->expansion = di->expansion; +} + +static void +d_backtrack (struct d_info *di, struct d_info_checkpoint *checkpoint) +{ + di->n = checkpoint->n; + di->next_comp = checkpoint->next_comp; + di->next_sub = checkpoint->next_sub; + di->did_subs = checkpoint->did_subs; + di->expansion = checkpoint->expansion; +} + /* Initialize a growable string. */ static void @@ -3504,11 +3786,141 @@ d_growable_string_callback_adapter (const char *s, size_t l, void *opaque) d_growable_string_append_buffer (dgs, s, l); } +/* Walk the tree, counting the number of templates encountered, and + the number of times a scope might be saved. These counts will be + used to allocate data structures for d_print_comp, so the logic + here must mirror the logic d_print_comp will use. It is not + important that the resulting numbers are exact, so long as they + are larger than the actual numbers encountered. */ + +static void +d_count_templates_scopes (int *num_templates, int *num_scopes, + const struct demangle_component *dc) +{ + if (dc == NULL) + return; + + switch (dc->type) + { + case DEMANGLE_COMPONENT_NAME: + case DEMANGLE_COMPONENT_TEMPLATE_PARAM: + case DEMANGLE_COMPONENT_FUNCTION_PARAM: + case DEMANGLE_COMPONENT_SUB_STD: + case DEMANGLE_COMPONENT_BUILTIN_TYPE: + case DEMANGLE_COMPONENT_OPERATOR: + case DEMANGLE_COMPONENT_CHARACTER: + case DEMANGLE_COMPONENT_NUMBER: + case DEMANGLE_COMPONENT_UNNAMED_TYPE: + break; + + case DEMANGLE_COMPONENT_TEMPLATE: + (*num_templates)++; + goto recurse_left_right; + + case DEMANGLE_COMPONENT_REFERENCE: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE: + if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) + (*num_scopes)++; + goto recurse_left_right; + + case DEMANGLE_COMPONENT_QUAL_NAME: + case DEMANGLE_COMPONENT_LOCAL_NAME: + case DEMANGLE_COMPONENT_TYPED_NAME: + case DEMANGLE_COMPONENT_VTABLE: + case DEMANGLE_COMPONENT_VTT: + case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: + case DEMANGLE_COMPONENT_TYPEINFO: + case DEMANGLE_COMPONENT_TYPEINFO_NAME: + case DEMANGLE_COMPONENT_TYPEINFO_FN: + case DEMANGLE_COMPONENT_THUNK: + case DEMANGLE_COMPONENT_VIRTUAL_THUNK: + case DEMANGLE_COMPONENT_COVARIANT_THUNK: + case DEMANGLE_COMPONENT_JAVA_CLASS: + case DEMANGLE_COMPONENT_GUARD: + case DEMANGLE_COMPONENT_TLS_INIT: + case DEMANGLE_COMPONENT_TLS_WRAPPER: + case DEMANGLE_COMPONENT_REFTEMP: + case DEMANGLE_COMPONENT_HIDDEN_ALIAS: + case DEMANGLE_COMPONENT_RESTRICT: + case DEMANGLE_COMPONENT_VOLATILE: + case DEMANGLE_COMPONENT_CONST: + case DEMANGLE_COMPONENT_RESTRICT_THIS: + case DEMANGLE_COMPONENT_VOLATILE_THIS: + case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_REFERENCE_THIS: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: + case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: + case DEMANGLE_COMPONENT_POINTER: + case DEMANGLE_COMPONENT_COMPLEX: + case DEMANGLE_COMPONENT_IMAGINARY: + case DEMANGLE_COMPONENT_VENDOR_TYPE: + case DEMANGLE_COMPONENT_FUNCTION_TYPE: + case DEMANGLE_COMPONENT_ARRAY_TYPE: + case DEMANGLE_COMPONENT_PTRMEM_TYPE: + case DEMANGLE_COMPONENT_FIXED_TYPE: + case DEMANGLE_COMPONENT_VECTOR_TYPE: + case DEMANGLE_COMPONENT_ARGLIST: + case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: + case DEMANGLE_COMPONENT_INITIALIZER_LIST: + case DEMANGLE_COMPONENT_CAST: + case DEMANGLE_COMPONENT_NULLARY: + case DEMANGLE_COMPONENT_UNARY: + case DEMANGLE_COMPONENT_BINARY: + case DEMANGLE_COMPONENT_BINARY_ARGS: + case DEMANGLE_COMPONENT_TRINARY: + case DEMANGLE_COMPONENT_TRINARY_ARG1: + case DEMANGLE_COMPONENT_TRINARY_ARG2: + case DEMANGLE_COMPONENT_LITERAL: + case DEMANGLE_COMPONENT_LITERAL_NEG: + case DEMANGLE_COMPONENT_JAVA_RESOURCE: + case DEMANGLE_COMPONENT_COMPOUND_NAME: + case DEMANGLE_COMPONENT_DECLTYPE: + case DEMANGLE_COMPONENT_TRANSACTION_CLONE: + case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE: + case DEMANGLE_COMPONENT_PACK_EXPANSION: + case DEMANGLE_COMPONENT_TAGGED_NAME: + case DEMANGLE_COMPONENT_CLONE: + recurse_left_right: + d_count_templates_scopes (num_templates, num_scopes, + d_left (dc)); + d_count_templates_scopes (num_templates, num_scopes, + d_right (dc)); + break; + + case DEMANGLE_COMPONENT_CTOR: + d_count_templates_scopes (num_templates, num_scopes, + dc->u.s_ctor.name); + break; + + case DEMANGLE_COMPONENT_DTOR: + d_count_templates_scopes (num_templates, num_scopes, + dc->u.s_dtor.name); + break; + + case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: + d_count_templates_scopes (num_templates, num_scopes, + dc->u.s_extended_operator.name); + break; + + case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: + case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: + d_count_templates_scopes (num_templates, num_scopes, + d_left (dc)); + break; + + case DEMANGLE_COMPONENT_LAMBDA: + case DEMANGLE_COMPONENT_DEFAULT_ARG: + d_count_templates_scopes (num_templates, num_scopes, + dc->u.s_unary_num.sub); + break; + } +} + /* Initialize a print information structure. */ static void d_print_init (struct d_print_info *dpi, demangle_callbackref callback, - void *opaque) + void *opaque, const struct demangle_component *dc) { dpi->len = 0; dpi->last_char = '\0'; @@ -3521,6 +3933,20 @@ d_print_init (struct d_print_info *dpi, demangle_callbackref callback, dpi->opaque = opaque; dpi->demangle_failure = 0; + + dpi->saved_scopes = NULL; + dpi->next_saved_scope = 0; + dpi->num_saved_scopes = 0; + + dpi->copy_templates = NULL; + dpi->next_copy_template = 0; + dpi->num_copy_templates = 0; + + d_count_templates_scopes (&dpi->num_copy_templates, + &dpi->num_saved_scopes, dc); + dpi->num_copy_templates *= dpi->num_saved_scopes; + + dpi->current_template = NULL; } /* Indicate that an error occurred during printing, and test for error. */ @@ -3606,9 +4032,24 @@ cplus_demangle_print_callback (int options, { struct d_print_info dpi; - d_print_init (&dpi, callback, opaque); + d_print_init (&dpi, callback, opaque, dc); + + { +#ifdef CP_DYNAMIC_ARRAYS + __extension__ struct d_saved_scope scopes[dpi.num_saved_scopes]; + __extension__ struct d_print_template temps[dpi.num_copy_templates]; + + dpi.saved_scopes = scopes; + dpi.copy_templates = temps; +#else + dpi.saved_scopes = alloca (dpi.num_saved_scopes + * sizeof (*dpi.saved_scopes)); + dpi.copy_templates = alloca (dpi.num_copy_templates + * sizeof (*dpi.copy_templates)); +#endif - d_print_comp (&dpi, options, dc); + d_print_comp (&dpi, options, dc); + } d_print_flush (&dpi); @@ -3710,11 +4151,13 @@ d_find_pack (struct d_print_info *dpi, case DEMANGLE_COMPONENT_LAMBDA: case DEMANGLE_COMPONENT_NAME: + case DEMANGLE_COMPONENT_TAGGED_NAME: case DEMANGLE_COMPONENT_OPERATOR: case DEMANGLE_COMPONENT_BUILTIN_TYPE: case DEMANGLE_COMPONENT_SUB_STD: case DEMANGLE_COMPONENT_CHARACTER: case DEMANGLE_COMPONENT_FUNCTION_PARAM: + case DEMANGLE_COMPONENT_UNNAMED_TYPE: return NULL; case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: @@ -3767,6 +4210,62 @@ d_print_subexpr (struct d_print_info *dpi, int options, d_append_char (dpi, ')'); } +/* Save the current scope. */ + +static void +d_save_scope (struct d_print_info *dpi, + const struct demangle_component *container) +{ + struct d_saved_scope *scope; + struct d_print_template *src, **link; + + if (dpi->next_saved_scope >= dpi->num_saved_scopes) + { + d_print_error (dpi); + return; + } + scope = &dpi->saved_scopes[dpi->next_saved_scope]; + dpi->next_saved_scope++; + + scope->container = container; + link = &scope->templates; + + for (src = dpi->templates; src != NULL; src = src->next) + { + struct d_print_template *dst; + + if (dpi->next_copy_template >= dpi->num_copy_templates) + { + d_print_error (dpi); + return; + } + dst = &dpi->copy_templates[dpi->next_copy_template]; + dpi->next_copy_template++; + + dst->template_decl = src->template_decl; + *link = dst; + link = &dst->next; + } + + *link = NULL; +} + +/* Attempt to locate a previously saved scope. Returns NULL if no + corresponding saved scope was found. */ + +static struct d_saved_scope * +d_get_saved_scope (struct d_print_info *dpi, + const struct demangle_component *container) +{ + int i; + + for (i = 0; i < dpi->next_saved_scope; i++) + if (dpi->saved_scopes[i].container == container) + return &dpi->saved_scopes[i]; + + return NULL; +} + /* Subroutine to handle components. */ static void @@ -3777,6 +4276,13 @@ d_print_comp (struct d_print_info *dpi, int options, without needing to modify *dc. */ const struct demangle_component *mod_inner = NULL; + /* Variable used to store the current templates while a previously + captured scope is used. */ + struct d_print_template *saved_templates; + + /* Nonzero if templates have been stored in the above variable. */ + int need_template_restore = 0; + if (dc == NULL) { d_print_error (dpi); @@ -3794,6 +4300,13 @@ d_print_comp (struct d_print_info *dpi, int options, d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len); return; + case DEMANGLE_COMPONENT_TAGGED_NAME: + d_print_comp (dpi, options, d_left (dc)); + d_append_string (dpi, "[abi:"); + d_print_comp (dpi, options, d_right (dc)); + d_append_char (dpi, ']'); + return; + case DEMANGLE_COMPONENT_QUAL_NAME: case DEMANGLE_COMPONENT_LOCAL_NAME: d_print_comp (dpi, options, d_left (dc)); @@ -3801,7 +4314,17 @@ d_print_comp (struct d_print_info *dpi, int options, d_append_string (dpi, "::"); else d_append_char (dpi, '.'); - d_print_comp (dpi, options, d_right (dc)); + { + struct demangle_component *local_name = d_right (dc); + if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) + { + d_append_string (dpi, "{default arg#"); + d_append_num (dpi, local_name->u.s_unary_num.num + 1); + d_append_string (dpi, "}::"); + local_name = local_name->u.s_unary_num.sub; + } + d_print_comp (dpi, options, local_name); + } return; case DEMANGLE_COMPONENT_TYPED_NAME: @@ -3836,7 +4359,9 @@ d_print_comp (struct d_print_info *dpi, int options, if (typed_name->type != DEMANGLE_COMPONENT_RESTRICT_THIS && typed_name->type != DEMANGLE_COMPONENT_VOLATILE_THIS - && typed_name->type != DEMANGLE_COMPONENT_CONST_THIS) + && typed_name->type != DEMANGLE_COMPONENT_CONST_THIS + && typed_name->type != DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS + && typed_name->type != DEMANGLE_COMPONENT_REFERENCE_THIS) break; typed_name = d_left (typed_name); @@ -3870,7 +4395,10 @@ d_print_comp (struct d_print_info *dpi, int options, local_name = local_name->u.s_unary_num.sub; while (local_name->type == DEMANGLE_COMPONENT_RESTRICT_THIS || local_name->type == DEMANGLE_COMPONENT_VOLATILE_THIS - || local_name->type == DEMANGLE_COMPONENT_CONST_THIS) + || local_name->type == DEMANGLE_COMPONENT_CONST_THIS + || local_name->type == DEMANGLE_COMPONENT_REFERENCE_THIS + || (local_name->type + == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS)) { if (i >= sizeof adpm / sizeof adpm[0]) { @@ -3917,6 +4445,12 @@ d_print_comp (struct d_print_info *dpi, int options, { struct d_print_mod *hold_dpm; struct demangle_component *dcl; + const struct demangle_component *hold_current; + + /* This template may need to be referenced by a cast operator + contained in its subtree. */ + hold_current = dpi->current_template; + dpi->current_template = dc; /* Don't push modifiers into a template definition. Doing so could give the wrong definition for a template argument. @@ -3953,6 +4487,7 @@ d_print_comp (struct d_print_info *dpi, int options, } dpi->modifiers = hold_dpm; + dpi->current_template = hold_current; return; } @@ -4052,6 +4587,16 @@ d_print_comp (struct d_print_info *dpi, int options, d_print_comp (dpi, options, d_left (dc)); return; + case DEMANGLE_COMPONENT_TLS_INIT: + d_append_string (dpi, "TLS init function for "); + d_print_comp (dpi, options, d_left (dc)); + return; + + case DEMANGLE_COMPONENT_TLS_WRAPPER: + d_append_string (dpi, "TLS wrapper function for "); + d_print_comp (dpi, options, d_left (dc)); + return; + case DEMANGLE_COMPONENT_REFTEMP: d_append_string (dpi, "reference temporary #"); d_print_comp (dpi, options, d_right (dc)); @@ -4113,12 +4658,37 @@ d_print_comp (struct d_print_info *dpi, int options, const struct demangle_component *sub = d_left (dc); if (sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) { - struct demangle_component *a = d_lookup_template_argument (dpi, sub); + struct d_saved_scope *scope = d_get_saved_scope (dpi, sub); + struct demangle_component *a; + + if (scope == NULL) + { + /* This is the first time SUB has been traversed. + We need to capture the current templates so + they can be restored if SUB is reentered as a + substitution. */ + d_save_scope (dpi, sub); + if (d_print_saw_error (dpi)) + return; + } + else + { + /* This traversal is reentering SUB as a substition. + Restore the original templates temporarily. */ + saved_templates = dpi->templates; + dpi->templates = scope->templates; + need_template_restore = 1; + } + + a = d_lookup_template_argument (dpi, sub); if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) a = d_index_template_argument (a, dpi->pack_index); if (a == NULL) { + if (need_template_restore) + dpi->templates = saved_templates; + d_print_error (dpi); return; } @@ -4137,6 +4707,8 @@ d_print_comp (struct d_print_info *dpi, int options, case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_REFERENCE_THIS: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: case DEMANGLE_COMPONENT_POINTER: case DEMANGLE_COMPONENT_COMPLEX: @@ -4164,6 +4736,9 @@ d_print_comp (struct d_print_info *dpi, int options, dpi->modifiers = dpm.next; + if (need_template_restore) + dpi->templates = saved_templates; + return; } @@ -4454,6 +5029,17 @@ d_print_comp (struct d_print_info *dpi, int options, return; } + if (op_is_new_cast (d_left (dc))) + { + d_print_expr_op (dpi, options, d_left (dc)); + d_append_char (dpi, '<'); + d_print_comp (dpi, options, d_left (d_right (dc))); + d_append_string (dpi, ">("); + d_print_comp (dpi, options, d_right (d_right (dc))); + d_append_char (dpi, ')'); + return; + } + /* We wrap an expression which uses the greater-than operator in an extra layer of parens so that it does not get confused with the '>' which ends the template parameters. */ @@ -4798,7 +5384,10 @@ d_print_mod_list (struct d_print_info *dpi, int options, || (! suffix && (mods->mod->type == DEMANGLE_COMPONENT_RESTRICT_THIS || mods->mod->type == DEMANGLE_COMPONENT_VOLATILE_THIS - || mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS))) + || mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS + || mods->mod->type == DEMANGLE_COMPONENT_REFERENCE_THIS + || (mods->mod->type + == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS)))) { d_print_mod_list (dpi, options, mods->next, suffix); return; @@ -4853,7 +5442,9 @@ d_print_mod_list (struct d_print_info *dpi, int options, while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS || dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS - || dc->type == DEMANGLE_COMPONENT_CONST_THIS) + || dc->type == DEMANGLE_COMPONENT_CONST_THIS + || dc->type == DEMANGLE_COMPONENT_REFERENCE_THIS + || dc->type == DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS) dc = d_left (dc); d_print_comp (dpi, options, dc); @@ -4898,9 +5489,14 @@ d_print_mod (struct d_print_info *dpi, int options, if ((options & DMGL_JAVA) == 0) d_append_char (dpi, '*'); return; + case DEMANGLE_COMPONENT_REFERENCE_THIS: + /* For the ref-qualifier, put a space before the &. */ + d_append_char (dpi, ' '); case DEMANGLE_COMPONENT_REFERENCE: d_append_char (dpi, '&'); return; + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: + d_append_char (dpi, ' '); case DEMANGLE_COMPONENT_RVALUE_REFERENCE: d_append_string (dpi, "&&"); return; @@ -4972,6 +5568,8 @@ d_print_function_type (struct d_print_info *dpi, int options, case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_REFERENCE_THIS: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: break; default: break; @@ -5086,28 +5684,32 @@ static void d_print_cast (struct d_print_info *dpi, int options, const struct demangle_component *dc) { - if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) - d_print_comp (dpi, options, d_left (dc)); - else - { - struct d_print_mod *hold_dpm; - struct d_print_template dpt; - - /* It appears that for a templated cast operator, we need to put - the template parameters in scope for the operator name, but - not for the parameters. The effect is that we need to handle - the template printing here. */ - - hold_dpm = dpi->modifiers; - dpi->modifiers = NULL; + struct d_print_template dpt; + /* For a cast operator, we need the template parameters from + the enclosing template in scope for processing the type. */ + if (dpi->current_template != NULL) + { dpt.next = dpi->templates; dpi->templates = &dpt; - dpt.template_decl = d_left (dc); + dpt.template_decl = dpi->current_template; + } + if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) + { + d_print_comp (dpi, options, d_left (dc)); + if (dpi->current_template != NULL) + dpi->templates = dpt.next; + } + else + { d_print_comp (dpi, options, d_left (d_left (dc))); - dpi->templates = dpt.next; + /* For a templated cast operator, we need to remove the template + parameters from scope after printing the operator name, + so we need to handle the template printing here. */ + if (dpi->current_template != NULL) + dpi->templates = dpt.next; if (d_last_char (dpi) == '<') d_append_char (dpi, ' '); @@ -5118,8 +5720,6 @@ d_print_cast (struct d_print_info *dpi, int options, if (d_last_char (dpi) == '>') d_append_char (dpi, ' '); d_append_char (dpi, '>'); - - dpi->modifiers = hold_dpm; } } @@ -5152,6 +5752,8 @@ cplus_demangle_init_info (const char *mangled, int options, size_t len, di->last_name = NULL; di->expansion = 0; + di->is_expression = 0; + di->is_conversion = 0; } /* Internal implementation for the demangler. If MANGLED is a g++ v3 ABI @@ -5222,6 +5824,8 @@ d_demangle_callback (const char *mangled, int options, NULL); d_advance (&di, strlen (d_str (&di))); break; + default: + abort (); /* We have listed all the cases. */ } /* If DMGL_PARAMS is set, then if we didn't consume the entire @@ -5492,14 +6096,17 @@ is_ctor_or_dtor (const char *mangled, { switch (dc->type) { + /* These cannot appear on a constructor or destructor. */ + case DEMANGLE_COMPONENT_RESTRICT_THIS: + case DEMANGLE_COMPONENT_VOLATILE_THIS: + case DEMANGLE_COMPONENT_CONST_THIS: + case DEMANGLE_COMPONENT_REFERENCE_THIS: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE_THIS: default: dc = NULL; break; case DEMANGLE_COMPONENT_TYPED_NAME: case DEMANGLE_COMPONENT_TEMPLATE: - case DEMANGLE_COMPONENT_RESTRICT_THIS: - case DEMANGLE_COMPONENT_VOLATILE_THIS: - case DEMANGLE_COMPONENT_CONST_THIS: dc = d_left (dc); break; case DEMANGLE_COMPONENT_QUAL_NAME: diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h index ae635beb4c..6fce0252dc 100644 --- a/libiberty/cp-demangle.h +++ b/libiberty/cp-demangle.h @@ -122,6 +122,11 @@ struct d_info mangled name to the demangled name, such as standard substitutions and builtin types. */ int expansion; + /* Non-zero if we are parsing an expression. */ + int is_expression; + /* Non-zero if we are parsing the type operand of a conversion + operator, but not when in an expression. */ + int is_conversion; }; /* To avoid running past the ending '\0', don't: diff --git a/libiberty/dwarfnames.c b/libiberty/dwarfnames.c new file mode 100644 index 0000000000..7017308d98 --- /dev/null +++ b/libiberty/dwarfnames.c @@ -0,0 +1,98 @@ +/* Names of various DWARF tags. + Copyright (C) 2012 Free Software Foundation, Inc. + +This file is part of GNU CC. + +GNU CC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +In addition to the permissions in the GNU General Public License, the +Free Software Foundation gives you unlimited permission to link the +compiled version of this file into combinations with other programs, +and to distribute those combinations without any restriction coming +from the use of this file. (The General Public License restrictions +do apply in other respects; for example, they cover modification of +the file, and distribution when not linked into a combined +executable.) + +GNU CC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 51 Franklin Street - Fifth Floor, +Boston, MA 02110-1301, USA. */ + +#include "dwarf2.h" + +#define DW_FIRST_TAG(name, value) \ + const char *get_DW_TAG_name (unsigned int tag) \ + { switch (tag) { \ + DW_TAG (name, value) +#define DW_END_TAG } return 0; } +#define DW_FIRST_FORM(name, value) \ + const char *get_DW_FORM_name (unsigned int form) \ + { switch (form) { \ + DW_FORM (name, value) +#define DW_END_FORM } return 0; } +#define DW_FIRST_AT(name, value) \ + const char *get_DW_AT_name (unsigned int attr) { \ + switch (attr) { \ + DW_AT (name, value) +#define DW_END_AT } return 0; } +#define DW_FIRST_OP(name, value) \ + const char *get_DW_OP_name (unsigned int op) { \ + switch (op) { \ + DW_OP (name, value) +#define DW_END_OP } return 0; } +#define DW_FIRST_ATE(name, value) \ + const char *get_DW_ATE_name (unsigned int enc) { \ + switch (enc) { \ + DW_ATE (name, value) +#define DW_END_ATE } return 0; } +#define DW_FIRST_CFA(name, value) \ + const char *get_DW_CFA_name (unsigned int opc) { \ + switch (opc) { \ + DW_CFA (name, value) +#define DW_END_CFA } return 0; } + +#define DW_TAG(name, value) case name: return # name ; +#define DW_TAG_DUP(name, value) +#define DW_FORM(name, value) case name: return # name ; +#define DW_AT(name, value) case name: return # name ; +#define DW_AT_DUP(name, value) +#define DW_OP(name, value) case name: return # name ; +#define DW_OP_DUP(name, value) +#define DW_ATE(name, value) case name: return # name ; +#define DW_ATE_DUP(name, value) +#define DW_CFA(name, value) case name: return # name ; + +#include "dwarf2.def" + +#undef DW_FIRST_TAG +#undef DW_END_TAG +#undef DW_FIRST_FORM +#undef DW_END_FORM +#undef DW_FIRST_AT +#undef DW_END_AT +#undef DW_FIRST_OP +#undef DW_END_OP +#undef DW_FIRST_ATE +#undef DW_END_ATE +#undef DW_FIRST_CFA +#undef DW_END_CFA + +#undef DW_TAG +#undef DW_TAG_DUP +#undef DW_FORM +#undef DW_AT +#undef DW_AT_DUP +#undef DW_OP +#undef DW_OP_DUP +#undef DW_ATE +#undef DW_ATE_DUP +#undef DW_CFA diff --git a/libiberty/filename_cmp.c b/libiberty/filename_cmp.c index 5179f8dd14..9e16d24208 100644 --- a/libiberty/filename_cmp.c +++ b/libiberty/filename_cmp.c @@ -141,3 +141,52 @@ filename_ncmp (const char *s1, const char *s2, size_t n) return 0; #endif } + +/* + +@deftypefn Extension hashval_t filename_hash (const void *@var{s}) + +Return the hash value for file name @var{s} that will be compared +using filename_cmp. +This function is for use with hashtab.c hash tables. + +@end deftypefn + +*/ + +hashval_t +filename_hash (const void *s) +{ + /* The cast is for -Wc++-compat. */ + const unsigned char *str = (const unsigned char *) s; + hashval_t r = 0; + unsigned char c; + + while ((c = *str++) != 0) + { + if (c == '\\') + c = '/'; + c = TOLOWER (c); + r = r * 67 + c - 113; + } + + return r; +} + +/* + +@deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2}) + +Return non-zero if file names @var{s1} and @var{s2} are equivalent. +This function is for use with hashtab.c hash tables. + +@end deftypefn + +*/ + +int +filename_eq (const void *s1, const void *s2) +{ + /* The casts are for -Wc++-compat. */ + return filename_cmp ((const char *) s1, (const char *) s2) == 0; +} diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c index 1116c63117..789fa05777 100644 --- a/libiberty/floatformat.c +++ b/libiberty/floatformat.c @@ -1,5 +1,5 @@ /* IEEE floating point support routines, for GDB, the GNU Debugger. - Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006, 2010 + Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006, 2010, 2012 Free Software Foundation, Inc. This file is part of GDB. @@ -371,14 +371,23 @@ floatformat_ibm_long_double_is_valid (const struct floatformat *fmt, } } -const struct floatformat floatformat_ibm_long_double = +const struct floatformat floatformat_ibm_long_double_big = { floatformat_big, 128, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no, - "floatformat_ibm_long_double", + "floatformat_ibm_long_double_big", floatformat_ibm_long_double_is_valid, &floatformat_ieee_double_big }; + +const struct floatformat floatformat_ibm_long_double_little = +{ + floatformat_little, 128, 0, 1, 11, 1023, 2047, 12, 52, + floatformat_intbit_no, + "floatformat_ibm_long_double_little", + floatformat_ibm_long_double_is_valid, + &floatformat_ieee_double_little +}; #ifndef min @@ -463,7 +472,6 @@ floatformat_to_double (const struct floatformat *fmt, unsigned long mant; unsigned int mant_bits, mant_off; int mant_bits_left; - int special_exponent; /* It's a NaN, denorm or zero */ /* Split values are not handled specially, since the top half has the correctly rounded double value (in the only supported case of @@ -503,20 +511,20 @@ floatformat_to_double (const struct floatformat *fmt, mant_off = fmt->man_start; dto = 0.0; - special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan; - - /* Don't bias zero's, denorms or NaNs. */ - if (!special_exponent) - exponent -= fmt->exp_bias; - /* Build the result algebraically. Might go infinite, underflow, etc; who cares. */ - /* If this format uses a hidden bit, explicitly add it in now. Otherwise, - increment the exponent by one to account for the integer bit. */ - - if (!special_exponent) + /* For denorms use minimum exponent. */ + if (exponent == 0) + exponent = 1 - fmt->exp_bias; + else { + exponent -= fmt->exp_bias; + + /* If this format uses a hidden bit, explicitly add it in now. + Otherwise, increment the exponent by one to account for the + integer bit. */ + if (fmt->intbit == floatformat_intbit_no) dto = ldexp (1.0, exponent); else @@ -530,18 +538,8 @@ floatformat_to_double (const struct floatformat *fmt, mant = get_field (ufrom, fmt->byteorder, fmt->totalsize, mant_off, mant_bits); - /* Handle denormalized numbers. FIXME: What should we do for - non-IEEE formats? */ - if (special_exponent && exponent == 0 && mant != 0) - dto += ldexp ((double)mant, - (- fmt->exp_bias - - mant_bits - - (mant_off - fmt->man_start) - + 1)); - else - dto += ldexp ((double)mant, exponent - mant_bits); - if (exponent != 0) - exponent -= mant_bits; + dto += ldexp ((double) mant, exponent - mant_bits); + exponent -= mant_bits; mant_off += mant_bits; mant_bits_left -= mant_bits; } @@ -756,6 +754,7 @@ main (void) { ieee_test (0.0); ieee_test (0.5); + ieee_test (1.1); ieee_test (256.0); ieee_test (0.12345); ieee_test (234235.78907234); diff --git a/libiberty/functions.texi b/libiberty/functions.texi index c9df186be0..9323ff9f2e 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -84,7 +84,7 @@ is respectively less than, matching, or greater than the array member. @end deftypefn -@c argv.c:142 +@c argv.c:135 @deftypefn Extension char** buildargv (char *@var{sp}) Given a pointer to a string, parse the string extracting fields @@ -95,7 +95,7 @@ remains unchanged. The last element of the vector is followed by a @code{NULL} element. All of the memory for the pointer array and copies of the string -is obtained from @code{malloc}. All of the memory can be returned to the +is obtained from @code{xmalloc}. All of the memory can be returned to the system with the single function call @code{freeargv}, which takes the returned result of @code{buildargv}, as it's argument. @@ -166,6 +166,14 @@ pointer encountered. Pointers to empty strings are ignored. @end deftypefn +@c argv.c:470 +@deftypefn Extension int countargv (char **@var{argv}) + +Return the number of elements in @var{argv}. +Returns zero if @var{argv} is NULL. + +@end deftypefn + @c crc32.c:141 @deftypefn Extension {unsigned int} crc32 (const unsigned char *@var{buf}, @ int @var{len}, unsigned int @var{init}) @@ -224,7 +232,7 @@ symbolic name or message. @end deftypefn -@c argv.c:361 +@c argv.c:341 @deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) The @var{argcp} and @code{argvp} arguments are pointers to the usual @@ -296,7 +304,24 @@ and backward slashes are equal. @end deftypefn -@c filename_cmp.c:81 +@c filename_cmp.c:178 +@deftypefn Extension int filename_eq (const void *@var{s1}, const void *@var{s2}) + +Return non-zero if file names @var{s1} and @var{s2} are equivalent. +This function is for use with hashtab.c hash tables. + +@end deftypefn + +@c filename_cmp.c:147 +@deftypefn Extension hashval_t filename_hash (const void *@var{s}) + +Return the hash value for file name @var{s} that will be compared +using filename_cmp. +This function is for use with hashtab.c hash tables. + +@end deftypefn + +@c filename_cmp.c:89 @deftypefn Extension int filename_ncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n}) Return zero if the two file names @var{s1} and @var{s2} are equivalent @@ -376,7 +401,7 @@ unchanged. @end deftypefn -@c argv.c:97 +@c argv.c:90 @deftypefn Extension void freeargv (char **@var{vector}) Free an argument vector that was built using @code{buildargv}. Simply @@ -1465,6 +1490,13 @@ deallocate values. @end deftypefn +@c stack-limit.c:28 +@deftypefn Extension void stack_limit_increase (unsigned long @var{pref}) + +Attempt to increase stack size limit to @var{pref} bytes if possible. + +@end deftypefn + @c stpcpy.c:23 @deftypefn Supplemental char* stpcpy (char *@var{dst}, const char *@var{src}) @@ -1574,6 +1606,16 @@ memory was available. The result is always NUL terminated. @end deftypefn +@c strnlen.c:6 +@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen}) + +Returns the length of @var{s}, as with @code{strlen}, but never looks +past the first @var{maxlen} characters in the string. If there is no +'\0' character in the first @var{maxlen} characters, returns +@var{maxlen}. + +@end deftypefn + @c strrchr.c:6 @deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c}) @@ -1728,6 +1770,22 @@ This function is especially useful when dealing with filename sorting, because filenames frequently hold indices/version numbers. @end deftypefun +@c timeval-utils.c:43 +@deftypefn Extension void timeval_add (struct timeval *@var{a}, @ + struct timeval *@var{b}, struct timeval *@var{result}) + +Adds @var{a} to @var{b} and stores the result in @var{result}. + +@end deftypefn + +@c timeval-utils.c:67 +@deftypefn Extension void timeval_sub (struct timeval *@var{a}, @ + struct timeval *@var{b}, struct timeval *@var{result}) + +Subtracts @var{b} from @var{a} and stores the result in @var{result}. + +@end deftypefn + @c tmpnam.c:3 @deftypefn Supplemental char* tmpnam (char *@var{s}) @@ -1829,7 +1887,7 @@ does the return value. The third argument is unused in @libib{}. @end deftypefn -@c argv.c:306 +@c argv.c:286 @deftypefn Extension int writeargv (const char **@var{argv}, FILE *@var{file}) Write each member of ARGV, handling all necessary quoting, to the file diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index dfaec0f31a..04607ea6a0 100644 --- a/libiberty/hashtab.c +++ b/libiberty/hashtab.c @@ -194,14 +194,6 @@ higher_prime_index (unsigned long n) return low; } -/* Returns a hash code for P. */ - -static hashval_t -hash_pointer (const PTR p) -{ - return (hashval_t) ((intptr_t)p >> 3); -} - /* Returns non-zero if P1 and P2 are equal. */ static int @@ -988,3 +980,19 @@ iterative_hash (const PTR k_in /* the key */, /*-------------------------------------------- report the result */ return c; } + +/* Returns a hash code for pointer P. Simplified version of evahash */ + +static hashval_t +hash_pointer (const PTR p) +{ + intptr_t v = (intptr_t) p; + unsigned a, b, c; + + a = b = 0x9e3779b9; + a += v >> (sizeof (intptr_t) * CHAR_BIT / 2); + b += v & (((intptr_t) 1 << (sizeof (intptr_t) * CHAR_BIT / 2)) - 1); + c = 0x42135234; + mix (a, b, c); + return c; +} diff --git a/libiberty/libiberty.texi b/libiberty/libiberty.texi index 74f70d2bd5..f4af66d40b 100644 --- a/libiberty/libiberty.texi +++ b/libiberty/libiberty.texi @@ -82,8 +82,6 @@ License; for more information, see @ref{Library Copying}. * Functions:: Available functions, macros, and global variables. -* Obstacks:: Object Stacks. - * Licenses:: The various licenses under which libiberty sources are distributed. @@ -243,8 +241,7 @@ central location from which to use, maintain, and distribute them. * Obstacks:: Stacks of arbitrary objects. @end menu -@c This is generated from the glibc manual using a make-obstacks-texi.sh -@c script of Phil's. Hope it's accurate. +@c This is generated from the glibc manual using contrib/make-obstacks-texi.pl @include obstacks.texi @node Functions diff --git a/libiberty/maint-tool b/libiberty/maint-tool index 36b92034f3..d50f8959a3 100644 --- a/libiberty/maint-tool +++ b/libiberty/maint-tool @@ -222,7 +222,7 @@ sub deps { opendir(INC, $incdir); while ($f = readdir INC) { - next unless $f =~ /\.h$/; + next unless $f =~ /\.h$/ || $f =~ /\.def$/; $mine{$f} = "\$(INCDIR)/$f"; $deps{$f} = join(' ', &deps_for("$incdir/$f")); } diff --git a/libiberty/makefile.vms b/libiberty/makefile.vms index 606adac096..15a7d0a206 100644 --- a/libiberty/makefile.vms +++ b/libiberty/makefile.vms @@ -13,7 +13,8 @@ OBJS=getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\ concat.obj,getruntime.obj,getpagesize.obj,getpwd.obj,xstrerror.obj,\ xmemdup.obj,xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,\ objalloc.obj,safe-ctype.obj,hashtab.obj,lbasename.obj,argv.obj,\ - lrealpath.obj,make-temp-file.obj,stpcpy.obj,unlink-if-ordinary.obj + lrealpath.obj,make-temp-file.obj,stpcpy.obj,unlink-if-ordinary.obj,\ + dwarfnames.obj ifeq ($(CC),gcc) CFLAGS=/include=([],[-.include]) diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c index 3ddac2ce4c..72e92d2ddc 100644 --- a/libiberty/objalloc.c +++ b/libiberty/objalloc.c @@ -1,5 +1,5 @@ /* objalloc.c -- routines to allocate memory for objects - Copyright 1997 Free Software Foundation, Inc. + Copyright 1997-2012 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Solutions. This program is free software; you can redistribute it and/or modify it @@ -112,8 +112,10 @@ objalloc_create (void) /* Allocate space from an objalloc structure. */ PTR -_objalloc_alloc (struct objalloc *o, unsigned long len) +_objalloc_alloc (struct objalloc *o, unsigned long original_len) { + unsigned long len = original_len; + /* We avoid confusion from zero sized objects by always allocating at least 1 byte. */ if (len == 0) @@ -121,6 +123,11 @@ _objalloc_alloc (struct objalloc *o, unsigned long len) len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); + /* Check for overflow in the alignment operation above and the + malloc argument below. */ + if (len + CHUNK_HEADER_SIZE < original_len) + return NULL; + if (len <= o->current_space) { o->current_ptr += len; diff --git a/libiberty/obstacks.texi b/libiberty/obstacks.texi index a1b1b478c3..adcd8103da 100644 --- a/libiberty/obstacks.texi +++ b/libiberty/obstacks.texi @@ -1,5 +1,5 @@ -@node Obstacks,Licenses,Functions,Top -@chapter Obstacks +@node Obstacks +@subsection Obstacks @cindex obstacks An @dfn{obstack} is a pool of memory containing a stack of objects. You @@ -15,25 +15,25 @@ the objects are usually small. And the only space overhead per object is the padding needed to start each object on a suitable boundary. @menu -* Creating Obstacks:: How to declare an obstack in your program. -* Preparing for Obstacks:: Preparations needed before you can - use obstacks. +* Creating Obstacks:: How to declare an obstack in your program. +* Preparing for Obstacks:: Preparations needed before you can + use obstacks. * Allocation in an Obstack:: Allocating objects in an obstack. * Freeing Obstack Objects:: Freeing objects in an obstack. -* Obstack Functions:: The obstack functions are both - functions and macros. +* Obstack Functions:: The obstack functions are both + functions and macros. * Growing Objects:: Making an object bigger by stages. -* Extra Fast Growing:: Extra-high-efficiency (though more - complicated) growing objects. +* Extra Fast Growing:: Extra-high-efficiency (though more + complicated) growing objects. * Status of an Obstack:: Inquiries about the status of an obstack. * Obstacks Data Alignment:: Controlling alignment of objects in obstacks. * Obstack Chunks:: How obstacks obtain and release chunks; - efficiency considerations. + efficiency considerations. * Summary of Obstacks:: @end menu @node Creating Obstacks -@section Creating Obstacks +@subsubsection Creating Obstacks The utilities for manipulating obstacks are declared in the header file @file{obstack.h}. @@ -74,7 +74,7 @@ directly or indirectly. You must also supply a function to free a chunk. These matters are described in the following section. @node Preparing for Obstacks -@section Preparing for Using Obstacks +@subsubsection Preparing for Using Obstacks Each source file in which you plan to use the obstack functions must include the header file @file{obstack.h}, like this: @@ -160,7 +160,7 @@ obstack_alloc_failed_handler = &my_obstack_alloc_failed; @end defvar @node Allocation in an Obstack -@section Allocation in an Obstack +@subsubsection Allocation in an Obstack @cindex allocation (obstacks) The most direct way to allocate an object in an obstack is with @@ -233,7 +233,7 @@ Contrast this with the previous example of @code{savestring} using @code{malloc} (@pxref{Basic Allocation, , , libc, The GNU C Library Reference Manual}). @node Freeing Obstack Objects -@section Freeing Objects in an Obstack +@subsubsection Freeing Objects in an Obstack @cindex freeing (obstacks) To free an object allocated in an obstack, use the function @@ -265,7 +265,7 @@ frees the chunk (@pxref{Preparing for Obstacks}). Then other obstacks, or non-obstack allocation, can reuse the space of the chunk. @node Obstack Functions -@section Obstack Functions and Macros +@subsubsection Obstack Functions and Macros @cindex macros The interfaces for using obstacks may be defined either as functions or @@ -321,7 +321,7 @@ various language extensions in GNU C permit defining the macros so as to compute each argument only once. @node Growing Objects -@section Growing Objects +@subsubsection Growing Objects @cindex growing objects (in obstacks) @cindex changing the size of a block (obstacks) @@ -435,7 +435,7 @@ the current object smaller. Just don't try to shrink it beyond zero length---there's no telling what will happen if you do that. @node Extra Fast Growing -@section Extra Fast Growing Objects +@subsubsection Extra Fast Growing Objects @cindex efficiency and obstacks The usual functions for growing objects incur overhead for checking @@ -538,7 +538,7 @@ add_string (struct obstack *obstack, const char *ptr, int len) @end smallexample @node Status of an Obstack -@section Status of an Obstack +@subsubsection Status of an Obstack @cindex obstack status @cindex status of obstack @@ -580,12 +580,13 @@ obstack_next_free (@var{obstack-ptr}) - obstack_base (@var{obstack-ptr}) @end deftypefun @node Obstacks Data Alignment -@section Alignment of Data in Obstacks +@subsubsection Alignment of Data in Obstacks @cindex alignment (in obstacks) Each obstack has an @dfn{alignment boundary}; each object allocated in the obstack automatically starts on an address that is a multiple of the -specified boundary. By default, this boundary is 4 bytes. +specified boundary. By default, this boundary is aligned so that +the object can hold any type of data. To access an obstack's alignment boundary, use the macro @code{obstack_alignment_mask}, whose function prototype looks like @@ -597,7 +598,9 @@ this: The value is a bit mask; a bit that is 1 indicates that the corresponding bit in the address of an object should be 0. The mask value should be one less than a power of 2; the effect is that all object addresses are -multiples of that power of 2. The default value of the mask is 3, so that +multiples of that power of 2. The default value of the mask is a value +that allows aligned objects to hold any type of data: for example, if +its value is 3, any type of data can be stored at locations whose addresses are multiples of 4. A mask value of 0 means an object can start on any multiple of 1 (that is, no alignment is required). @@ -620,7 +623,7 @@ This will finish a zero-length object and then do proper alignment for the next object. @node Obstack Chunks -@section Obstack Chunks +@subsubsection Obstack Chunks @cindex efficiency of chunks @cindex chunks @@ -676,7 +679,7 @@ if (obstack_chunk_size (obstack_ptr) < @var{new-chunk-size}) @end smallexample @node Summary of Obstacks -@section Summary of Obstack Functions +@subsubsection Summary of Obstack Functions Here is a summary of all the functions associated with obstacks. Each takes the address of an obstack (@code{struct obstack *}) as its first diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c index 8d5145c523..addf8ee23d 100644 --- a/libiberty/pex-unix.c +++ b/libiberty/pex-unix.c @@ -85,13 +85,15 @@ to_ptr32 (char **ptr64) int argc; __char_ptr_char_ptr32 short_argv; - for (argc=0; ptr64[argc]; argc++); + /* Count number of arguments. */ + for (argc = 0; ptr64[argc] != NULL; argc++) + ; /* Reallocate argv with 32 bit pointers. */ short_argv = (__char_ptr_char_ptr32) decc$malloc (sizeof (__char_ptr32) * (argc + 1)); - for (argc=0; ptr64[argc]; argc++) + for (argc = 0; ptr64[argc] != NULL; argc++) short_argv[argc] = (__char_ptr32) decc$strdup (ptr64[argc]); short_argv[argc] = (__char_ptr32) 0; diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c index 107ac6fdcc..eae72c51dc 100644 --- a/libiberty/pex-win32.c +++ b/libiberty/pex-win32.c @@ -741,24 +741,17 @@ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags, int orig_out, orig_in, orig_err; BOOL separate_stderr = !(flags & PEX_STDERR_TO_STDOUT); - /* Ensure we have inheritable descriptors to pass to the child, and close the - original descriptors. */ + /* Ensure we have inheritable descriptors to pass to the child. */ orig_in = in; in = _dup (orig_in); - if (orig_in != STDIN_FILENO) - _close (orig_in); orig_out = out; out = _dup (orig_out); - if (orig_out != STDOUT_FILENO) - _close (orig_out); if (separate_stderr) { orig_err = errdes; errdes = _dup (orig_err); - if (orig_err != STDERR_FILENO) - _close (orig_err); } stdin_handle = INVALID_HANDLE_VALUE; @@ -836,6 +829,22 @@ pex_win32_exec_child (struct pex_obj *obj ATTRIBUTE_UNUSED, int flags, *errmsg = "CreateProcess"; } + /* If the child was created successfully, close the original file + descriptors. If the process creation fails, these are closed by + pex_run_in_environment instead. We must not close them twice as + that seems to cause a Windows exception. */ + + if (pid != (pid_t) -1) + { + if (orig_in != STDIN_FILENO) + _close (orig_in); + if (orig_out != STDOUT_FILENO) + _close (orig_out); + if (separate_stderr + && orig_err != STDERR_FILENO) + _close (orig_err); + } + /* Close the standard input, standard output and standard error handles in the parent. */ diff --git a/libiberty/regex.c b/libiberty/regex.c index e5ad222bac..16338cb206 100644 --- a/libiberty/regex.c +++ b/libiberty/regex.c @@ -4,7 +4,7 @@ internationalization features.) Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2005, 2010 Free Software Foundation, Inc. + 2002, 2005, 2010, 2013 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -151,7 +151,7 @@ char *realloc (); # include <string.h> # ifndef bzero # ifndef _LIBC -# define bzero(s, n) (memset (s, '\0', n), (s)) +# define bzero(s, n) ((void) memset (s, '\0', n)) # else # define bzero(s, n) __bzero (s, n) # endif @@ -3396,7 +3396,7 @@ PREFIX(regex_compile) (const char *ARG_PREFIX(pattern), class. */ PATFETCH (c); - /* Now we have to go throught the whole table + /* Now we have to go through the whole table and find all characters which have the same first level weight. @@ -8093,12 +8093,12 @@ regerror (int errcode, const regex_t *preg ATTRIBUTE_UNUSED, #if defined HAVE_MEMPCPY || defined _LIBC *((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; #else - memcpy (errbuf, msg, errbuf_size - 1); + (void) memcpy (errbuf, msg, errbuf_size - 1); errbuf[errbuf_size - 1] = 0; #endif } else - memcpy (errbuf, msg, msg_size); + (void) memcpy (errbuf, msg, msg_size); } return msg_size; diff --git a/libiberty/simple-object-common.h b/libiberty/simple-object-common.h index 264b179955..bef9b08cef 100644 --- a/libiberty/simple-object-common.h +++ b/libiberty/simple-object-common.h @@ -148,6 +148,7 @@ struct simple_object_functions extern const struct simple_object_functions simple_object_coff_functions; extern const struct simple_object_functions simple_object_elf_functions; extern const struct simple_object_functions simple_object_mach_o_functions; +extern const struct simple_object_functions simple_object_xcoff_functions; /* Read SIZE bytes from DESCRIPTOR at file offset OFFSET into BUFFER. Return non-zero on success. On failure return 0 and set *ERRMSG diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c index af5e4f9ca8..d1b676d777 100644 --- a/libiberty/simple-object-mach-o.c +++ b/libiberty/simple-object-mach-o.c @@ -1,5 +1,5 @@ /* simple-object-mach-o.c -- routines to manipulate Mach-O object files. - Copyright 2010, 2011 Free Software Foundation, Inc. + Copyright 2010, 2011, 2013 Free Software Foundation, Inc. Written by Ian Lance Taylor, Google. This program is free software; you can redistribute it and/or modify it @@ -432,7 +432,7 @@ simple_object_mach_o_segment (simple_object_read *sobj, off_t offset, size_t index_size; unsigned int n_wrapped_sects; size_t wrapper_sect_size; - off_t wrapper_sect_offset; + off_t wrapper_sect_offset = 0; fetch_32 = (omr->is_big_endian ? simple_object_fetch_big_32 @@ -701,12 +701,13 @@ simple_object_mach_o_segment (simple_object_read *sobj, off_t offset, /* Otherwise, make a name like __segment,__section as per the convention in mach-o asm. */ name = &namebuf[0]; - memset (namebuf, 0, MACH_O_NAME_LEN * 2 + 2); memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN); + namebuf[MACH_O_NAME_LEN] = '\0'; l = strlen (namebuf); namebuf[l] = ','; memcpy (namebuf + l + 1, (char *) sechdr + sectname_offset, MACH_O_NAME_LEN); + namebuf[l + 1 + MACH_O_NAME_LEN] = '\0'; } simple_object_mach_o_section_info (omr->is_big_endian, is_32, sechdr, diff --git a/libiberty/simple-object-xcoff.c b/libiberty/simple-object-xcoff.c new file mode 100644 index 0000000000..ff1dc18079 --- /dev/null +++ b/libiberty/simple-object-xcoff.c @@ -0,0 +1,898 @@ +/* simple-object-coff.c -- routines to manipulate XCOFF object files. + Copyright 2013 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Google and David Edelsohn, IBM. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 51 Franklin Street - Fifth Floor, +Boston, MA 02110-1301, USA. */ + +#include "config.h" +#include "libiberty.h" +#include "simple-object.h" + +#include <errno.h> +#include <stddef.h> + +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif + +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#include "simple-object-common.h" + +/* XCOFF structures and constants. */ + +/* XCOFF file header. */ + +struct external_filehdr +{ + unsigned char f_magic[2]; /* magic number */ + unsigned char f_nscns[2]; /* number of sections */ + unsigned char f_timdat[4]; /* time & date stamp */ + union + { + struct + { + unsigned char f_symptr[4]; /* file pointer to symtab */ + unsigned char f_nsyms[4]; /* number of symtab entries */ + unsigned char f_opthdr[2]; /* sizeof(optional hdr) */ + unsigned char f_flags[2]; /* flags */ + } xcoff32; + struct + { + unsigned char f_symptr[8]; /* file pointer to symtab */ + unsigned char f_opthdr[2]; /* sizeof(optional hdr) */ + unsigned char f_flags[2]; /* flags */ + unsigned char f_nsyms[4]; /* number of symtab entries */ + } xcoff64; + } u; +}; + +/* Bits for filehdr f_flags field. */ + +#define F_EXEC (0x0002) + +/* The known values of f_magic in an XCOFF file header. */ + +#define U802WRMAGIC 0730 /* Writeable text segments. */ +#define U802ROMAGIC 0735 /* Readonly sharable text segments. */ +#define U802TOCMAGIC 0737 /* Readonly text segments and TOC. */ +#define U803XTOCMAGIC 0757 /* Aix 4.3 64-bit XCOFF. */ +#define U64_TOCMAGIC 0767 /* AIX 5+ 64-bit XCOFF. */ + +/* XCOFF section header. */ + +struct external_scnhdr +{ + unsigned char s_name[8]; /* section name */ + union + { + struct + { + unsigned char s_paddr[4]; /* physical address, aliased s_nlib */ + unsigned char s_vaddr[4]; /* virtual address */ + unsigned char s_size[4]; /* section size */ + unsigned char s_scnptr[4]; /* file ptr to raw data for section */ + unsigned char s_relptr[4]; /* file ptr to relocation */ + unsigned char s_lnnoptr[4]; /* file ptr to line numbers */ + unsigned char s_nreloc[2]; /* number of relocation entries */ + unsigned char s_nlnno[2]; /* number of line number entries */ + unsigned char s_flags[4]; /* flags */ + } xcoff32; + struct + { + unsigned char s_paddr[8]; /* physical address, aliased s_nlib */ + unsigned char s_vaddr[8]; /* virtual address */ + unsigned char s_size[8]; /* section size */ + unsigned char s_scnptr[8]; /* file ptr to raw data for section */ + unsigned char s_relptr[8]; /* file ptr to relocation */ + unsigned char s_lnnoptr[8]; /* file ptr to line numbers */ + unsigned char s_nreloc[4]; /* number of relocation entries */ + unsigned char s_nlnno[4]; /* number of line number entries */ + unsigned char s_flags[4]; /* flags */ + } xcoff64; + } u; +}; + +#define SCNHSZ32 (40) +#define SCNHSZ64 (68) + +/* The length of the s_name field in struct external_scnhdr. */ + +#define SCNNMLEN (8) + +/* Bits for scnhdr s_flags field. */ + +#define STYP_DATA 0x40 + +/* XCOFF symbol table entry. */ + + +#define N_SYMNMLEN (8) /* # characters in a symbol name */ + +/* The format of an XCOFF symbol-table entry. */ +struct external_syment +{ + union { + struct { + union { + /* The name of the symbol. There is an implicit null character + after the end of the array. */ + char n_name[N_SYMNMLEN]; + struct { + /* If n_zeroes is zero, n_offset is the offset the name from + the start of the string table. */ + unsigned char n_zeroes[4]; + unsigned char n_offset[4]; + } n; + } n; + + /* The symbol's value. */ + unsigned char n_value[4]; + } xcoff32; + struct { + /* The symbol's value. */ + unsigned char n_value[8]; + + /* The offset of the symbol from the start of the string table. */ + unsigned char n_offset[4]; + } xcoff64; + } u; + + /* The number of the section to which this symbol belongs. */ + unsigned char n_scnum[2]; + + /* The type of symbol. (It can be interpreted as an n_lang + and an n_cpu byte, but we don't care about that here.) */ + unsigned char n_type[2]; + + /* The class of symbol (a C_* value). */ + unsigned char n_sclass[1]; + + /* The number of auxiliary symbols attached to this entry. */ + unsigned char n_numaux[1]; +}; + +#define SYMESZ (18) + +/* Length allowed for filename in aux sym format 4. */ + +#define FILNMLEN (14) + +/* Omits x_sym and other unused variants. */ + +union external_auxent +{ + /* Aux sym format 4: file. */ + union + { + char x_fname[FILNMLEN]; + struct + { + unsigned char x_zeroes[4]; + unsigned char x_offset[4]; + unsigned char x_pad[FILNMLEN-8]; + unsigned char x_ftype; + } _x; + } x_file; + /* Aux sym format 5: section. */ + struct + { + unsigned char x_scnlen[4]; /* section length */ + unsigned char x_nreloc[2]; /* # relocation entries */ + unsigned char x_nlinno[2]; /* # line numbers */ + } x_scn; + /* CSECT auxiliary entry. */ + union + { + struct + { + struct + { + unsigned char x_scnlen[4]; /* csect length */ + unsigned char x_parmhash[4]; /* parm type hash index */ + unsigned char x_snhash[2]; /* sect num with parm hash */ + unsigned char x_smtyp; /* symbol align and type */ + unsigned char x_smclas; /* storage mapping class */ + unsigned char x_stab; /* dbx stab info index */ + unsigned char x_snstab[2]; /* sect num with dbx stab */ + } x_csect; + } xcoff32; + struct + { + struct + { + unsigned char x_scnlen_lo[4]; /* csect length */ + unsigned char x_parmhash[4]; /* parm type hash index */ + unsigned char x_snhash[2]; /* sect num with parm hash */ + unsigned char x_smtyp; /* symbol align and type */ + unsigned char x_smclas; /* storage mapping class */ + unsigned char x_scnlen_hi[4]; + unsigned char pad; + unsigned char x_auxtype; + } x_csect; + } xcoff64; + } u; + /* SECTION/DWARF auxiliary entry. */ + struct + { + unsigned char x_scnlen[4]; /* section length */ + unsigned char pad1[4]; + unsigned char x_nreloc[4]; /* number RLDs */ + } x_sect; +}; + +/* Symbol-related constants. */ + +#define N_DEBUG (-2) +#define IMAGE_SYM_TYPE_NULL (0) +#define IMAGE_SYM_DTYPE_NULL (0) +#define IMAGE_SYM_CLASS_STATIC (3) +#define IMAGE_SYM_CLASS_FILE (103) + +#define IMAGE_SYM_TYPE \ + ((IMAGE_SYM_DTYPE_NULL << 4) | IMAGE_SYM_TYPE_NULL) + +#define C_STAT (3) +#define C_FILE (103) + +/* Private data for an simple_object_read. */ + +struct simple_object_xcoff_read +{ + /* Magic number. */ + unsigned short magic; + /* Number of sections. */ + unsigned short nscns; + /* File offset of symbol table. */ + off_t symptr; + /* Number of symbol table entries. */ + unsigned int nsyms; + /* Flags. */ + unsigned short flags; + /* Offset of section headers in file. */ + off_t scnhdr_offset; +}; + +/* Private data for an simple_object_attributes. */ + +struct simple_object_xcoff_attributes +{ + /* Magic number. */ + unsigned short magic; + /* Flags. */ + unsigned short flags; +}; + +/* See if we have a XCOFF file. */ + +static void * +simple_object_xcoff_match (unsigned char header[SIMPLE_OBJECT_MATCH_HEADER_LEN], + int descriptor, off_t offset, + const char *segment_name ATTRIBUTE_UNUSED, + const char **errmsg, int *err) +{ + unsigned short magic; + unsigned short (*fetch_16) (const unsigned char *); + unsigned int (*fetch_32) (const unsigned char *); + ulong_type (*fetch_64) (const unsigned char *); + unsigned char hdrbuf[sizeof (struct external_filehdr)]; + struct simple_object_xcoff_read *ocr; + int u64; + + magic = simple_object_fetch_big_16 (header); + + if (magic != U802TOCMAGIC && magic != U64_TOCMAGIC) + { + *errmsg = NULL; + *err = 0; + return NULL; + } + + fetch_16 = simple_object_fetch_big_16; + fetch_32 = simple_object_fetch_big_32; + fetch_64 = simple_object_fetch_big_64; + + if (!simple_object_internal_read (descriptor, offset, hdrbuf, sizeof hdrbuf, + errmsg, err)) + return NULL; + + u64 = magic == U64_TOCMAGIC; + + ocr = XNEW (struct simple_object_xcoff_read); + ocr->magic = magic; + ocr->nscns = fetch_16 (hdrbuf + offsetof (struct external_filehdr, f_nscns)); + if (u64) + { + ocr->symptr = fetch_64 (hdrbuf + + offsetof (struct external_filehdr, + u.xcoff64.f_symptr)); + ocr->nsyms = fetch_32 (hdrbuf + offsetof (struct external_filehdr, + u.xcoff64.f_nsyms)); + ocr->scnhdr_offset = (sizeof (struct external_filehdr) + + fetch_16 (hdrbuf + offsetof (struct external_filehdr, + u.xcoff64.f_opthdr))); + + } + else + { + ocr->symptr = fetch_32 (hdrbuf + + offsetof (struct external_filehdr, + u.xcoff32.f_symptr)); + ocr->nsyms = fetch_32 (hdrbuf + offsetof (struct external_filehdr, + u.xcoff32.f_nsyms)); + ocr->scnhdr_offset = (sizeof (struct external_filehdr) - 4 + + fetch_16 (hdrbuf + offsetof (struct external_filehdr, + u.xcoff32.f_opthdr))); + + } + + return (void *) ocr; +} + +/* Read the string table in a XCOFF file. */ + +static char * +simple_object_xcoff_read_strtab (simple_object_read *sobj, size_t *strtab_size, + const char **errmsg, int *err) +{ + struct simple_object_xcoff_read *ocr = + (struct simple_object_xcoff_read *) sobj->data; + off_t strtab_offset; + unsigned char strsizebuf[4]; + size_t strsize; + char *strtab; + + strtab_offset = sobj->offset + ocr->symptr + + ocr->nsyms * SYMESZ; + if (!simple_object_internal_read (sobj->descriptor, strtab_offset, + strsizebuf, 4, errmsg, err)) + return NULL; + strsize = simple_object_fetch_big_32 (strsizebuf); + strtab = XNEWVEC (char, strsize); + if (!simple_object_internal_read (sobj->descriptor, strtab_offset, + (unsigned char *) strtab, strsize, errmsg, + err)) + { + XDELETEVEC (strtab); + return NULL; + } + *strtab_size = strsize; + return strtab; +} + +/* Find all sections in a XCOFF file. */ + +static const char * +simple_object_xcoff_find_sections (simple_object_read *sobj, + int (*pfn) (void *, const char *, + off_t offset, off_t length), + void *data, + int *err) +{ + struct simple_object_xcoff_read *ocr = + (struct simple_object_xcoff_read *) sobj->data; + int u64 = ocr->magic == U64_TOCMAGIC; + size_t scnhdr_size; + unsigned char *scnbuf; + const char *errmsg; + unsigned int (*fetch_32) (const unsigned char *); + ulong_type (*fetch_64) (const unsigned char *); + unsigned int nscns; + char *strtab; + size_t strtab_size; + unsigned int i; + + scnhdr_size = u64 ? SCNHSZ64 : SCNHSZ32; + scnbuf = XNEWVEC (unsigned char, scnhdr_size * ocr->nscns); + if (!simple_object_internal_read (sobj->descriptor, + sobj->offset + ocr->scnhdr_offset, + scnbuf, scnhdr_size * ocr->nscns, &errmsg, + err)) + { + XDELETEVEC (scnbuf); + return errmsg; + } + + fetch_32 = simple_object_fetch_big_32; + fetch_64 = simple_object_fetch_big_64; + + nscns = ocr->nscns; + strtab = NULL; + strtab_size = 0; + for (i = 0; i < nscns; ++i) + { + unsigned char *scnhdr; + unsigned char *scnname; + char namebuf[SCNNMLEN + 1]; + char *name; + off_t scnptr; + unsigned int size; + + scnhdr = scnbuf + i * scnhdr_size; + scnname = scnhdr + offsetof (struct external_scnhdr, s_name); + memcpy (namebuf, scnname, SCNNMLEN); + namebuf[SCNNMLEN] = '\0'; + name = &namebuf[0]; + if (namebuf[0] == '/') + { + size_t strindex; + char *end; + + strindex = strtol (namebuf + 1, &end, 10); + if (*end == '\0') + { + /* The real section name is found in the string + table. */ + if (strtab == NULL) + { + strtab = simple_object_xcoff_read_strtab (sobj, + &strtab_size, + &errmsg, err); + if (strtab == NULL) + { + XDELETEVEC (scnbuf); + return errmsg; + } + } + + if (strindex < 4 || strindex >= strtab_size) + { + XDELETEVEC (strtab); + XDELETEVEC (scnbuf); + *err = 0; + return "section string index out of range"; + } + + name = strtab + strindex; + } + } + + if (u64) + { + scnptr = fetch_64 (scnhdr + offsetof (struct external_scnhdr, + u.xcoff64.s_scnptr)); + size = fetch_64 (scnhdr + offsetof (struct external_scnhdr, + u.xcoff64.s_size)); + } + else + { + scnptr = fetch_32 (scnhdr + offsetof (struct external_scnhdr, + u.xcoff32.s_scnptr)); + size = fetch_32 (scnhdr + offsetof (struct external_scnhdr, + u.xcoff32.s_size)); + } + + if (!(*pfn) (data, name, scnptr, size)) + break; + } + + if (strtab != NULL) + XDELETEVEC (strtab); + XDELETEVEC (scnbuf); + + return NULL; +} + +/* Fetch the attributes for an simple_object_read. */ + +static void * +simple_object_xcoff_fetch_attributes (simple_object_read *sobj, + const char **errmsg ATTRIBUTE_UNUSED, + int *err ATTRIBUTE_UNUSED) +{ + struct simple_object_xcoff_read *ocr = + (struct simple_object_xcoff_read *) sobj->data; + struct simple_object_xcoff_attributes *ret; + + ret = XNEW (struct simple_object_xcoff_attributes); + ret->magic = ocr->magic; + ret->flags = ocr->flags; + return ret; +} + +/* Release the private data for an simple_object_read. */ + +static void +simple_object_xcoff_release_read (void *data) +{ + XDELETE (data); +} + +/* Compare two attributes structures. */ + +static const char * +simple_object_xcoff_attributes_merge (void *todata, void *fromdata, int *err) +{ + struct simple_object_xcoff_attributes *to = + (struct simple_object_xcoff_attributes *) todata; + struct simple_object_xcoff_attributes *from = + (struct simple_object_xcoff_attributes *) fromdata; + + if (to->magic != from->magic) + { + *err = 0; + return "XCOFF object format mismatch"; + } + return NULL; +} + +/* Release the private data for an attributes structure. */ + +static void +simple_object_xcoff_release_attributes (void *data) +{ + XDELETE (data); +} + +/* Prepare to write out a file. */ + +static void * +simple_object_xcoff_start_write (void *attributes_data, + const char **errmsg ATTRIBUTE_UNUSED, + int *err ATTRIBUTE_UNUSED) +{ + struct simple_object_xcoff_attributes *attrs = + (struct simple_object_xcoff_attributes *) attributes_data; + struct simple_object_xcoff_attributes *ret; + + /* We're just going to record the attributes, but we need to make a + copy because the user may delete them. */ + ret = XNEW (struct simple_object_xcoff_attributes); + *ret = *attrs; + return ret; +} + +/* Write out a XCOFF filehdr. */ + +static int +simple_object_xcoff_write_filehdr (simple_object_write *sobj, int descriptor, + unsigned int nscns, size_t symtab_offset, + unsigned int nsyms, const char **errmsg, + int *err) +{ + struct simple_object_xcoff_attributes *attrs = + (struct simple_object_xcoff_attributes *) sobj->data; + int u64 = attrs->magic == U64_TOCMAGIC; + unsigned char hdrbuf[sizeof (struct external_filehdr)]; + unsigned char *hdr; + void (*set_16) (unsigned char *, unsigned short); + void (*set_32) (unsigned char *, unsigned int); + void (*set_64) (unsigned char *, ulong_type); + + hdr = &hdrbuf[0]; + + set_16 = simple_object_set_big_16; + set_32 = simple_object_set_big_32; + set_64 = simple_object_set_big_64; + + memset (hdr, 0, sizeof (struct external_filehdr)); + + set_16 (hdr + offsetof (struct external_filehdr, f_magic), attrs->magic); + set_16 (hdr + offsetof (struct external_filehdr, f_nscns), nscns); + /* f_timdat left as zero. */ + if (u64) + { + set_64 (hdr + offsetof (struct external_filehdr, u.xcoff64.f_symptr), + symtab_offset); + set_32 (hdr + offsetof (struct external_filehdr, u.xcoff64.f_nsyms), + nsyms); + /* f_opthdr left as zero. */ + set_16 (hdr + offsetof (struct external_filehdr, u.xcoff64.f_flags), + attrs->flags); + } + else + { + set_32 (hdr + offsetof (struct external_filehdr, u.xcoff64.f_symptr), + symtab_offset); + set_32 (hdr + offsetof (struct external_filehdr, u.xcoff64.f_nsyms), + nsyms); + /* f_opthdr left as zero. */ + set_16 (hdr + offsetof (struct external_filehdr, u.xcoff64.f_flags), + attrs->flags); + } + + return simple_object_internal_write (descriptor, 0, hdrbuf, + sizeof (struct external_filehdr), + errmsg, err); +} + +/* Write out a XCOFF section header. */ + +static int +simple_object_xcoff_write_scnhdr (simple_object_write *sobj, + int descriptor, + const char *name, size_t *name_offset, + off_t scnhdr_offset, size_t scnsize, + off_t offset, unsigned int align, + const char **errmsg, int *err) +{ + struct simple_object_xcoff_read *ocr = + (struct simple_object_xcoff_read *) sobj->data; + int u64 = ocr->magic == U64_TOCMAGIC; + void (*set_32) (unsigned char *, unsigned int); + void (*set_64) (unsigned char *, unsigned int); + unsigned char hdrbuf[sizeof (struct external_scnhdr)]; + unsigned char *hdr; + size_t namelen; + unsigned int flags; + + set_32 = simple_object_set_big_32; + set_64 = simple_object_set_big_32; + + memset (hdrbuf, 0, sizeof hdrbuf); + hdr = &hdrbuf[0]; + + namelen = strlen (name); + if (namelen <= SCNNMLEN) + strncpy ((char *) hdr + offsetof (struct external_scnhdr, s_name), + name, SCNNMLEN); + else + { + snprintf ((char *) hdr + offsetof (struct external_scnhdr, s_name), + SCNNMLEN, "/%lu", (unsigned long) *name_offset); + *name_offset += namelen + 1; + } + + /* s_paddr left as zero. */ + /* s_vaddr left as zero. */ + if (u64) + { + set_64 (hdr + offsetof (struct external_scnhdr, u.xcoff64.s_size), + scnsize); + set_64 (hdr + offsetof (struct external_scnhdr, u.xcoff64.s_scnptr), + offset); + } + else + { + set_32 (hdr + offsetof (struct external_scnhdr, u.xcoff32.s_size), + scnsize); + set_32 (hdr + offsetof (struct external_scnhdr, u.xcoff32.s_scnptr), + offset); + } + /* s_relptr left as zero. */ + /* s_lnnoptr left as zero. */ + /* s_nreloc left as zero. */ + /* s_nlnno left as zero. */ + flags = STYP_DATA; + if (align > 13) + align = 13; + if (u64) + set_32 (hdr + offsetof (struct external_scnhdr, u.xcoff64.s_flags), flags); + else + set_32 (hdr + offsetof (struct external_scnhdr, u.xcoff32.s_flags), flags); + + return simple_object_internal_write (descriptor, scnhdr_offset, hdrbuf, + u64 ? SCNHSZ64 : SCNHSZ32, + errmsg, err); +} + +/* Write out a complete XCOFF file. */ + +static const char * +simple_object_xcoff_write_to_file (simple_object_write *sobj, int descriptor, + int *err) +{ + struct simple_object_xcoff_read *ocr = + (struct simple_object_xcoff_read *) sobj->data; + int u64 = ocr->magic == U64_TOCMAGIC; + unsigned int nscns, secnum; + simple_object_write_section *section; + off_t scnhdr_offset; + size_t symtab_offset; + off_t secsym_offset; + unsigned int nsyms; + size_t offset; + size_t name_offset; + const char *errmsg; + unsigned char strsizebuf[4]; + /* The interface doesn't give us access to the name of the input file + yet. We want to use its basename for the FILE symbol. This is + what 'gas' uses when told to assemble from stdin. */ + const char *source_filename = "fake"; + size_t sflen; + union + { + struct external_syment sym; + union external_auxent aux; + } syms[2]; + void (*set_16) (unsigned char *, unsigned short); + void (*set_32) (unsigned char *, unsigned int); + + set_16 = simple_object_set_big_16; + set_32 = simple_object_set_big_32; + + nscns = 0; + for (section = sobj->sections; section != NULL; section = section->next) + ++nscns; + + scnhdr_offset = sizeof (struct external_filehdr) - (u64 ? 4 : 0); + offset = scnhdr_offset + nscns * (u64 ? SCNHSZ64 : SCNHSZ32); + name_offset = 4; + for (section = sobj->sections; section != NULL; section = section->next) + { + size_t mask; + size_t new_offset; + size_t scnsize; + struct simple_object_write_section_buffer *buffer; + + mask = (1U << section->align) - 1; + new_offset = offset & mask; + new_offset &= ~ mask; + while (new_offset > offset) + { + unsigned char zeroes[16]; + size_t write; + + memset (zeroes, 0, sizeof zeroes); + write = new_offset - offset; + if (write > sizeof zeroes) + write = sizeof zeroes; + if (!simple_object_internal_write (descriptor, offset, zeroes, write, + &errmsg, err)) + return errmsg; + } + + scnsize = 0; + for (buffer = section->buffers; buffer != NULL; buffer = buffer->next) + { + if (!simple_object_internal_write (descriptor, offset + scnsize, + ((const unsigned char *) + buffer->buffer), + buffer->size, &errmsg, err)) + return errmsg; + scnsize += buffer->size; + } + + if (!simple_object_xcoff_write_scnhdr (sobj, descriptor, section->name, + &name_offset, scnhdr_offset, + scnsize, offset, section->align, + &errmsg, err)) + return errmsg; + + scnhdr_offset += u64 ? SCNHSZ64 : SCNHSZ32; + offset += scnsize; + } + + /* Symbol table is always half-word aligned. */ + offset += (offset & 1); + /* There is a file symbol and a section symbol per section, + and each of these has a single auxiliary symbol following. */ + nsyms = 2 * (nscns + 1); + symtab_offset = offset; + /* Advance across space reserved for symbol table to locate + start of string table. */ + offset += nsyms * SYMESZ; + + /* Write out file symbol. */ + memset (&syms[0], 0, sizeof (syms)); + if (!u64) + strcpy ((char *)&syms[0].sym.u.xcoff32.n.n_name[0], ".file"); + set_16 (&syms[0].sym.n_scnum[0], N_DEBUG); + set_16 (&syms[0].sym.n_type[0], IMAGE_SYM_TYPE); + syms[0].sym.n_sclass[0] = C_FILE; + syms[0].sym.n_numaux[0] = 1; + /* The name need not be nul-terminated if it fits into the x_fname field + directly, but must be if it has to be placed into the string table. */ + sflen = strlen (source_filename); + if (sflen <= FILNMLEN) + memcpy (&syms[1].aux.x_file.x_fname[0], source_filename, sflen); + else + { + set_32 (&syms[1].aux.x_file._x.x_offset[0], name_offset); + if (!simple_object_internal_write (descriptor, offset + name_offset, + ((const unsigned char *) + source_filename), + sflen + 1, &errmsg, err)) + return errmsg; + name_offset += strlen (source_filename) + 1; + } + if (!simple_object_internal_write (descriptor, symtab_offset, + (const unsigned char *) &syms[0], + sizeof (syms), &errmsg, err)) + return errmsg; + + /* Write the string table length, followed by the strings and section + symbols in step with each other. */ + set_32 (strsizebuf, name_offset); + if (!simple_object_internal_write (descriptor, offset, strsizebuf, 4, + &errmsg, err)) + return errmsg; + + name_offset = 4; + secsym_offset = symtab_offset + sizeof (syms); + memset (&syms[0], 0, sizeof (syms)); + set_16 (&syms[0].sym.n_type[0], IMAGE_SYM_TYPE); + syms[0].sym.n_sclass[0] = C_STAT; + syms[0].sym.n_numaux[0] = 1; + secnum = 1; + + for (section = sobj->sections; section != NULL; section = section->next) + { + size_t namelen; + size_t scnsize; + struct simple_object_write_section_buffer *buffer; + + namelen = strlen (section->name); + set_16 (&syms[0].sym.n_scnum[0], secnum++); + scnsize = 0; + for (buffer = section->buffers; buffer != NULL; buffer = buffer->next) + scnsize += buffer->size; + set_32 (&syms[1].aux.x_scn.x_scnlen[0], scnsize); + if (namelen > SCNNMLEN) + { + set_32 (&syms[0].sym.u.xcoff32.n.n.n_zeroes[0], 0); + set_32 (&syms[0].sym.u.xcoff32.n.n.n_offset[0], name_offset); + if (!simple_object_internal_write (descriptor, offset + name_offset, + ((const unsigned char *) + section->name), + namelen + 1, &errmsg, err)) + return errmsg; + name_offset += namelen + 1; + } + else + { + memcpy (&syms[0].sym.u.xcoff32.n.n_name[0], section->name, + strlen (section->name)); + memset (&syms[0].sym.u.xcoff32.n.n_name[strlen (section->name)], 0, + N_SYMNMLEN - strlen (section->name)); + } + + if (!simple_object_internal_write (descriptor, secsym_offset, + (const unsigned char *) &syms[0], + sizeof (syms), &errmsg, err)) + return errmsg; + secsym_offset += sizeof (syms); + } + + if (!simple_object_xcoff_write_filehdr (sobj, descriptor, nscns, + symtab_offset, nsyms, &errmsg, err)) + return errmsg; + + return NULL; +} + +/* Release the private data for an simple_object_write structure. */ + +static void +simple_object_xcoff_release_write (void *data) +{ + XDELETE (data); +} + +/* The XCOFF functions. */ + +const struct simple_object_functions simple_object_xcoff_functions = +{ + simple_object_xcoff_match, + simple_object_xcoff_find_sections, + simple_object_xcoff_fetch_attributes, + simple_object_xcoff_release_read, + simple_object_xcoff_attributes_merge, + simple_object_xcoff_release_attributes, + simple_object_xcoff_start_write, + simple_object_xcoff_write_to_file, + simple_object_xcoff_release_write +}; diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c index d000cfc080..5d379d053c 100644 --- a/libiberty/simple-object.c +++ b/libiberty/simple-object.c @@ -51,7 +51,8 @@ static const struct simple_object_functions * const format_functions[] = { &simple_object_elf_functions, &simple_object_mach_o_functions, - &simple_object_coff_functions + &simple_object_coff_functions, + &simple_object_xcoff_functions }; /* Read data from a file using the simple_object error reporting @@ -62,8 +63,6 @@ simple_object_internal_read (int descriptor, off_t offset, unsigned char *buffer, size_t size, const char **errmsg, int *err) { - ssize_t got; - if (lseek (descriptor, offset, SEEK_SET) < 0) { *errmsg = "lseek"; @@ -71,15 +70,26 @@ simple_object_internal_read (int descriptor, off_t offset, return 0; } - got = read (descriptor, buffer, size); - if (got < 0) + do { - *errmsg = "read"; - *err = errno; - return 0; + ssize_t got = read (descriptor, buffer, size); + if (got == 0) + break; + else if (got > 0) + { + buffer += got; + size -= got; + } + else if (errno != EINTR) + { + *errmsg = "read"; + *err = errno; + return 0; + } } + while (size > 0); - if ((size_t) got < size) + if (size > 0) { *errmsg = "file too short"; *err = 0; @@ -97,8 +107,6 @@ simple_object_internal_write (int descriptor, off_t offset, const unsigned char *buffer, size_t size, const char **errmsg, int *err) { - ssize_t wrote; - if (lseek (descriptor, offset, SEEK_SET) < 0) { *errmsg = "lseek"; @@ -106,15 +114,26 @@ simple_object_internal_write (int descriptor, off_t offset, return 0; } - wrote = write (descriptor, buffer, size); - if (wrote < 0) + do { - *errmsg = "write"; - *err = errno; - return 0; + ssize_t wrote = write (descriptor, buffer, size); + if (wrote == 0) + break; + else if (wrote > 0) + { + buffer += wrote; + size -= wrote; + } + else if (errno != EINTR) + { + *errmsg = "write"; + *err = errno; + return 0; + } } + while (size > 0); - if ((size_t) wrote < size) + if (size > 0) { *errmsg = "short write"; *err = 0; diff --git a/libiberty/snprintf.c b/libiberty/snprintf.c index 1e3b03888e..49bcd8300d 100644 --- a/libiberty/snprintf.c +++ b/libiberty/snprintf.c @@ -1,5 +1,5 @@ /* Implement the snprintf function. - Copyright (C) 2003, 2011 Free Software Foundation, Inc. + Copyright (C) 2003, 2011, 2013 Free Software Foundation, Inc. Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. This file is part of the libiberty library. This library is free @@ -53,11 +53,9 @@ int snprintf (char *s, size_t n, const char *format, ...) { int result; - VA_OPEN (ap, format); - VA_FIXEDARG (ap, char *, s); - VA_FIXEDARG (ap, size_t, n); - VA_FIXEDARG (ap, const char *, format); + va_list ap; + va_start (ap, format); result = vsnprintf (s, n, format, ap); - VA_CLOSE (ap); + va_end (ap); return result; } diff --git a/libiberty/stack-limit.c b/libiberty/stack-limit.c index e64cac28d1..82c3d44498 100644 --- a/libiberty/stack-limit.c +++ b/libiberty/stack-limit.c @@ -34,6 +34,7 @@ Attempt to increase stack size limit to @var{pref} bytes if possible. */ #include "config.h" +#include "ansidecl.h" #ifdef HAVE_STDINT_H #include <stdint.h> @@ -43,7 +44,7 @@ Attempt to increase stack size limit to @var{pref} bytes if possible. #endif void -stack_limit_increase (unsigned long pref) +stack_limit_increase (unsigned long pref ATTRIBUTE_UNUSED) { #if defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT) \ && defined(RLIMIT_STACK) && defined(RLIM_INFINITY) diff --git a/libiberty/strnlen.c b/libiberty/strnlen.c new file mode 100644 index 0000000000..4934973adc --- /dev/null +++ b/libiberty/strnlen.c @@ -0,0 +1,30 @@ +/* Portable version of strnlen. + This function is in the public domain. */ + +/* + +@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t @var{maxlen}) + +Returns the length of @var{s}, as with @code{strlen}, but never looks +past the first @var{maxlen} characters in the string. If there is no +'\0' character in the first @var{maxlen} characters, returns +@var{maxlen}. + +@end deftypefn + +*/ + +#include "config.h" + +#include <stddef.h> + +size_t +strnlen (const char *s, size_t maxlen) +{ + size_t i; + + for (i = 0; i < maxlen; ++i) + if (s[i] == '\0') + break; + return i; +} diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected index d489692f0b..3ff08e6e5f 100644 --- a/libiberty/testsuite/demangle-expected +++ b/libiberty/testsuite/demangle-expected @@ -3951,6 +3951,9 @@ S::f(int, int)::{default arg#2}::{lambda()#2}::operator()() const _ZNK1SIiE1xMUlvE1_clEv S<int>::x::{lambda()#3}::operator()() const --format=gnu-v3 +_ZN8functionC1IZN1CIiE4testES_Ed_UliE_EET_ +function::function<C<int>::test(function)::{default arg#1}::{lambda(int)#1}>(C<int>::test(function)::{default arg#1}::{lambda(int)#1}) +--format=gnu-v3 _Z1fN1SUt_E f(S::{unnamed type#1}) --format=gnu-v3 @@ -4081,6 +4084,12 @@ decltype (new auto({parm#1})) f<int>(int) --format=gnu-v3 _Z1fIiERDaRKT_S1_ auto& f<int>(int const&, int) +--format=gnu-v3 +_Z1gILi1EEvR1AIXT_EER1BIXscbT_EE +void g<1>(A<1>&, B<static_cast<bool>(1)>&) +--format=gnu-v3 +_ZNKSt7complexIiE4realB5cxx11Ev +std::complex<int>::real[abi:cxx11]() const # # Ada (GNAT) tests. # @@ -4264,5 +4273,47 @@ foo # --format=gnu-v3 --no-params _Z1fIKFvvES0_Evv -void f<void () const, void ()>() -f<void () const, void ()> +void f<void () const, void () const>() +f<void () const, void () const> +# +--format=gnu-v3 +_ZN4modc6parser8sequenceINS_9astParser13LocatedParserINS0_9ParserRefINS2_UlRNS2_16TokenParserInputEE_EEEEEINS0_14OptionalParserINS2_18ListParserTemplateILNS_6tokens5Token4TypeE4EXadL_ZNSD_Ut_13parenthesizedEEEE6ParserINS4_INS0_6ParserIS5_NS_3ast10ExpressionEEEEEEEEENSA_INS4_INS2_22OneOfKeywordsToTParserINSJ_5StyleEEEEEEENS0_14SequenceParserIS5_INS0_18ExactElementParserIS5_EENSA_ISM_EEEEENS0_14RepeatedParserINS4_INS0_15TransformParserINSU_IS5_INS4_INSP_INSJ_10Annotation12RelationshipEEEEESX_EEENS2_UlNS2_3LocES12_ONS_5MaybeISK_EEE19_EEEEELb0EEEEEENSU_INS0_17ExtractParserTypeIT_E9InputTypeEINS0_8MaybeRefIS1F_E4TypeEDpNS1I_IT0_E4TypeEEEEOS1F_DpOS1L_ +modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::parser::ExtractParserType<modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> > >::InputType, modc::parser::MaybeRef<modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}>::Type, modc::parser::RepeatedParser<modc::parser::ParserRef<modc::parser::TransformParser<modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::astParser::TokenParserInput<modc::parser::ParserRef<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > ><modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Annotation::Relationship> >, modc::parser::ExactElementParser> >, modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}> >, false><modc::parser::OptionalParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > > > >::Type, modc::parser::RepeatedParser<modc::parser::ParserRef<modc::parser::TransformParser<modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::astParser::TokenParserInput<modc::parser::ParserRef<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > ><modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Annotation::Relationship> >, modc::parser::ExactElementParser> >, modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}> >, false><modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> ><modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> > > >::Type, modc::parser::RepeatedParser<modc::parser::ParserRef<modc::parser::TransformParser<modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::astParser::TokenParserInput<modc::parser::ParserRef<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > ><modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Annotation::Relationship> >, modc::parser::ExactElementParser> >, modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}> >, false><modc::parser::SequenceParser<modc::astParser::TokenParserInput<modc::parser::ExactElementParser<modc::astParser::TokenParserInput>, modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> ><modc::ast::Expression> > > >::Type, modc::parser::RepeatedParser<modc::parser::ParserRef<modc::parser::TransformParser<modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::astParser::TokenParserInput<modc::parser::ParserRef<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > ><modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Annotation::Relationship> >, modc::parser::ExactElementParser> >, modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}> >, false><modc::parser::RepeatedParser<modc::parser::ParserRef<modc::parser::TransformParser<modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::astParser::TokenParserInput<modc::parser::ParserRef<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > ><modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Annotation::Relationship> >, modc::parser::ExactElementParser> >, modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}> >, false> >::Type> modc::parser::sequence<modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> >, modc::parser::OptionalParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > > >, modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> ><modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> > >, modc::parser::SequenceParser<modc::astParser::TokenParserInput<modc::parser::ExactElementParser<modc::astParser::TokenParserInput>, modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> ><modc::ast::Expression> > >, modc::parser::RepeatedParser<modc::parser::ParserRef<modc::parser::TransformParser<modc::parser::ParserRef<modc::astParser::OneOfKeywordsToTParser<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Style> ><modc::astParser::TokenParserInput<modc::parser::ParserRef<modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser<modc::parser::ParserRef<modc::parser::Parser<modc::astParser::TokenParserInput, modc::ast::Expression> > ><modc::astParser::ListParserTemplate<(modc::tokens::Token::Type)4, &modc::tokens::{unnamed type#1}::parenthesized>::Parser::Annotation::Relationship> >, modc::parser::ExactElementParser> >, modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}> >, false> >(modc::astParser::{lambda(modc::astParser::Loc, modc::parser::RepeatedParser, modc::Maybe<modc::parser::Parser>&&)#21}&&, (modc::parser::ExtractParserType<modc::astParser::LocatedParser<modc::parser::ParserRef<modc::astParser::{lambda(modc::astParser::TokenParserInput&)#1}> > >&&)...) +--format=gnu-v3 +_ZNKR1A1hEv +A::h() const & +--format=gnu-v3 +_Z1lM1AKFvvRE +l(void (A::*)() const &) +--format=gnu-v3 +_Z1mIFvvOEEvM1AT_ +void m<void () &&>(void (A::*)() &&) +--format=gnu-v3 +_Z1nIM1AKFvvREEvT_ +void n<void (A::*)() const &>(void (A::*)() const &) +--format=gnu-v3 +_ZL1fIiEvv +void f<int>() +--format=gnu-v3 +_ZSt7forwardIRN1x14refobjiteratorINS0_3refINS0_4mime30multipart_section_processorObjIZ15get_body_parserIZZN14mime_processor21make_section_iteratorERKNS2_INS3_10sectionObjENS0_10ptrrefBaseEEEbENKUlvE_clEvEUlSB_bE_ZZNS6_21make_section_iteratorESB_bENKSC_clEvEUlSB_E0_ENS1_INS2_INS0_20outputrefiteratorObjIiEES8_EEEERKSsSB_OT_OT0_EUlmE_NS3_32make_multipart_default_discarderISP_EEEES8_EEEEEOT_RNSt16remove_referenceISW_E4typeE +x::refobjiterator<x::ref<x::mime::multipart_section_processorObj<x::refobjiterator<x::ref<x::outputrefiteratorObj<int>, x::ptrrefBase> > get_body_parser<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}>(std::string const&, x::ref<x::mime::sectionObj, x::ptrrefBase> const&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}&&)::{lambda(unsigned long)#1}, x::mime::make_multipart_default_discarder<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&> >, x::ptrrefBase> >& std::forward<x::refobjiterator<x::ref<x::mime::multipart_section_processorObj<x::refobjiterator<x::ref<x::outputrefiteratorObj<int>, x::ptrrefBase> > get_body_parser<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}>(std::string const&, x::ref<x::mime::sectionObj, x::ptrrefBase> const&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}&&)::{lambda(unsigned long)#1}, x::mime::make_multipart_default_discarder<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&> >, x::ptrrefBase> >&>(std::remove_reference<x::mime::multipart_section_processorObj<x::refobjiterator<x::ref<x::outputrefiteratorObj<int>, x::ptrrefBase> > get_body_parser<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}>(std::string const&, x::ref<x::mime::sectionObj, x::ptrrefBase> const&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&, mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&)#2}&&)::{lambda(unsigned long)#1}, x::mime::make_multipart_default_discarder<mime_processor::make_section_iterator(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)::{lambda()#1}::operator()() const::{lambda(x::ref<x::mime::sectionObj, x::ptrrefBase> const&, bool)#1}&&> > >::type&) +# +--format=gnu-v3 --no-params +_ZNK7strings8internal8SplitterINS_9delimiter5AnyOfENS_9SkipEmptyEEcvT_ISt6vectorI12basic_stringIcSt11char_traitsIcESaIcEESaISD_EEvEEv +strings::internal::Splitter<strings::delimiter::AnyOf, strings::SkipEmpty>::operator std::vector<basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<basic_string<char, std::char_traits<char>, std::allocator<char> > > ><std::vector<basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<basic_string<char, std::char_traits<char>, std::allocator<char> > > >, void>() const +strings::internal::Splitter<strings::delimiter::AnyOf, strings::SkipEmpty>::operator std::vector<basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<basic_string<char, std::char_traits<char>, std::allocator<char> > > ><std::vector<basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<basic_string<char, std::char_traits<char>, std::allocator<char> > > >, void> +# +--format=gnu-v3 --no-params +_ZN1AcvT_I1CEEv +A::operator C<C>() +A::operator C<C> +# +--format=gnu-v3 --no-params +_ZN1AcvPT_I1CEEv +A::operator C*<C>() +A::operator C*<C> +# +--format=gnu-v3 --no-params +_ZN1AcvT_IiEI1CEEv +A::operator C<int><C>() +A::operator C<int><C> diff --git a/libiberty/testsuite/test-demangle.c b/libiberty/testsuite/test-demangle.c index 11d9729999..44062478c0 100644 --- a/libiberty/testsuite/test-demangle.c +++ b/libiberty/testsuite/test-demangle.c @@ -32,6 +32,9 @@ #if HAVE_STDLIB_H # include <stdlib.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif struct line { diff --git a/libiberty/testsuite/test-expandargv.c b/libiberty/testsuite/test-expandargv.c index dff20d41da..0edd751722 100644 --- a/libiberty/testsuite/test-expandargv.c +++ b/libiberty/testsuite/test-expandargv.c @@ -40,6 +40,9 @@ #ifdef HAVE_STRING_H #include <string.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c index 85de5429fc..492506037d 100644 --- a/libiberty/vasprintf.c +++ b/libiberty/vasprintf.c @@ -1,6 +1,6 @@ /* Like vsprintf but provides a pointer to malloc'd storage, which must be freed by the caller. - Copyright (C) 1994, 2003, 2011 Free Software Foundation, Inc. + Copyright (C) 1994, 2003, 2011, 2013 Free Software Foundation, Inc. This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or @@ -165,10 +165,10 @@ static void ATTRIBUTE_PRINTF_1 checkit (const char *format, ...) { char *result; - VA_OPEN (args, format); - VA_FIXEDARG (args, const char *, format); + va_list args; + va_start (args, format); vasprintf (&result, format, args); - VA_CLOSE (args); + va_end (args); if (strlen (result) < (size_t) global_total_width) printf ("PASS: "); diff --git a/libiberty/vsnprintf.c b/libiberty/vsnprintf.c index 6c0afa6726..2c441a72f6 100644 --- a/libiberty/vsnprintf.c +++ b/libiberty/vsnprintf.c @@ -1,5 +1,5 @@ /* Implement the vsnprintf function. - Copyright (C) 2003, 2004, 2005, 2011 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2011, 2013 Free Software Foundation, Inc. Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>. This file is part of the libiberty library. This library is free @@ -95,12 +95,10 @@ static int ATTRIBUTE_PRINTF_3 checkit (char *s, size_t n, const char *format, ...) { int result; - VA_OPEN (ap, format); - VA_FIXEDARG (ap, char *, s); - VA_FIXEDARG (ap, size_t, n); - VA_FIXEDARG (ap, const char *, format); + va_list ap; + va_start (ap, format); result = vsnprintf (s, n, format, ap); - VA_CLOSE (ap); + va_end (ap); return result; } |