Commit: Update libiberty sources with changes from the gcc mainline

Message ID 87k15q5fqf.fsf@redhat.com
State New
Headers show
Series
  • Commit: Update libiberty sources with changes from the gcc mainline
Related show

Commit Message

Nick Clifton Jan. 17, 2020, 2:18 p.m.
Hi Guys,

  I have updated the libiberty sources with the changes from the gcc
  mainline. (Patch attached).  I understand that there is a forthcoming
  patch to the gcc version to fix a LTO problem.  If that is committed
  in the next couple of weeks then I will make sure that it gets into
  the binutils sources (branch and mainline) before the release.

Cheers
  Nick

libiberty/ChangeLog
2020-01-01  Jakub Jelinek  <jakub@redhat.com>

	Update copyright years.

2019-12-06  Tim Ruehsen  <tim.ruehsen@gmx.de>

	* make-relative-prefix.c (split_directories):
	Return early on empty 'name'

2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>

	* cp-demangle.c (d_print_init): Remove const from 4th param.
	(cplus_demangle_fill_name): Initialize d->d_counting.
	(cplus_demangle_fill_extended_operator): Likewise.
	(cplus_demangle_fill_ctor): Likewise.
	(cplus_demangle_fill_dtor): Likewise.
	(d_make_empty): Likewise.
	(d_count_templates_scopes): Remobe const from 3rd param,
	Return on dc->d_counting > 1,
	Increment dc->d_counting.
        * cp-demint.c (cplus_demangle_fill_component): Initialize d->d_counting.
	(cplus_demangle_fill_builtin_type): Likewise.
	(cplus_demangle_fill_operator): Likewise.

2019-11-16  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

	* cplus-dem.c (cplus_demangle): Use rust_demangle directly.
	(rust_demangle): Remove.
	* rust-demangle.c (is_prefixed_hash): Rename to is_legacy_prefixed_hash.
	(parse_lower_hex_nibble): Rename to decode_lower_hex_nibble.
	(parse_legacy_escape): Rename to decode_legacy_escape.
	(rust_is_mangled): Remove.
	(struct rust_demangler): Add.
	(peek): Add.
	(next): Add.
	(struct rust_mangled_ident): Add.
	(parse_ident): Add.
	(rust_demangle_sym): Remove.
	(print_str): Add.
	(PRINT): Add.
	(print_ident): Add.
	(rust_demangle_callback): Add.
	(struct str_buf): Add.
	(str_buf_reserve): Add.
	(str_buf_append): Add.
	(str_buf_demangle_callback): Add.
	(rust_demangle): Add.
	* rust-demangle.h: Remove.

2019-11-15  Miguel Saldivar  <saldivarcher@gmail.com>

	* testsuite/demangle-expected: Fix test.

2019-11-04  Kamlesh Kumar  <kamleshbhalui@gmail.com>

	* cp-demangle.c (d_expr_primary): Handle
	nullptr demangling.
	* testsuite/demangle-expected: Added test.

2019-10-29 Paul Pluzhnikov  <ppluzhnikov@google.com>

	* cp-demangle.c (d_number): Avoid signed int overflow.

2019-10-28  Miguel Saldivar  <saldivarcher@gmail.com>

	* cp-demangle.c (d_print_mod): Add a space before printing `complex`
	and `imaginary`, as opposed to after.
	* testsuite/demangle-expected: Adjust test.

2019-10-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

	* rust-demangle.c (looks_like_rust): Remove.
	(rust_is_mangled): Don't check escapes.
	(is_prefixed_hash): Allow 0-9a-f permutations.
	(rust_demangle_sym): Don't bail on unknown escapes.
	* testsuite/rust-demangle-expected: Update 'main::$99$' test.

2019-09-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

	* rust-demangle.c (unescape): Remove.
	(parse_lower_hex_nibble): New function.
	(parse_legacy_escape): New function.
	(is_prefixed_hash): Use parse_lower_hex_nibble.
	(looks_like_rust): Use parse_legacy_escape.
	(rust_demangle_sym): Use parse_legacy_escape.
	* testsuite/rust-demangle-expected: Add 'llv$u6d$' test.

2019-08-27  Martin Liska  <mliska@suse.cz>

	PR lto/91478
	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
	First find a WEAK HIDDEN symbol in symbol table that will be
	preserved.  Later, use the symbol name for all removed symbols.

2019-08-12  Martin Liska  <mliska@suse.cz>

	* Makefile.in: Add filedescriptor.c.
	* filedescriptor.c: New file.
	* lrealpath.c (is_valid_fd): Remove.

include/ChangeLog
2020-01-17  Nick Clifton  <nickc@redhat.com>

	* Import from gcc mainline:
	2019-06-10  Martin Liska  <mliska@suse.cz>

	* ansidecl.h (ATTRIBUTE_WARN_UNUSED_RESULT): New macro.
	* libiberty.h (xmalloc): Use it.
	(xrealloc): Likewise.
	(xcalloc): Likewise.
	(xstrdup): Likewise.
	(xstrndup): Likewise.
	(xmemdup): Likewise.

	2019-06-10  Martin Liska  <mliska@suse.cz>

	* ansidecl.h:
	(ATTRIBUTE_RESULT_SIZE_1): Define new macro.
	(ATTRIBUTE_RESULT_SIZE_2): Likewise.
	(ATTRIBUTE_RESULT_SIZE_1_2): Likewise.
	* libiberty.h (xmalloc): Add RESULT_SIZE attribute.
	(xrealloc): Likewise.
	(xcalloc): Likewise.

	2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>

	* demangle.h (struct demangle_component): Add member
	d_counting.

	2019-11-16  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

	* demangle.h (rust_demangle_callback): Add.

	2019-07-18  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

	* demangle.h (rust_is_mangled): Move to libiberty/rust-demangle.h.
	(rust_demangle_sym): Move to libiberty/rust-demangle.h.

Comments

H.J. Lu Jan. 17, 2020, 3:11 p.m. | #1
On Fri, Jan 17, 2020 at 6:18 AM Nick Clifton <nickc@redhat.com> wrote:
>

> Hi Guys,

>

>   I have updated the libiberty sources with the changes from the gcc

>   mainline. (Patch attached).  I understand that there is a forthcoming

>   patch to the gcc version to fix a LTO problem.  If that is committed

>   in the next couple of weeks then I will make sure that it gets into

>   the binutils sources (branch and mainline) before the release.

>

> Cheers

>   Nick

>

> libiberty/ChangeLog

> 2020-01-01  Jakub Jelinek  <jakub@redhat.com>

>

>         Update copyright years.

>

> 2019-12-06  Tim Ruehsen  <tim.ruehsen@gmx.de>

>

>         * make-relative-prefix.c (split_directories):

>         Return early on empty 'name'

>

> 2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>

>

>         * cp-demangle.c (d_print_init): Remove const from 4th param.

>         (cplus_demangle_fill_name): Initialize d->d_counting.

>         (cplus_demangle_fill_extended_operator): Likewise.

>         (cplus_demangle_fill_ctor): Likewise.

>         (cplus_demangle_fill_dtor): Likewise.

>         (d_make_empty): Likewise.

>         (d_count_templates_scopes): Remobe const from 3rd param,

>         Return on dc->d_counting > 1,

>         Increment dc->d_counting.

>         * cp-demint.c (cplus_demangle_fill_component): Initialize d->d_counting.

>         (cplus_demangle_fill_builtin_type): Likewise.

>         (cplus_demangle_fill_operator): Likewise.

>

> 2019-11-16  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

>

>         * cplus-dem.c (cplus_demangle): Use rust_demangle directly.

>         (rust_demangle): Remove.

>         * rust-demangle.c (is_prefixed_hash): Rename to is_legacy_prefixed_hash.

>         (parse_lower_hex_nibble): Rename to decode_lower_hex_nibble.

>         (parse_legacy_escape): Rename to decode_legacy_escape.

>         (rust_is_mangled): Remove.

>         (struct rust_demangler): Add.

>         (peek): Add.

>         (next): Add.

>         (struct rust_mangled_ident): Add.

>         (parse_ident): Add.

>         (rust_demangle_sym): Remove.

>         (print_str): Add.

>         (PRINT): Add.

>         (print_ident): Add.

>         (rust_demangle_callback): Add.

>         (struct str_buf): Add.

>         (str_buf_reserve): Add.

>         (str_buf_append): Add.

>         (str_buf_demangle_callback): Add.

>         (rust_demangle): Add.

>         * rust-demangle.h: Remove.

>

> 2019-11-15  Miguel Saldivar  <saldivarcher@gmail.com>

>

>         * testsuite/demangle-expected: Fix test.

>

> 2019-11-04  Kamlesh Kumar  <kamleshbhalui@gmail.com>

>

>         * cp-demangle.c (d_expr_primary): Handle

>         nullptr demangling.

>         * testsuite/demangle-expected: Added test.

>

> 2019-10-29 Paul Pluzhnikov  <ppluzhnikov@google.com>

>

>         * cp-demangle.c (d_number): Avoid signed int overflow.

>

> 2019-10-28  Miguel Saldivar  <saldivarcher@gmail.com>

>

>         * cp-demangle.c (d_print_mod): Add a space before printing `complex`

>         and `imaginary`, as opposed to after.

>         * testsuite/demangle-expected: Adjust test.

>

> 2019-10-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

>

>         * rust-demangle.c (looks_like_rust): Remove.

>         (rust_is_mangled): Don't check escapes.

>         (is_prefixed_hash): Allow 0-9a-f permutations.

>         (rust_demangle_sym): Don't bail on unknown escapes.

>         * testsuite/rust-demangle-expected: Update 'main::$99$' test.

>

> 2019-09-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

>

>         * rust-demangle.c (unescape): Remove.

>         (parse_lower_hex_nibble): New function.

>         (parse_legacy_escape): New function.

>         (is_prefixed_hash): Use parse_lower_hex_nibble.

>         (looks_like_rust): Use parse_legacy_escape.

>         (rust_demangle_sym): Use parse_legacy_escape.

>         * testsuite/rust-demangle-expected: Add 'llv$u6d$' test.

>

> 2019-08-27  Martin Liska  <mliska@suse.cz>

>

>         PR lto/91478

>         * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):

>         First find a WEAK HIDDEN symbol in symbol table that will be

>         preserved.  Later, use the symbol name for all removed symbols.

>

> 2019-08-12  Martin Liska  <mliska@suse.cz>

>

>         * Makefile.in: Add filedescriptor.c.

>         * filedescriptor.c: New file.

>         * lrealpath.c (is_valid_fd): Remove.

>

> include/ChangeLog

> 2020-01-17  Nick Clifton  <nickc@redhat.com>

>

>         * Import from gcc mainline:

>         2019-06-10  Martin Liska  <mliska@suse.cz>

>

>         * ansidecl.h (ATTRIBUTE_WARN_UNUSED_RESULT): New macro.

>         * libiberty.h (xmalloc): Use it.

>         (xrealloc): Likewise.

>         (xcalloc): Likewise.

>         (xstrdup): Likewise.

>         (xstrndup): Likewise.

>         (xmemdup): Likewise.

>

>         2019-06-10  Martin Liska  <mliska@suse.cz>

>

>         * ansidecl.h:

>         (ATTRIBUTE_RESULT_SIZE_1): Define new macro.

>         (ATTRIBUTE_RESULT_SIZE_2): Likewise.

>         (ATTRIBUTE_RESULT_SIZE_1_2): Likewise.

>         * libiberty.h (xmalloc): Add RESULT_SIZE attribute.

>         (xrealloc): Likewise.

>         (xcalloc): Likewise.

>

>         2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>

>

>         * demangle.h (struct demangle_component): Add member

>         d_counting.

>

>         2019-11-16  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

>

>         * demangle.h (rust_demangle_callback): Add.

>

>         2019-07-18  Eduard-Mihai Burtescu  <eddyb@lyken.rs>

>

>         * demangle.h (rust_is_mangled): Move to libiberty/rust-demangle.h.

>         (rust_demangle_sym): Move to libiberty/rust-demangle.h.

>


I got

/test-demangle: 328 tests, 0 failures
FAIL at line 1452, options :
in:  _Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
out: void foo<(void*)0>(enable_if<((void*)0)==(decltype(nullptr)),
void>::type*)exp: void
foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))),
void>::type*)
./test-demangle: 335 tests, 1 failures
make[5]: *** [Makefile:52: check-cplus-dem] Error 1

-- 
H.J.
Nick Clifton Jan. 20, 2020, 2:18 p.m. | #2
Hi Tom,

> I think you should just submit the patch there as well.


You are right - I have gone ahead and done this.

Cheers
  Nick

Patch

diff --git a/include/ansidecl.h b/include/ansidecl.h
index e3f8ba7267..ec7a13f016 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -292,6 +292,40 @@  So instead we use the macro below and test it against specific values.  */
 # endif
 #endif
 
+/* Attribute `alloc_size' was valid as of gcc 4.3.  */
+#ifndef ATTRIBUTE_RESULT_SIZE_1
+# if (GCC_VERSION >= 4003)
+#  define ATTRIBUTE_RESULT_SIZE_1 __attribute__ ((alloc_size (1)))
+# else
+#  define ATTRIBUTE_RESULT_SIZE_1
+#endif
+#endif
+
+#ifndef ATTRIBUTE_RESULT_SIZE_2
+# if (GCC_VERSION >= 4003)
+#  define ATTRIBUTE_RESULT_SIZE_2 __attribute__ ((alloc_size (2)))
+# else
+#  define ATTRIBUTE_RESULT_SIZE_2
+#endif
+#endif
+
+#ifndef ATTRIBUTE_RESULT_SIZE_1_2
+# if (GCC_VERSION >= 4003)
+#  define ATTRIBUTE_RESULT_SIZE_1_2 __attribute__ ((alloc_size (1, 2)))
+# else
+#  define ATTRIBUTE_RESULT_SIZE_1_2
+#endif
+#endif
+
+/* Attribute `warn_unused_result' was valid as of gcc 3.3.  */
+#ifndef ATTRIBUTE_WARN_UNUSED_RESULT
+# if GCC_VERSION >= 3003
+#  define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
+# else
+#  define ATTRIBUTE_WARN_UNUSED_RESULT
+# endif
+#endif
+
 /* We use __extension__ in some places to suppress -pedantic warnings
    about GCC extensions.  This feature didn't work properly before
    gcc 2.8.  */
diff --git a/include/demangle.h b/include/demangle.h
index 1564362995..a7f11f5920 100644
--- a/include/demangle.h
+++ b/include/demangle.h
@@ -159,24 +159,11 @@  ada_demangle (const char *mangled, int options);
 extern char *
 dlang_demangle (const char *mangled, int options);
 
-/* Returns non-zero iff MANGLED is a rust mangled symbol.  MANGLED must
-   already have been demangled through cplus_demangle_v3.  If this function
-   returns non-zero then MANGLED can be demangled (in-place) using
-   RUST_DEMANGLE_SYM.  */
 extern int
-rust_is_mangled (const char *mangled);
-
-/* Demangles SYM (in-place) if RUST_IS_MANGLED returned non-zero for SYM.
-   If RUST_IS_MANGLED returned zero for SYM then RUST_DEMANGLE_SYM might
-   replace characters that cannot be demangled with '?' and might truncate
-   SYM.  After calling RUST_DEMANGLE_SYM SYM might be shorter, but never
-   larger.  */
-extern void
-rust_demangle_sym (char *sym);
-
-/* Demangles MANGLED if it was GNU_V3 and then RUST mangled, otherwise
-   returns NULL. Uses CPLUS_DEMANGLE_V3, RUST_IS_MANGLED and
-   RUST_DEMANGLE_SYM.  Returns a new string that is owned by the caller.  */
+rust_demangle_callback (const char *mangled, int options,
+                        demangle_callbackref callback, void *opaque);
+
+
 extern char *
 rust_demangle (const char *mangled, int options);
 
@@ -481,6 +468,7 @@  struct demangle_component
      Initialize to zero.  Private to d_print_comp.
      All other fields are final after initialization.  */
   int d_printing;
+  int d_counting;
 
   union
   {
diff --git a/include/libiberty.h b/include/libiberty.h
index 267b6ec528..141cb886a8 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -137,6 +137,10 @@  extern const char *unix_lbasename (const char *) ATTRIBUTE_RETURNS_NONNULL ATTRI
 
 extern char *lrealpath (const char *);
 
+/* Return true when FD file descriptor exists.  */
+
+extern int is_valid_fd (int fd);
+
 /* Concatenate an arbitrary number of strings.  You must pass NULL as
    the last argument of this function, to terminate the list of
    strings.  Allocates memory using xmalloc.  */
@@ -310,30 +314,30 @@  extern void xmalloc_failed (size_t) ATTRIBUTE_NORETURN;
    message to stderr (using the name set by xmalloc_set_program_name,
    if any) and then call xexit.  */
 
-extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
+extern void *xmalloc (size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_1 ATTRIBUTE_WARN_UNUSED_RESULT;
 
 /* Reallocate memory without fail.  This works like xmalloc.  Note,
    realloc type functions are not suitable for attribute malloc since
    they may return the same address across multiple calls. */
 
-extern void *xrealloc (void *, size_t) ATTRIBUTE_RETURNS_NONNULL;
+extern void *xrealloc (void *, size_t) ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_2 ATTRIBUTE_WARN_UNUSED_RESULT;
 
 /* Allocate memory without fail and set it to zero.  This works like
    xmalloc.  */
 
-extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
+extern void *xcalloc (size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_RESULT_SIZE_1_2 ATTRIBUTE_WARN_UNUSED_RESULT;
 
 /* Copy a string into a memory buffer without fail.  */
 
-extern char *xstrdup (const char *) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
+extern char *xstrdup (const char *) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_WARN_UNUSED_RESULT;
 
 /* Copy at most N characters from string into a buffer without fail.  */
 
-extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
+extern char *xstrndup (const char *, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_WARN_UNUSED_RESULT;
 
 /* Copy an existing memory buffer to a new memory buffer without fail.  */
 
-extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
+extern void *xmemdup (const void *, size_t, size_t) ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL ATTRIBUTE_WARN_UNUSED_RESULT;
 
 /* Physical memory routines.  Return values are in BYTES.  */
 extern double physmem_total (void);
@@ -649,7 +653,7 @@  extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
 
 extern char *xasprintf (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF_1;
 
-#if !HAVE_DECL_VASPRINTF
+#if defined(HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
 /* Like vsprintf but provides a pointer to malloc'd storage, which
    must be freed by the caller.  */
 
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 95cb1525f2..c2bab93a15 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,103 @@ 
+2020-01-01  Jakub Jelinek  <jakub@redhat.com>
+
+	Update copyright years.
+
+2019-12-06  Tim Ruehsen  <tim.ruehsen@gmx.de>
+
+	* make-relative-prefix.c (split_directories):
+	Return early on empty 'name'
+
+2019-11-16  Tim Ruehsen  <tim.ruehsen@gmx.de>
+
+	* cp-demangle.c (d_print_init): Remove const from 4th param.
+	(cplus_demangle_fill_name): Initialize d->d_counting.
+	(cplus_demangle_fill_extended_operator): Likewise.
+	(cplus_demangle_fill_ctor): Likewise.
+	(cplus_demangle_fill_dtor): Likewise.
+	(d_make_empty): Likewise.
+	(d_count_templates_scopes): Remobe const from 3rd param,
+	Return on dc->d_counting > 1,
+	Increment dc->d_counting.
+        * cp-demint.c (cplus_demangle_fill_component): Initialize d->d_counting.
+	(cplus_demangle_fill_builtin_type): Likewise.
+	(cplus_demangle_fill_operator): Likewise.
+
+2019-11-16  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
+
+	* cplus-dem.c (cplus_demangle): Use rust_demangle directly.
+	(rust_demangle): Remove.
+	* rust-demangle.c (is_prefixed_hash): Rename to is_legacy_prefixed_hash.
+	(parse_lower_hex_nibble): Rename to decode_lower_hex_nibble.
+	(parse_legacy_escape): Rename to decode_legacy_escape.
+	(rust_is_mangled): Remove.
+	(struct rust_demangler): Add.
+	(peek): Add.
+	(next): Add.
+	(struct rust_mangled_ident): Add.
+	(parse_ident): Add.
+	(rust_demangle_sym): Remove.
+	(print_str): Add.
+	(PRINT): Add.
+	(print_ident): Add.
+	(rust_demangle_callback): Add.
+	(struct str_buf): Add.
+	(str_buf_reserve): Add.
+	(str_buf_append): Add.
+	(str_buf_demangle_callback): Add.
+	(rust_demangle): Add.
+	* rust-demangle.h: Remove.
+
+2019-11-15  Miguel Saldivar  <saldivarcher@gmail.com>
+
+	* testsuite/demangle-expected: Fix test.
+
+2019-11-04  Kamlesh Kumar  <kamleshbhalui@gmail.com>
+
+	* cp-demangle.c (d_expr_primary): Handle
+	nullptr demangling.
+	* testsuite/demangle-expected: Added test.
+
+2019-10-29 Paul Pluzhnikov  <ppluzhnikov@google.com>
+
+	* cp-demangle.c (d_number): Avoid signed int overflow.
+
+2019-10-28  Miguel Saldivar  <saldivarcher@gmail.com>
+
+	* cp-demangle.c (d_print_mod): Add a space before printing `complex`
+	and `imaginary`, as opposed to after.
+	* testsuite/demangle-expected: Adjust test.
+
+2019-10-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
+
+	* rust-demangle.c (looks_like_rust): Remove.
+	(rust_is_mangled): Don't check escapes.
+	(is_prefixed_hash): Allow 0-9a-f permutations.
+	(rust_demangle_sym): Don't bail on unknown escapes.
+	* testsuite/rust-demangle-expected: Update 'main::$99$' test.
+
+2019-09-03  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
+
+	* rust-demangle.c (unescape): Remove.
+	(parse_lower_hex_nibble): New function.
+	(parse_legacy_escape): New function.
+	(is_prefixed_hash): Use parse_lower_hex_nibble.
+	(looks_like_rust): Use parse_legacy_escape.
+	(rust_demangle_sym): Use parse_legacy_escape.
+	* testsuite/rust-demangle-expected: Add 'llv$u6d$' test.
+
+2019-08-27  Martin Liska  <mliska@suse.cz>
+
+	PR lto/91478
+	* simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+	First find a WEAK HIDDEN symbol in symbol table that will be
+	preserved.  Later, use the symbol name for all removed symbols.
+
+2019-08-12  Martin Liska  <mliska@suse.cz>
+
+	* Makefile.in: Add filedescriptor.c.
+	* filedescriptor.c: New file.
+	* lrealpath.c (is_valid_fd): Remove.
+
 2019-08-08  Martin Liska  <mliska@suse.cz>
 
 	PR bootstrap/91352
diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
index 0be45b4ae8..fe738d0db4 100644
--- a/libiberty/Makefile.in
+++ b/libiberty/Makefile.in
@@ -1,7 +1,7 @@ 
 # Makefile for the libiberty library.
 # Originally written by K. Richard Pixley <rich@cygnus.com>.
 #
-# Copyright (C) 1990-2019 Free Software Foundation, Inc.
+# Copyright (C) 1990-2020 Free Software Foundation, Inc.
 #
 # This file is part of the libiberty library.
 # Libiberty is free software; you can redistribute it and/or
@@ -127,7 +127,7 @@  CFILES = alloca.c argv.c asprintf.c atexit.c				\
 	calloc.c choose-temp.c clock.c concat.c cp-demangle.c		\
 	 cp-demint.c cplus-dem.c crc32.c				\
 	d-demangle.c dwarfnames.c dyn-string.c				\
-	fdmatch.c ffs.c fibheap.c filename_cmp.c floatformat.c		\
+	fdmatch.c ffs.c fibheap.c filedescriptor.c filename_cmp.c floatformat.c		\
 	fnmatch.c fopen_unlocked.c					\
 	getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c	\
          gettimeofday.c                                                 \
@@ -171,6 +171,7 @@  REQUIRED_OFILES =							\
 	./cp-demint.$(objext) ./crc32.$(objext) ./d-demangle.$(objext)	\
 	./dwarfnames.$(objext) ./dyn-string.$(objext)			\
 	./fdmatch.$(objext) ./fibheap.$(objext)				\
+	./filedescriptor.$(objext)	\
 	./filename_cmp.$(objext) ./floatformat.$(objext)		\
 	./fnmatch.$(objext) ./fopen_unlocked.$(objext)			\
 	./getopt.$(objext) ./getopt1.$(objext) ./getpwd.$(objext)	\
@@ -756,6 +757,17 @@  $(CONFIGURED_OFILES): stamp-picdir stamp-noasandir
 	else true; fi
 	$(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION)
 
+./filedescriptor.$(objext): $(srcdir)/filedescriptor.c config.h $(INCDIR)/ansidecl.h \
+	$(INCDIR)/libiberty.h
+	if [ x"$(PICFLAG)" != x ]; then \
+	  $(COMPILE.c) $(PICFLAG) $(srcdir)/filedescriptor.c -o pic/$@; \
+	else true; fi
+	if [ x"$(NOASANFLAG)" != x ]; then \
+	  $(COMPILE.c) $(PICFLAG) $(NOASANFLAG) $(srcdir)/filedescriptor.c -o noasan/$@; \
+	else true; fi
+	$(COMPILE.c) $(srcdir)/filedescriptor.c $(OUTPUT_OPTION)
+
+
 ./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \
 	$(INCDIR)/filenames.h $(INCDIR)/hashtab.h \
 	$(INCDIR)/safe-ctype.h
diff --git a/libiberty/_doprnt.c b/libiberty/_doprnt.c
index d44dc415ed..a739f4304f 100644
--- a/libiberty/_doprnt.c
+++ b/libiberty/_doprnt.c
@@ -1,5 +1,5 @@ 
 /* Provide a version of _doprnt in terms of fprintf.
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
    Contributed by Kaveh Ghazi  (ghazi@caip.rutgers.edu)  3/29/98
 
 This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/argv.c b/libiberty/argv.c
index 6444896f99..8c9794db6a 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -1,5 +1,5 @@ 
 /* Create and destroy argument vectors (argv's)
-   Copyright (C) 1992-2019 Free Software Foundation, Inc.
+   Copyright (C) 1992-2020 Free Software Foundation, Inc.
    Written by Fred Fish @ Cygnus Support
 
 This file is part of the libiberty library.
diff --git a/libiberty/asprintf.c b/libiberty/asprintf.c
index 5718682f69..6e38e2234d 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-2019 Free Software Foundation, Inc.
+   Copyright (C) 1997-2020 Free Software Foundation, Inc.
    Contributed by Cygnus Solutions.
 
 This file is part of the libiberty library.
diff --git a/libiberty/choose-temp.c b/libiberty/choose-temp.c
index 72c1b710bd..49a2faaa51 100644
--- a/libiberty/choose-temp.c
+++ b/libiberty/choose-temp.c
@@ -1,5 +1,5 @@ 
 /* Utility to pick a temporary filename prefix.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/clock.c b/libiberty/clock.c
index a3730714bd..0de74657d0 100644
--- a/libiberty/clock.c
+++ b/libiberty/clock.c
@@ -1,5 +1,5 @@ 
 /* ANSI-compatible clock function.
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
diff --git a/libiberty/concat.c b/libiberty/concat.c
index 8eb478b47b..533e4a99b0 100644
--- a/libiberty/concat.c
+++ b/libiberty/concat.c
@@ -1,5 +1,5 @@ 
 /* Concatenate variable number of strings.
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
    Written by Fred Fish @ Cygnus Support
 
 This file is part of the libiberty library.
diff --git a/libiberty/copying-lib.texi b/libiberty/copying-lib.texi
index ac733f93ad..ce1cb03cc7 100644
--- a/libiberty/copying-lib.texi
+++ b/libiberty/copying-lib.texi
@@ -5,7 +5,7 @@ 
 @center Version 2.1, February 1999
 
 @display
-Copyright @copyright{} 1991-2019 Free Software Foundation, Inc.
+Copyright @copyright{} 1991-2020 Free Software Foundation, Inc.
 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA
 
 Everyone is permitted to copy and distribute verbatim copies
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index aa78c86dd4..3639bfbfd4 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1,5 +1,5 @@ 
 /* Demangler for g++ V3 ABI.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@wasabisystems.com>.
 
    This file is part of the libiberty library, which is part of GCC.
@@ -517,7 +517,7 @@  d_growable_string_callback_adapter (const char *, size_t, void *);
 
 static void
 d_print_init (struct d_print_info *, demangle_callbackref, void *,
-	      const struct demangle_component *);
+	      struct demangle_component *);
 
 static inline void d_print_error (struct d_print_info *);
 
@@ -864,6 +864,7 @@  cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len)
   if (p == NULL || s == NULL || len <= 0)
     return 0;
   p->d_printing = 0;
+  p->d_counting = 0;
   p->type = DEMANGLE_COMPONENT_NAME;
   p->u.s_name.s = s;
   p->u.s_name.len = len;
@@ -880,6 +881,7 @@  cplus_demangle_fill_extended_operator (struct demangle_component *p, int args,
   if (p == NULL || args < 0 || name == NULL)
     return 0;
   p->d_printing = 0;
+  p->d_counting = 0;
   p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR;
   p->u.s_extended_operator.args = args;
   p->u.s_extended_operator.name = name;
@@ -900,6 +902,7 @@  cplus_demangle_fill_ctor (struct demangle_component *p,
       || (int) kind > gnu_v3_object_ctor_group)
     return 0;
   p->d_printing = 0;
+  p->d_counting = 0;
   p->type = DEMANGLE_COMPONENT_CTOR;
   p->u.s_ctor.kind = kind;
   p->u.s_ctor.name = name;
@@ -920,6 +923,7 @@  cplus_demangle_fill_dtor (struct demangle_component *p,
       || (int) kind > gnu_v3_object_dtor_group)
     return 0;
   p->d_printing = 0;
+  p->d_counting = 0;
   p->type = DEMANGLE_COMPONENT_DTOR;
   p->u.s_dtor.kind = kind;
   p->u.s_dtor.name = name;
@@ -937,6 +941,7 @@  d_make_empty (struct d_info *di)
     return NULL;
   p = &di->comps[di->next_comp];
   p->d_printing = 0;
+  p->d_counting = 0;
   ++di->next_comp;
   return p;
 }
@@ -1717,7 +1722,7 @@  d_number (struct d_info *di)
 	}
       if (ret > ((INT_MAX - (peek - '0')) / 10))
         return -1;
-      ret = ret * 10 + peek - '0';
+      ret = ret * 10 + (peek - '0');
       d_advance (di, 1);
       peek = d_peek_char (di);
     }
@@ -3577,6 +3582,17 @@  d_expr_primary (struct d_info *di)
 	  && type->u.s_builtin.type->print != D_PRINT_DEFAULT)
 	di->expansion -= type->u.s_builtin.type->len;
 
+      if (type->type == DEMANGLE_COMPONENT_BUILTIN_TYPE
+	  && strcmp (type->u.s_builtin.type->name,
+		     cplus_demangle_builtin_types[33].name) == 0)
+	{
+	  if (d_peek_char (di) == 'E')
+	    {
+	      d_advance (di, 1);
+	      return type;
+	    }
+	}
+
       /* Rather than try to interpret the literal value, we just
 	 collect it as a string.  Note that it's possible to have a
 	 floating point literal here.  The ABI specifies that the
@@ -4068,11 +4084,13 @@  d_growable_string_callback_adapter (const char *s, size_t l, void *opaque)
 
 static void
 d_count_templates_scopes (struct d_print_info *dpi,
-			  const struct demangle_component *dc)
+			  struct demangle_component *dc)
 {
-  if (dc == NULL)
+  if (dc == NULL || dc->d_counting > 1 || dpi->recursion > MAX_RECURSION_COUNT)
     return;
 
+  ++ dc->d_counting;
+
   switch (dc->type)
     {
     case DEMANGLE_COMPONENT_NAME:
@@ -4202,7 +4220,7 @@  d_count_templates_scopes (struct d_print_info *dpi,
 
 static void
 d_print_init (struct d_print_info *dpi, demangle_callbackref callback,
-	      void *opaque, const struct demangle_component *dc)
+	      void *opaque, struct demangle_component *dc)
 {
   dpi->len = 0;
   dpi->last_char = '\0';
@@ -5977,10 +5995,10 @@  d_print_mod (struct d_print_info *dpi, int options,
       d_append_string (dpi, "&&");
       return;
     case DEMANGLE_COMPONENT_COMPLEX:
-      d_append_string (dpi, "complex ");
+      d_append_string (dpi, " _Complex");
       return;
     case DEMANGLE_COMPONENT_IMAGINARY:
-      d_append_string (dpi, "imaginary ");
+      d_append_string (dpi, " _Imaginary");
       return;
     case DEMANGLE_COMPONENT_PTRMEM_TYPE:
       if (d_last_char (dpi) != '(')
diff --git a/libiberty/cp-demangle.h b/libiberty/cp-demangle.h
index 92191cf3ea..943a3ef478 100644
--- a/libiberty/cp-demangle.h
+++ b/libiberty/cp-demangle.h
@@ -1,5 +1,5 @@ 
 /* Internal demangler interface for g++ V3 ABI.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@wasabisystems.com>.
 
    This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/cp-demint.c b/libiberty/cp-demint.c
index 950e4dc552..6e41bad267 100644
--- a/libiberty/cp-demint.c
+++ b/libiberty/cp-demint.c
@@ -1,5 +1,5 @@ 
 /* Demangler component interface functions.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   Copyright (C) 2004-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@wasabisystems.com>.
 
    This file is part of the libiberty library, which is part of GCC.
@@ -125,6 +125,7 @@  cplus_demangle_fill_component (struct demangle_component *p,
   p->u.s_binary.left = left;
   p->u.s_binary.right = right;
   p->d_printing = 0;
+  p->d_counting = 0;
 
   return 1;
 }
@@ -149,6 +150,7 @@  cplus_demangle_fill_builtin_type (struct demangle_component *p,
 	  p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE;
 	  p->u.s_builtin.type = &cplus_demangle_builtin_types[i];
 	  p->d_printing = 0;
+	  p->d_counting = 0;
 	  return 1;
 	}
     }
@@ -176,6 +178,7 @@  cplus_demangle_fill_operator (struct demangle_component *p,
 	  p->type = DEMANGLE_COMPONENT_OPERATOR;
 	  p->u.s_operator.op = &cplus_demangle_operators[i];
 	  p->d_printing = 0;
+	  p->d_counting = 0;
 	  return 1;
 	}
     }
diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c
index a39e2bf2ed..fb0673d181 100644
--- a/libiberty/cplus-dem.c
+++ b/libiberty/cplus-dem.c
@@ -1,5 +1,5 @@ 
 /* Demangler for GNU C++
-   Copyright (C) 1989-2019 Free Software Foundation, Inc.
+   Copyright (C) 1989-2020 Free Software Foundation, Inc.
    Written by James Clark (jjc@jclark.uucp)
    Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling
    Modified by Satish Pai (pai@apollo.hp.com) for HP demangling
@@ -52,7 +52,6 @@  void * realloc ();
 #define CURRENT_DEMANGLING_STYLE options
 
 #include "libiberty.h"
-#include "rust-demangle.h"
 
 enum demangling_styles current_demangling_style = auto_demangling;
 
@@ -160,27 +159,20 @@  cplus_demangle (const char *mangled, int options)
   if ((options & DMGL_STYLE_MASK) == 0)
     options |= (int) current_demangling_style & DMGL_STYLE_MASK;
 
+  /* The Rust demangling is implemented elsewhere.
+     Legacy Rust symbols overlap with GNU_V3, so try Rust first.  */
+  if (RUST_DEMANGLING || AUTO_DEMANGLING)
+    {
+      ret = rust_demangle (mangled, options);
+      if (ret || RUST_DEMANGLING)
+        return ret;
+    }
+
   /* The V3 ABI demangling is implemented elsewhere.  */
-  if (GNU_V3_DEMANGLING || RUST_DEMANGLING || AUTO_DEMANGLING)
+  if (GNU_V3_DEMANGLING || AUTO_DEMANGLING)
     {
       ret = cplus_demangle_v3 (mangled, options);
-      if (GNU_V3_DEMANGLING)
-	return ret;
-
-      if (ret)
-	{
-	  /* Rust symbols are GNU_V3 mangled plus some extra subtitutions.
-	     The subtitutions are always smaller, so do in place changes.  */
-	  if (rust_is_mangled (ret))
-	    rust_demangle_sym (ret);
-	  else if (RUST_DEMANGLING)
-	    {
-	      free (ret);
-	      ret = NULL;
-	    }
-	}
-
-      if (ret || RUST_DEMANGLING)
+      if (ret || GNU_V3_DEMANGLING)
 	return ret;
     }
 
@@ -204,27 +196,6 @@  cplus_demangle (const char *mangled, int options)
   return (ret);
 }
 
-char *
-rust_demangle (const char *mangled, int options)
-{
-  /* Rust symbols are GNU_V3 mangled plus some extra subtitutions.  */
-  char *ret = cplus_demangle_v3 (mangled, options);
-
-  /* The Rust subtitutions are always smaller, so do in place changes.  */
-  if (ret != NULL)
-    {
-      if (rust_is_mangled (ret))
-	rust_demangle_sym (ret);
-      else
-	{
-	  free (ret);
-	  ret = NULL;
-	}
-    }
-
-  return ret;
-}
-
 /* Demangle ada names.  The encoding is documented in gcc/ada/exp_dbug.ads.  */
 
 char *
diff --git a/libiberty/crc32.c b/libiberty/crc32.c
index 96b12b9b56..8f7832aa2a 100644
--- a/libiberty/crc32.c
+++ b/libiberty/crc32.c
@@ -1,5 +1,5 @@ 
 /* crc32.c
-   Copyright (C) 2009-2019 Free Software Foundation, Inc.
+   Copyright (C) 2009-2020 Free Software Foundation, Inc.
 
    This file is part of the libiberty library.
 
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index becc402c1f..a9702858a6 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1,5 +1,5 @@ 
 /* Demangler for the D programming language
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
    Written by Iain Buclaw (ibuclaw@gdcproject.org)
 
 This file is part of the libiberty library.
diff --git a/libiberty/dwarfnames.c b/libiberty/dwarfnames.c
index c97741e4e3..968d191753 100644
--- a/libiberty/dwarfnames.c
+++ b/libiberty/dwarfnames.c
@@ -1,5 +1,5 @@ 
 /* Names of various DWARF tags.
-   Copyright (C) 2012-2019 Free Software Foundation, Inc.
+   Copyright (C) 2012-2020 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
    
diff --git a/libiberty/dyn-string.c b/libiberty/dyn-string.c
index 441b36bf24..e10f691181 100644
--- a/libiberty/dyn-string.c
+++ b/libiberty/dyn-string.c
@@ -1,5 +1,5 @@ 
 /* An abstract string datatype.
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
 This file is part of GNU CC.
diff --git a/libiberty/fdmatch.c b/libiberty/fdmatch.c
index ff45e41917..31803e47f7 100644
--- a/libiberty/fdmatch.c
+++ b/libiberty/fdmatch.c
@@ -1,5 +1,5 @@ 
 /* Compare two open file descriptors to see if they refer to the same file.
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/fibheap.c b/libiberty/fibheap.c
index 1449e7fd3d..b897228100 100644
--- a/libiberty/fibheap.c
+++ b/libiberty/fibheap.c
@@ -1,5 +1,5 @@ 
 /* A Fibonacci heap datatype.
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
    Contributed by Daniel Berlin (dan@cgsoftware.com).
    
 This file is part of GNU CC.
diff --git a/libiberty/filename_cmp.c b/libiberty/filename_cmp.c
index d111066d39..68fb06f945 100644
--- a/libiberty/filename_cmp.c
+++ b/libiberty/filename_cmp.c
@@ -1,6 +1,6 @@ 
 /* File name comparison routine.
 
-   Copyright (C) 2007-2019 Free Software Foundation, Inc.
+   Copyright (C) 2007-2020 Free Software Foundation, Inc.
 
    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
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index 8632253b4c..2fd5e688ec 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -1,5 +1,5 @@ 
 /* IEEE floating point support routines, for GDB, the GNU Debugger.
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
diff --git a/libiberty/fnmatch.c b/libiberty/fnmatch.c
index 50fe2e8da8..7be51aed03 100644
--- a/libiberty/fnmatch.c
+++ b/libiberty/fnmatch.c
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
 NOTE: This source is derived from an old version taken from the GNU C
 Library (glibc).
diff --git a/libiberty/fopen_unlocked.c b/libiberty/fopen_unlocked.c
index 05efad43eb..b8c426b8ea 100644
--- a/libiberty/fopen_unlocked.c
+++ b/libiberty/fopen_unlocked.c
@@ -1,5 +1,5 @@ 
 /* Implement fopen_unlocked and related functions.
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/gather-docs b/libiberty/gather-docs
index 94a1212fe7..01f1e0bf32 100644
--- a/libiberty/gather-docs
+++ b/libiberty/gather-docs
@@ -1,7 +1,7 @@ 
 #!/usr/bin/perl
 # -*- perl -*-
 
-#   Copyright (C) 2001-2019 Free Software Foundation, Inc.
+#   Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is part of the libiberty library.
 # Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/getopt.c b/libiberty/getopt.c
index 1ad4d505a0..7119b621c1 100644
--- a/libiberty/getopt.c
+++ b/libiberty/getopt.c
@@ -3,7 +3,7 @@ 
    "Keep this file name-space clean" means, talk to drepper@gnu.org
    before changing it!
 
-   Copyright (C) 1987-2019 Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
    NOTE: This source is derived from an old version taken from the GNU C
    Library (glibc).
diff --git a/libiberty/getopt1.c b/libiberty/getopt1.c
index 33e0bda21b..87242472e8 100644
--- a/libiberty/getopt1.c
+++ b/libiberty/getopt1.c
@@ -1,5 +1,5 @@ 
 /* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987-2019 Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
    NOTE: This source is derived from an old version taken from the GNU C
    Library (glibc).
diff --git a/libiberty/getruntime.c b/libiberty/getruntime.c
index 0900a19dfb..f9f7841a74 100644
--- a/libiberty/getruntime.c
+++ b/libiberty/getruntime.c
@@ -1,5 +1,5 @@ 
 /* Return time used so far, in microseconds.
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 9f917c3571..26c98ce2d6 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -1,5 +1,5 @@ 
 /* An expandable hash tables datatype.  
-   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+   Copyright (C) 1999-2020 Free Software Foundation, Inc.
    Contributed by Vladimir Makarov (vmakarov@cygnus.com).
 
 This file is part of the libiberty library.
diff --git a/libiberty/hex.c b/libiberty/hex.c
index 67ce13cdb5..f2b57e3b81 100644
--- a/libiberty/hex.c
+++ b/libiberty/hex.c
@@ -1,5 +1,5 @@ 
 /* Hex character manipulation support.
-   Copyright (C) 1995-2019 Free Software Foundation, Inc.
+   Copyright (C) 1995-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/lbasename.c b/libiberty/lbasename.c
index 7aefbb4936..6715b20858 100644
--- a/libiberty/lbasename.c
+++ b/libiberty/lbasename.c
@@ -1,6 +1,6 @@ 
 /* Libiberty basename.  Like basename, but is not overridden by the
    system C library.
-   Copyright (C) 2001-2019 Free Software Foundation, Inc.
+   Copyright (C) 2001-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/libiberty.texi b/libiberty/libiberty.texi
index bf870d9c62..01751be39d 100644
--- a/libiberty/libiberty.texi
+++ b/libiberty/libiberty.texi
@@ -24,7 +24,7 @@ 
 @ifinfo
 This manual describes the GNU @libib library of utility subroutines.
 
-Copyright @copyright{} 2001-2019 Free Software Foundation, Inc.
+Copyright @copyright{} 2001-2020 Free Software Foundation, Inc.
 
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
@@ -50,7 +50,7 @@  notice identical to this one except for the removal of this paragraph
 
 
 @vskip 0pt plus 1filll
-Copyright @copyright{} 2001-2019 Free Software Foundation, Inc.
+Copyright @copyright{} 2001-2020 Free Software Foundation, Inc.
 
       Permission is granted to copy, distribute and/or modify this document
       under the terms of the GNU Free Documentation License, Version 1.3
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index ac914a7a4f..d6694c4034 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -1,7 +1,7 @@ 
 /* Libiberty realpath.  Like realpath, but more consistent behavior.
    Based on gdb_realpath from GDB.
 
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
 
    This file is part of the libiberty library.
 
@@ -49,9 +49,6 @@  components will be simplified.  The returned value will be allocated using
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
 
 /* On GNU libc systems the declaration is only visible with _GNU_SOURCE.  */
 #if defined(HAVE_CANONICALIZE_FILE_NAME) \
@@ -158,16 +155,3 @@  lrealpath (const char *filename)
   /* This system is a lost cause, just duplicate the filename.  */
   return strdup (filename);
 }
-
-/* Return true when FD file descriptor exists.  */
-
-int
-is_valid_fd (int fd)
-{
-#if defined(_WIN32)
-  HANDLE h = (HANDLE) _get_osfhandle (fd);
-  return h != (HANDLE) -1;
-#else
-  return fcntl (fd, F_GETFD) >= 0;
-#endif
-}
diff --git a/libiberty/maint-tool b/libiberty/maint-tool
index f100dd4a0d..c27c3a4fc8 100644
--- a/libiberty/maint-tool
+++ b/libiberty/maint-tool
@@ -1,7 +1,7 @@ 
 #!/usr/bin/perl
 # -*- perl -*-
 
-#   Copyright (C) 2001-2019 Free Software Foundation, Inc.
+#   Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is part of the libiberty library.
 # Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/make-relative-prefix.c b/libiberty/make-relative-prefix.c
index ec0b0ee749..e3f9f920df 100644
--- a/libiberty/make-relative-prefix.c
+++ b/libiberty/make-relative-prefix.c
@@ -1,5 +1,5 @@ 
 /* Relative (relocatable) prefix support.
-   Copyright (C) 1987-2019 Free Software Foundation, Inc.
+   Copyright (C) 1987-2020 Free Software Foundation, Inc.
 
 This file is part of libiberty.
 
@@ -122,6 +122,9 @@  split_directories (const char *name, int *ptr_num_dirs)
   const char *p, *q;
   int ch;
 
+  if (!*name)
+    return NULL;
+
   /* Count the number of directories.  Special case MSDOS disk names as part
      of the initial directory.  */
   p = name;
diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c
index 2c66e35cc1..cb08c27af6 100644
--- a/libiberty/make-temp-file.c
+++ b/libiberty/make-temp-file.c
@@ -1,5 +1,5 @@ 
 /* Utility to pick a temporary filename prefix.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/md5.c b/libiberty/md5.c
index 54875a3826..755b8ff9f8 100644
--- a/libiberty/md5.c
+++ b/libiberty/md5.c
@@ -1,6 +1,6 @@ 
 /* md5.c - Functions to compute MD5 message digest of files or memory blocks
    according to the definition of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 1995-2019 Free Software Foundation, Inc.
+   Copyright (C) 1995-2020 Free Software Foundation, Inc.
 
    NOTE: This source is derived from an old version taken from the GNU C
    Library (glibc).
diff --git a/libiberty/memmem.c b/libiberty/memmem.c
index e45af443ea..1e26c8bc2a 100644
--- a/libiberty/memmem.c
+++ b/libiberty/memmem.c
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/libiberty/mempcpy.c b/libiberty/mempcpy.c
index 1cc569c690..a65a55703f 100644
--- a/libiberty/mempcpy.c
+++ b/libiberty/mempcpy.c
@@ -1,5 +1,5 @@ 
 /* Implement the mempcpy function.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/mkstemps.c b/libiberty/mkstemps.c
index b57880ef0e..18d879ac87 100644
--- a/libiberty/mkstemps.c
+++ b/libiberty/mkstemps.c
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file is derived from mkstemp.c from the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/objalloc.c b/libiberty/objalloc.c
index f6c65a2f71..131598f37f 100644
--- a/libiberty/objalloc.c
+++ b/libiberty/objalloc.c
@@ -1,5 +1,5 @@ 
 /* objalloc.c -- routines to allocate memory for objects
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
+   Copyright (C) 1997-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Solutions.
 
 This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/obstack.c b/libiberty/obstack.c
index 3e1d160700..0a4e57ee4c 100644
--- a/libiberty/obstack.c
+++ b/libiberty/obstack.c
@@ -1,5 +1,5 @@ 
 /* obstack.c - subroutines used implicitly by object stack macros
-   Copyright (C) 1988-2019 Free Software Foundation, Inc.
+   Copyright (C) 1988-2020 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
diff --git a/libiberty/partition.c b/libiberty/partition.c
index 37011b867e..2e17515f2d 100644
--- a/libiberty/partition.c
+++ b/libiberty/partition.c
@@ -1,5 +1,5 @@ 
 /* List implementation of a partition of consecutive integers.
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
    Contributed by CodeSourcery, LLC.
 
    This file is part of GNU CC.
diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c
index 5f3a9628ed..30cd9040d9 100644
--- a/libiberty/pex-common.c
+++ b/libiberty/pex-common.c
@@ -1,5 +1,5 @@ 
 /* Common code for executing a program in a sub-process.
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@airs.com>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/pex-common.h b/libiberty/pex-common.h
index b5aa87737e..54dd1a1249 100644
--- a/libiberty/pex-common.h
+++ b/libiberty/pex-common.h
@@ -1,6 +1,6 @@ 
 /* Utilities to execute a program in a subprocess (possibly linked by pipes
    with other subprocesses), and wait for it.  Shared logic.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-djgpp.c b/libiberty/pex-djgpp.c
index 847cd15020..35118089b4 100644
--- a/libiberty/pex-djgpp.c
+++ b/libiberty/pex-djgpp.c
@@ -1,6 +1,6 @@ 
 /* Utilities to execute a program in a subprocess (possibly linked by pipes
    with other subprocesses), and wait for it.  DJGPP specialization.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-msdos.c b/libiberty/pex-msdos.c
index c7fa8a325d..67a4733d49 100644
--- a/libiberty/pex-msdos.c
+++ b/libiberty/pex-msdos.c
@@ -1,6 +1,6 @@ 
 /* Utilities to execute a program in a subprocess (possibly linked by pipes
    with other subprocesses), and wait for it.  Generic MSDOS specialization.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-one.c b/libiberty/pex-one.c
index b26da672d1..2dcf6c07ff 100644
--- a/libiberty/pex-one.c
+++ b/libiberty/pex-one.c
@@ -1,5 +1,5 @@ 
 /* Execute a program and wait for a result.
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-unix.c b/libiberty/pex-unix.c
index f9e5277897..684a49ace6 100644
--- a/libiberty/pex-unix.c
+++ b/libiberty/pex-unix.c
@@ -1,7 +1,7 @@ 
 /* Utilities to execute a program in a subprocess (possibly linked by pipes
    with other subprocesses), and wait for it.  Generic Unix version
    (also used for UWIN and VMS).
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index 0c69a25031..331067b507 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -1,6 +1,6 @@ 
 /* Utilities to execute a program in a subprocess (possibly linked by pipes
    with other subprocesses), and wait for it.  Generic Win32 specialization.
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c
index b951d908b2..2dfcdda68d 100644
--- a/libiberty/pexecute.c
+++ b/libiberty/pexecute.c
@@ -1,6 +1,6 @@ 
 /* Utilities to execute a program in a subprocess (possibly linked by pipes
    with other subprocesses), and wait for it.
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   Copyright (C) 2004-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/physmem.c b/libiberty/physmem.c
index e2d393b3cf..f9427168a6 100644
--- a/libiberty/physmem.c
+++ b/libiberty/physmem.c
@@ -1,5 +1,5 @@ 
 /* Calculate the size of physical memory.
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
 
    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
diff --git a/libiberty/putenv.c b/libiberty/putenv.c
index f0f2ca37e2..f3ddf83933 100644
--- a/libiberty/putenv.c
+++ b/libiberty/putenv.c
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 1991-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
    This file based on putenv.c in the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/regex.c b/libiberty/regex.c
index 07b8ac832d..7d2031994f 100644
--- a/libiberty/regex.c
+++ b/libiberty/regex.c
@@ -3,7 +3,7 @@ 
    (Implements POSIX draft P1003.2/D11.2, except for some of the
    internationalization features.)
 
-   Copyright (C) 1993-2019 Free Software Foundation, Inc.
+   Copyright (C) 1993-2020 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
diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c
index 2302db45b6..b87365c85f 100644
--- a/libiberty/rust-demangle.c
+++ b/libiberty/rust-demangle.c
@@ -1,5 +1,5 @@ 
 /* Demangler for the Rust programming language
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
+   Copyright (C) 2016-2020 Free Software Foundation, Inc.
    Written by David Tolnay (dtolnay@gmail.com).
 
 This file is part of the libiberty library.
@@ -33,9 +33,11 @@  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "safe-ctype.h"
 
+#include <inttypes.h>
 #include <sys/types.h>
 #include <string.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -47,303 +49,484 @@  extern void *memset(void *s, int c, size_t n);
 
 #include <demangle.h>
 #include "libiberty.h"
-#include "rust-demangle.h"
 
+struct rust_demangler
+{
+  const char *sym;
+  size_t sym_len;
 
-/* Mangled Rust symbols look like this:
-     _$LT$std..sys..fd..FileDesc$u20$as$u20$core..ops..Drop$GT$::drop::hc68340e1baa4987a
-
-   The original symbol is:
-     <std::sys::fd::FileDesc as core::ops::Drop>::drop
-
-   The last component of the path is a 64-bit hash in lowercase hex,
-   prefixed with "h". Rust does not have a global namespace between
-   crates, an illusion which Rust maintains by using the hash to
-   distinguish things that would otherwise have the same symbol.
-
-   Any path component not starting with a XID_Start character is
-   prefixed with "_".
-
-   The following escape sequences are used:
+  void *callback_opaque;
+  demangle_callbackref callback;
 
-   ","  =>  $C$
-   "@"  =>  $SP$
-   "*"  =>  $BP$
-   "&"  =>  $RF$
-   "<"  =>  $LT$
-   ">"  =>  $GT$
-   "("  =>  $LP$
-   ")"  =>  $RP$
-   " "  =>  $u20$
-   "\"" =>  $u22$
-   "'"  =>  $u27$
-   "+"  =>  $u2b$
-   ";"  =>  $u3b$
-   "["  =>  $u5b$
-   "]"  =>  $u5d$
-   "{"  =>  $u7b$
-   "}"  =>  $u7d$
-   "~"  =>  $u7e$
+  /* Position of the next character to read from the symbol. */
+  size_t next;
 
-   A double ".." means "::" and a single "." means "-".
+  /* Non-zero if any error occurred. */
+  int errored;
 
-   The only characters allowed in the mangled symbol are a-zA-Z0-9 and _.:$  */
+  /* Non-zero if printing should be verbose (e.g. include hashes). */
+  int verbose;
 
-static const char *hash_prefix = "::h";
-static const size_t hash_prefix_len = 3;
-static const size_t hash_len = 16;
+  /* Rust mangling version, with legacy mangling being -1. */
+  int version;
+};
 
-static int is_prefixed_hash (const char *start);
-static int looks_like_rust (const char *sym, size_t len);
-static int unescape (const char **in, char **out, const char *seq, char value);
+/* Parsing functions. */
 
-/* INPUT: sym: symbol that has been through C++ (gnu v3) demangling
+static char
+peek (const struct rust_demangler *rdm)
+{
+  if (rdm->next < rdm->sym_len)
+    return rdm->sym[rdm->next];
+  return 0;
+}
 
-   This function looks for the following indicators:
+static char
+next (struct rust_demangler *rdm)
+{
+  char c = peek (rdm);
+  if (!c)
+    rdm->errored = 1;
+  else
+    rdm->next++;
+  return c;
+}
 
-   1. The hash must consist of "h" followed by 16 lowercase hex digits.
+struct rust_mangled_ident
+{
+  /* ASCII part of the identifier. */
+  const char *ascii;
+  size_t ascii_len;
+};
 
-   2. As a sanity check, the hash must use between 5 and 15 of the 16
-      possible hex digits. This is true of 99.9998% of hashes so once
-      in your life you may see a false negative. The point is to
-      notice path components that could be Rust hashes but are
-      probably not, like "haaaaaaaaaaaaaaaa". In this case a false
-      positive (non-Rust symbol has an important path component
-      removed because it looks like a Rust hash) is worse than a false
-      negative (the rare Rust symbol is not demangled) so this sets
-      the balance in favor of false negatives.
+static struct rust_mangled_ident
+parse_ident (struct rust_demangler *rdm)
+{
+  char c;
+  size_t start, len;
+  struct rust_mangled_ident ident;
+
+  ident.ascii = NULL;
+  ident.ascii_len = 0;
+
+  c = next (rdm);
+  if (!ISDIGIT (c))
+    {
+      rdm->errored = 1;
+      return ident;
+    }
+  len = c - '0';
+
+  if (c != '0')
+    while (ISDIGIT (peek (rdm)))
+      len = len * 10 + (next (rdm) - '0');
+
+  start = rdm->next;
+  rdm->next += len;
+  /* Check for overflows. */
+  if ((start > rdm->next) || (rdm->next > rdm->sym_len))
+    {
+      rdm->errored = 1;
+      return ident;
+    }
+
+  ident.ascii = rdm->sym + start;
+  ident.ascii_len = len;
+
+  if (ident.ascii_len == 0)
+    ident.ascii = NULL;
+
+  return ident;
+}
 
-   3. There must be no characters other than a-zA-Z0-9 and _.:$
+/* Printing functions. */
 
-   4. There must be no unrecognized $-sign sequences.
+static void
+print_str (struct rust_demangler *rdm, const char *data, size_t len)
+{
+  if (!rdm->errored)
+    rdm->callback (data, len, rdm->callback_opaque);
+}
 
-   5. There must be no sequence of three or more dots in a row ("...").  */
+#define PRINT(s) print_str (rdm, s, strlen (s))
 
-int
-rust_is_mangled (const char *sym)
+/* Return a 0x0-0xf value if the char is 0-9a-f, and -1 otherwise. */
+static int
+decode_lower_hex_nibble (char nibble)
 {
-  size_t len, len_without_hash;
+  if ('0' <= nibble && nibble <= '9')
+    return nibble - '0';
+  if ('a' <= nibble && nibble <= 'f')
+    return 0xa + (nibble - 'a');
+  return -1;
+}
 
-  if (!sym)
-    return 0;
+/* Return the unescaped character for a "$...$" escape, or 0 if invalid. */
+static char
+decode_legacy_escape (const char *e, size_t len, size_t *out_len)
+{
+  char c = 0;
+  size_t escape_len = 0;
+  int lo_nibble = -1, hi_nibble = -1;
 
-  len = strlen (sym);
-  if (len <= hash_prefix_len + hash_len)
-    /* Not long enough to contain "::h" + hash + something else */
+  if (len < 3 || e[0] != '$')
     return 0;
 
-  len_without_hash = len - (hash_prefix_len + hash_len);
-  if (!is_prefixed_hash (sym + len_without_hash))
+  e++;
+  len--;
+
+  if (e[0] == 'C')
+    {
+      escape_len = 1;
+
+      c = ',';
+    }
+  else if (len > 2)
+    {
+      escape_len = 2;
+
+      if (e[0] == 'S' && e[1] == 'P')
+        c = '@';
+      else if (e[0] == 'B' && e[1] == 'P')
+        c = '*';
+      else if (e[0] == 'R' && e[1] == 'F')
+        c = '&';
+      else if (e[0] == 'L' && e[1] == 'T')
+        c = '<';
+      else if (e[0] == 'G' && e[1] == 'T')
+        c = '>';
+      else if (e[0] == 'L' && e[1] == 'P')
+        c = '(';
+      else if (e[0] == 'R' && e[1] == 'P')
+        c = ')';
+      else if (e[0] == 'u' && len > 3)
+        {
+          escape_len = 3;
+
+          hi_nibble = decode_lower_hex_nibble (e[1]);
+          if (hi_nibble < 0)
+            return 0;
+          lo_nibble = decode_lower_hex_nibble (e[2]);
+          if (lo_nibble < 0)
+            return 0;
+
+          /* Only allow non-control ASCII characters. */
+          if (hi_nibble > 7)
+            return 0;
+          c = (hi_nibble << 4) | lo_nibble;
+          if (c < 0x20)
+            return 0;
+        }
+    }
+
+  if (!c || len <= escape_len || e[escape_len] != '$')
     return 0;
 
-  return looks_like_rust (sym, len_without_hash);
+  *out_len = 2 + escape_len;
+  return c;
 }
 
-/* A hash is the prefix "::h" followed by 16 lowercase hex digits. The
-   hex digits must comprise between 5 and 15 (inclusive) distinct
-   digits.  */
+static void
+print_ident (struct rust_demangler *rdm, struct rust_mangled_ident ident)
+{
+  char unescaped;
+  size_t len;
 
+  if (rdm->errored)
+    return;
+
+  if (rdm->version == -1)
+    {
+      /* Ignore leading underscores preceding escape sequences.
+         The mangler inserts an underscore to make sure the
+         identifier begins with a XID_Start character. */
+      if (ident.ascii_len >= 2 && ident.ascii[0] == '_'
+          && ident.ascii[1] == '$')
+        {
+          ident.ascii++;
+          ident.ascii_len--;
+        }
+
+      while (ident.ascii_len > 0)
+        {
+          /* Handle legacy escape sequences ("$...$", ".." or "."). */
+          if (ident.ascii[0] == '$')
+            {
+              unescaped
+                  = decode_legacy_escape (ident.ascii, ident.ascii_len, &len);
+              if (unescaped)
+                print_str (rdm, &unescaped, 1);
+              else
+                {
+                  /* Unexpected escape sequence, print the rest verbatim. */
+                  print_str (rdm, ident.ascii, ident.ascii_len);
+                  return;
+                }
+            }
+          else if (ident.ascii[0] == '.')
+            {
+              if (ident.ascii_len >= 2 && ident.ascii[1] == '.')
+                {
+                  /* ".." becomes "::" */
+                  PRINT ("::");
+                  len = 2;
+                }
+              else
+                {
+                  /* "." becomes "-" */
+                  PRINT ("-");
+                  len = 1;
+                }
+            }
+          else
+            {
+              /* Print everything before the next escape sequence, at once. */
+              for (len = 0; len < ident.ascii_len; len++)
+                if (ident.ascii[len] == '$' || ident.ascii[len] == '.')
+                  break;
+
+              print_str (rdm, ident.ascii, len);
+            }
+
+          ident.ascii += len;
+          ident.ascii_len -= len;
+        }
+
+      return;
+    }
+}
+
+/* A legacy hash is the prefix "h" followed by 16 lowercase hex digits.
+   The hex digits must contain at least 5 distinct digits. */
 static int
-is_prefixed_hash (const char *str)
+is_legacy_prefixed_hash (struct rust_mangled_ident ident)
 {
-  const char *end;
-  char seen[16];
-  size_t i;
-  int count;
+  uint16_t seen;
+  int nibble;
+  size_t i, count;
 
-  if (strncmp (str, hash_prefix, hash_prefix_len))
+  if (ident.ascii_len != 17 || ident.ascii[0] != 'h')
     return 0;
-  str += hash_prefix_len;
-
-  memset (seen, 0, sizeof(seen));
-  for (end = str + hash_len; str < end; str++)
-    if (*str >= '0' && *str <= '9')
-      seen[*str - '0'] = 1;
-    else if (*str >= 'a' && *str <= 'f')
-      seen[*str - 'a' + 10] = 1;
-    else
-      return 0;
 
-  /* Count how many distinct digits seen */
-  count = 0;
+  seen = 0;
   for (i = 0; i < 16; i++)
-    if (seen[i])
-      count++;
-
-  return count >= 5 && count <= 15;
+    {
+      nibble = decode_lower_hex_nibble (ident.ascii[1 + i]);
+      if (nibble < 0)
+        return 0;
+      seen |= (uint16_t)1 << nibble;
+    }
+
+  /* Count how many distinct digits were seen. */
+  count = 0;
+  while (seen)
+    {
+      if (seen & 1)
+        count++;
+      seen >>= 1;
+    }
+
+  return count >= 5;
 }
 
-static int
-looks_like_rust (const char *str, size_t len)
+int
+rust_demangle_callback (const char *mangled, int options,
+                        demangle_callbackref callback, void *opaque)
 {
-  const char *end = str + len;
-
-  while (str < end)
-    switch (*str)
-      {
-      case '$':
-	if (!strncmp (str, "$C$", 3))
-	  str += 3;
-	else if (!strncmp (str, "$SP$", 4)
-		 || !strncmp (str, "$BP$", 4)
-		 || !strncmp (str, "$RF$", 4)
-		 || !strncmp (str, "$LT$", 4)
-		 || !strncmp (str, "$GT$", 4)
-		 || !strncmp (str, "$LP$", 4)
-		 || !strncmp (str, "$RP$", 4))
-	  str += 4;
-	else if (!strncmp (str, "$u20$", 5)
-		 || !strncmp (str, "$u22$", 5)
-		 || !strncmp (str, "$u27$", 5)
-		 || !strncmp (str, "$u2b$", 5)
-		 || !strncmp (str, "$u3b$", 5)
-		 || !strncmp (str, "$u5b$", 5)
-		 || !strncmp (str, "$u5d$", 5)
-		 || !strncmp (str, "$u7b$", 5)
-		 || !strncmp (str, "$u7d$", 5)
-		 || !strncmp (str, "$u7e$", 5))
-	  str += 5;
-	else
-	  return 0;
-	break;
-      case '.':
-	/* Do not allow three or more consecutive dots */
-	if (!strncmp (str, "...", 3))
-	  return 0;
-	/* Fall through */
-      case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
-      case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
-      case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
-      case 's': case 't': case 'u': case 'v': case 'w': case 'x':
-      case 'y': case 'z':
-      case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
-      case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
-      case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
-      case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
-      case 'Y': case 'Z':
-      case '0': case '1': case '2': case '3': case '4': case '5':
-      case '6': case '7': case '8': case '9':
-      case '_':
-      case ':':
-	str++;
-	break;
-      default:
-	return 0;
-      }
-
-  return 1;
-}
+  const char *p;
+  struct rust_demangler rdm;
+  struct rust_mangled_ident ident;
+
+  rdm.sym = mangled;
+  rdm.sym_len = 0;
+
+  rdm.callback_opaque = opaque;
+  rdm.callback = callback;
+
+  rdm.next = 0;
+  rdm.errored = 0;
+  rdm.verbose = (options & DMGL_VERBOSE) != 0;
+  rdm.version = 0;
+
+  /* Rust symbols always start with _ZN (legacy). */
+  if (rdm.sym[0] == '_' && rdm.sym[1] == 'Z' && rdm.sym[2] == 'N')
+    {
+      rdm.sym += 3;
+      rdm.version = -1;
+    }
+  else
+    return 0;
+
+  /* Legacy Rust symbols use only [_0-9a-zA-Z.:$] characters. */
+  for (p = rdm.sym; *p; p++)
+    {
+      rdm.sym_len++;
 
-/*
-  INPUT: sym: symbol for which rust_is_mangled(sym) returned 1.
+      if (*p == '_' || ISALNUM (*p))
+        continue;
 
-  The input is demangled in-place because the mangled name is always
-  longer than the demangled one.  */
+      if (rdm.version == -1 && (*p == '$' || *p == '.' || *p == ':'))
+        continue;
 
-void
-rust_demangle_sym (char *sym)
+      return 0;
+    }
+
+  /* Legacy Rust symbols need to be handled separately. */
+  if (rdm.version == -1)
+    {
+      /* Legacy Rust symbols always end with E. */
+      if (!(rdm.sym_len > 0 && rdm.sym[rdm.sym_len - 1] == 'E'))
+        return 0;
+      rdm.sym_len--;
+
+      /* Legacy Rust symbols also always end with a path segment
+         that encodes a 16 hex digit hash, i.e. '17h[a-f0-9]{16}'.
+         This early check, before any parse_ident calls, should
+         quickly filter out most C++ symbols unrelated to Rust. */
+      if (!(rdm.sym_len > 19
+            && !memcmp (&rdm.sym[rdm.sym_len - 19], "17h", 3)))
+        return 0;
+
+      do
+        {
+          ident = parse_ident (&rdm);
+          if (rdm.errored || !ident.ascii)
+            return 0;
+        }
+      while (rdm.next < rdm.sym_len);
+
+      /* The last path segment should be the hash. */
+      if (!is_legacy_prefixed_hash (ident))
+        return 0;
+
+      /* Reset the state for a second pass, to print the symbol. */
+      rdm.next = 0;
+      if (!rdm.verbose && rdm.sym_len > 19)
+        {
+          /* Hide the last segment, containing the hash, if not verbose. */
+          rdm.sym_len -= 19;
+        }
+
+      do
+        {
+          if (rdm.next > 0)
+            print_str (&rdm, "::", 2);
+
+          ident = parse_ident (&rdm);
+          print_ident (&rdm, ident);
+        }
+      while (rdm.next < rdm.sym_len);
+    }
+  else
+    return 0;
+
+  return !rdm.errored;
+}
+
+/* Growable string buffers. */
+struct str_buf
+{
+  char *ptr;
+  size_t len;
+  size_t cap;
+  int errored;
+};
+
+static void
+str_buf_reserve (struct str_buf *buf, size_t extra)
 {
-  const char *in;
-  char *out;
-  const char *end;
+  size_t available, min_new_cap, new_cap;
+  char *new_ptr;
 
-  if (!sym)
+  /* Allocation failed before. */
+  if (buf->errored)
     return;
 
-  in = sym;
-  out = sym;
-  end = sym + strlen (sym) - (hash_prefix_len + hash_len);
-
-  while (in < end)
-    switch (*in)
-      {
-      case '$':
-	if (!(unescape (&in, &out, "$C$", ',')
-	      || unescape (&in, &out, "$SP$", '@')
-	      || unescape (&in, &out, "$BP$", '*')
-	      || unescape (&in, &out, "$RF$", '&')
-	      || unescape (&in, &out, "$LT$", '<')
-	      || unescape (&in, &out, "$GT$", '>')
-	      || unescape (&in, &out, "$LP$", '(')
-	      || unescape (&in, &out, "$RP$", ')')
-	      || unescape (&in, &out, "$u20$", ' ')
-	      || unescape (&in, &out, "$u22$", '\"')
-	      || unescape (&in, &out, "$u27$", '\'')
-	      || unescape (&in, &out, "$u2b$", '+')
-	      || unescape (&in, &out, "$u3b$", ';')
-	      || unescape (&in, &out, "$u5b$", '[')
-	      || unescape (&in, &out, "$u5d$", ']')
-	      || unescape (&in, &out, "$u7b$", '{')
-	      || unescape (&in, &out, "$u7d$", '}')
-	      || unescape (&in, &out, "$u7e$", '~'))) {
-	  /* unexpected escape sequence, not looks_like_rust. */
-	  goto fail;
-	}
-	break;
-      case '_':
-	/* If this is the start of a path component and the next
-	   character is an escape sequence, ignore the underscore. The
-	   mangler inserts an underscore to make sure the path
-	   component begins with a XID_Start character. */
-	if ((in == sym || in[-1] == ':') && in[1] == '$')
-	  in++;
-	else
-	  *out++ = *in++;
-	break;
-      case '.':
-	if (in[1] == '.')
-	  {
-	    /* ".." becomes "::" */
-	    *out++ = ':';
-	    *out++ = ':';
-	    in += 2;
-	  }
-	else
-	  {
-	    /* "." becomes "-" */
-	    *out++ = '-';
-	    in++;
-	  }
-	break;
-      case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
-      case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
-      case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
-      case 's': case 't': case 'u': case 'v': case 'w': case 'x':
-      case 'y': case 'z':
-      case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
-      case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
-      case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
-      case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
-      case 'Y': case 'Z':
-      case '0': case '1': case '2': case '3': case '4': case '5':
-      case '6': case '7': case '8': case '9':
-      case ':':
-	*out++ = *in++;
-	break;
-      default:
-	/* unexpected character in symbol, not looks_like_rust.  */
-	goto fail;
-      }
-  goto done;
-
-fail:
-  *out++ = '?'; /* This is pretty lame, but it's hard to do better. */
-done:
-  *out = '\0';
+  available = buf->cap - buf->len;
+
+  if (extra <= available)
+    return;
+
+  min_new_cap = buf->cap + (extra - available);
+
+  /* Check for overflows. */
+  if (min_new_cap < buf->cap)
+    {
+      buf->errored = 1;
+      return;
+    }
+
+  new_cap = buf->cap;
+
+  if (new_cap == 0)
+    new_cap = 4;
+
+  /* Double capacity until sufficiently large. */
+  while (new_cap < min_new_cap)
+    {
+      new_cap *= 2;
+
+      /* Check for overflows. */
+      if (new_cap < buf->cap)
+        {
+          buf->errored = 1;
+          return;
+        }
+    }
+
+  new_ptr = (char *)realloc (buf->ptr, new_cap);
+  if (new_ptr == NULL)
+    {
+      free (buf->ptr);
+      buf->ptr = NULL;
+      buf->len = 0;
+      buf->cap = 0;
+      buf->errored = 1;
+    }
+  else
+    {
+      buf->ptr = new_ptr;
+      buf->cap = new_cap;
+    }
 }
 
-static int
-unescape (const char **in, char **out, const char *seq, char value)
+static void
+str_buf_append (struct str_buf *buf, const char *data, size_t len)
 {
-  size_t len = strlen (seq);
+  str_buf_reserve (buf, len);
+  if (buf->errored)
+    return;
 
-  if (strncmp (*in, seq, len))
-    return 0;
+  memcpy (buf->ptr + buf->len, data, len);
+  buf->len += len;
+}
+
+static void
+str_buf_demangle_callback (const char *data, size_t len, void *opaque)
+{
+  str_buf_append ((struct str_buf *)opaque, data, len);
+}
+
+char *
+rust_demangle (const char *mangled, int options)
+{
+  struct str_buf out;
+  int success;
+
+  out.ptr = NULL;
+  out.len = 0;
+  out.cap = 0;
+  out.errored = 0;
 
-  **out = value;
+  success = rust_demangle_callback (mangled, options,
+                                    str_buf_demangle_callback, &out);
 
-  *in += len;
-  *out += 1;
+  if (!success)
+    {
+      free (out.ptr);
+      return NULL;
+    }
 
-  return 1;
+  str_buf_append (&out, "\0", 1);
+  return out.ptr;
 }
diff --git a/libiberty/safe-ctype.c b/libiberty/safe-ctype.c
index 1877898ccc..56364e6ecd 100644
--- a/libiberty/safe-ctype.c
+++ b/libiberty/safe-ctype.c
@@ -1,6 +1,6 @@ 
 /* <ctype.h> replacement macros.
 
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
    Contributed by Zack Weinberg <zackw@stanford.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/setenv.c b/libiberty/setenv.c
index 2ceabe1317..82bf1b8360 100644
--- a/libiberty/setenv.c
+++ b/libiberty/setenv.c
@@ -1,4 +1,4 @@ 
-/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
    This file based on setenv.c in the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
diff --git a/libiberty/setproctitle.c b/libiberty/setproctitle.c
index 1d3fafbf0a..3de50f6759 100644
--- a/libiberty/setproctitle.c
+++ b/libiberty/setproctitle.c
@@ -1,5 +1,5 @@ 
 /* Set the title of a process.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/sha1.c b/libiberty/sha1.c
index f56f803ba2..af08219b1b 100644
--- a/libiberty/sha1.c
+++ b/libiberty/sha1.c
@@ -1,7 +1,7 @@ 
 /* sha1.c - Functions to compute SHA1 message digest of files or
    memory blocks according to the NIST specification FIPS-180-1.
 
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
 
    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
diff --git a/libiberty/simple-object-coff.c b/libiberty/simple-object-coff.c
index f299f5afbb..104cd560f6 100644
--- a/libiberty/simple-object-coff.c
+++ b/libiberty/simple-object-coff.c
@@ -1,5 +1,5 @@ 
 /* simple-object-coff.c -- routines to manipulate COFF object files.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/simple-object-common.h b/libiberty/simple-object-common.h
index ddcefc4ee0..2e3f187346 100644
--- a/libiberty/simple-object-common.h
+++ b/libiberty/simple-object-common.h
@@ -1,5 +1,5 @@ 
 /* simple-object-common.h -- common structs for object file manipulation.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/simple-object-elf.c b/libiberty/simple-object-elf.c
index 7515926659..c62d5bba55 100644
--- a/libiberty/simple-object-elf.c
+++ b/libiberty/simple-object-elf.c
@@ -1,5 +1,5 @@ 
 /* simple-object-elf.c -- routines to manipulate ELF object files.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 This program is free software; you can redistribute it and/or modify it
@@ -1366,30 +1366,17 @@  simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
 	  return errmsg;
 	}
 
-      /* If we are processing .symtab purge __gnu_lto_slim symbol
-	 from it and any symbols in discarded sections.  */
+      /* If we are processing .symtab purge any symbols
+	 in discarded sections.  */
       if (sh_type == SHT_SYMTAB)
 	{
 	  unsigned entsize = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
 					      shdr, sh_entsize, Elf_Addr);
 	  unsigned strtab = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
 					     shdr, sh_link, Elf_Word);
-	  unsigned char *strshdr = shdrs + (strtab - 1) * shdr_size;
-	  off_t stroff = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
-					  strshdr, sh_offset, Elf_Addr);
-	  size_t strsz = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
-					  strshdr, sh_size, Elf_Addr);
-	  char *strings = XNEWVEC (char, strsz);
-	  char *gnu_lto = strings;
+	  size_t prevailing_name_idx = 0;
 	  unsigned char *ent;
 	  unsigned *shndx_table = NULL;
-	  simple_object_internal_read (sobj->descriptor,
-				       sobj->offset + stroff,
-				       (unsigned char *)strings,
-				       strsz, &errmsg, err);
-	  /* Find first '\0' in strings.  */
-	  gnu_lto = (char *) memchr (gnu_lto + 1, '\0',
-				     strings + strsz - gnu_lto);
 	  /* Read the section index table if present.  */
 	  if (symtab_indices_shndx[i - 1] != 0)
 	    {
@@ -1404,6 +1391,45 @@  simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
 					   (unsigned char *)shndx_table,
 					   sidxsz, &errmsg, err);
 	    }
+
+	  /* Find a WEAK HIDDEN symbol which name we will use for removed
+	     symbols.  We know there's a prevailing weak hidden symbol
+	     at the start of the .debug_info section.  */
+	  for (ent = buf; ent < buf + length; ent += entsize)
+	    {
+	      unsigned st_shndx = ELF_FETCH_FIELD (type_functions, ei_class,
+						   Sym, ent,
+						   st_shndx, Elf_Half);
+	      unsigned char *st_info;
+	      unsigned char *st_other;
+	      if (ei_class == ELFCLASS32)
+		{
+		  st_info = &((Elf32_External_Sym *)ent)->st_info;
+		  st_other = &((Elf32_External_Sym *)ent)->st_other;
+		}
+	      else
+		{
+		  st_info = &((Elf64_External_Sym *)ent)->st_info;
+		  st_other = &((Elf64_External_Sym *)ent)->st_other;
+		}
+	      if (st_shndx == SHN_XINDEX)
+		st_shndx = type_functions->fetch_Elf_Word
+		    ((unsigned char *)(shndx_table + (ent - buf) / entsize));
+
+	      if (st_shndx != SHN_COMMON
+		  && !(st_shndx != SHN_UNDEF
+		       && st_shndx < shnum
+		       && pfnret[st_shndx - 1] == -1)
+		  && ELF_ST_BIND (*st_info) == STB_WEAK
+		  && *st_other == STV_HIDDEN)
+		{
+		  prevailing_name_idx = ELF_FETCH_FIELD (type_functions,
+							 ei_class, Sym, ent,
+							 st_name, Elf_Word);
+		  break;
+		}
+	    }
+
 	  for (ent = buf; ent < buf + length; ent += entsize)
 	    {
 	      unsigned st_shndx = ELF_FETCH_FIELD (type_functions, ei_class,
@@ -1426,9 +1452,10 @@  simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
 	      if (st_shndx == SHN_XINDEX)
 		st_shndx = type_functions->fetch_Elf_Word
 		    ((unsigned char *)(shndx_table + (ent - buf) / entsize));
-	      /* Eliminate all COMMONs - this includes __gnu_lto_v1
-		 and __gnu_lto_slim which otherwise cause endless
-		 LTO plugin invocation.  */
+	      /* Eliminate all COMMONs - this includes __gnu_lto_slim
+		 which otherwise cause endless LTO plugin invocation.
+		 FIXME: remove the condition once we remove emission
+		 of __gnu_lto_slim symbol.  */
 	      if (st_shndx == SHN_COMMON)
 		discard = 1;
 	      /* We also need to remove symbols refering to sections
@@ -1460,12 +1487,13 @@  simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
 		  else
 		    {
 		      /* Make discarded global symbols hidden weak
-			 undefined and sharing the gnu_lto_ name.  */
+			 undefined and sharing a name of a prevailing
+			 symbol.  */
 		      bind = STB_WEAK;
 		      other = STV_HIDDEN;
 		      ELF_SET_FIELD (type_functions, ei_class, Sym,
 				     ent, st_name, Elf_Word,
-				     gnu_lto - strings);
+				     prevailing_name_idx);
 		      ELF_SET_FIELD (type_functions, ei_class, Sym,
 				     ent, st_shndx, Elf_Half, SHN_UNDEF);
 		    }
@@ -1482,7 +1510,6 @@  simple_object_elf_copy_lto_debug_sections (simple_object_read *sobj,
 		ELF_SET_FIELD (type_functions, ei_class, Sym,
 			       ent, st_shndx, Elf_Half, sh_map[st_shndx]);
 	    }
-	  XDELETEVEC (strings);
 	  XDELETEVEC (shndx_table);
 	}
       else if (sh_type == SHT_GROUP)
diff --git a/libiberty/simple-object-mach-o.c b/libiberty/simple-object-mach-o.c
index 03283a0e3d..14f5342864 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 (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/simple-object-xcoff.c b/libiberty/simple-object-xcoff.c
index 60676567e8..d874de258f 100644
--- a/libiberty/simple-object-xcoff.c
+++ b/libiberty/simple-object-xcoff.c
@@ -1,5 +1,5 @@ 
 /* simple-object-coff.c -- routines to manipulate XCOFF object files.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
+   Copyright (C) 2013-2020 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
diff --git a/libiberty/simple-object.c b/libiberty/simple-object.c
index b00c265128..d9c648af71 100644
--- a/libiberty/simple-object.c
+++ b/libiberty/simple-object.c
@@ -1,5 +1,5 @@ 
 /* simple-object.c -- simple routines to read and write object files.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
+   Copyright (C) 2010-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Google.
 
 This program is free software; you can redistribute it and/or modify it
diff --git a/libiberty/snprintf.c b/libiberty/snprintf.c
index a6feccf020..2ab931e60b 100644
--- a/libiberty/snprintf.c
+++ b/libiberty/snprintf.c
@@ -1,5 +1,5 @@ 
 /* Implement the snprintf function.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 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
diff --git a/libiberty/sort.c b/libiberty/sort.c
index 0267fdb230..fd8f926a8d 100644
--- a/libiberty/sort.c
+++ b/libiberty/sort.c
@@ -1,5 +1,5 @@ 
 /* Sorting algorithms.
-   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
    Contributed by Mark Mitchell <mark@codesourcery.com>.
 
 This file is part of GNU CC.
diff --git a/libiberty/spaces.c b/libiberty/spaces.c
index 6e35d2237f..d97390b2dd 100644
--- a/libiberty/spaces.c
+++ b/libiberty/spaces.c
@@ -1,5 +1,5 @@ 
 /* Allocate memory region filled with spaces.
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/splay-tree.c b/libiberty/splay-tree.c
index 4bbb39a62c..3b7b810388 100644
--- a/libiberty/splay-tree.c
+++ b/libiberty/splay-tree.c
@@ -1,5 +1,5 @@ 
 /* A splay-tree datatype.  
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
    Contributed by Mark Mitchell (mark@markmitchell.com).
 
 This file is part of GNU CC.
diff --git a/libiberty/stack-limit.c b/libiberty/stack-limit.c
index aabe016e7a..390adf32a4 100644
--- a/libiberty/stack-limit.c
+++ b/libiberty/stack-limit.c
@@ -1,5 +1,5 @@ 
 /* Increase stack size limit if possible.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
+   Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
diff --git a/libiberty/stpcpy.c b/libiberty/stpcpy.c
index ee44a7bdd2..2b0a850637 100644
--- a/libiberty/stpcpy.c
+++ b/libiberty/stpcpy.c
@@ -1,5 +1,5 @@ 
 /* Implement the stpcpy function.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/stpncpy.c b/libiberty/stpncpy.c
index 47e0276c7e..641b8f9cf9 100644
--- a/libiberty/stpncpy.c
+++ b/libiberty/stpncpy.c
@@ -1,5 +1,5 @@ 
 /* Implement the stpncpy function.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/strndup.c b/libiberty/strndup.c
index 88c3332e81..a7ff3a9bbf 100644
--- a/libiberty/strndup.c
+++ b/libiberty/strndup.c
@@ -1,5 +1,5 @@ 
 /* Implement the strndup function.
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/strtod.c b/libiberty/strtod.c
index 7bb11d286a..de8c54cdfe 100644
--- a/libiberty/strtod.c
+++ b/libiberty/strtod.c
@@ -1,5 +1,5 @@ 
 /* Implementation of strtod for systems with atof.
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
diff --git a/libiberty/strverscmp.c b/libiberty/strverscmp.c
index 19cf4aeab2..c31734675f 100644
--- a/libiberty/strverscmp.c
+++ b/libiberty/strverscmp.c
@@ -1,5 +1,5 @@ 
 /* Compare strings while treating digits characters numerically.
-   Copyright (C) 1997-2019 Free Software Foundation, Inc.
+   Copyright (C) 1997-2020 Free Software Foundation, Inc.
    This file is part of the libiberty library.
    Contributed by Jean-Fran├žois Bignolles <bignolle@ecoledoc.ibp.fr>, 1997.
 
diff --git a/libiberty/testsuite/Makefile.in b/libiberty/testsuite/Makefile.in
index 6b6b970fe0..1f05557a15 100644
--- a/libiberty/testsuite/Makefile.in
+++ b/libiberty/testsuite/Makefile.in
@@ -1,6 +1,6 @@ 
 #
 # Makefile
-#   Copyright (C) 1999-2019 Free Software Foundation, Inc.
+#   Copyright (C) 1999-2020 Free Software Foundation, Inc.
 #
 # This file is part of the libiberty library.
 # Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index f21ed00e55..5878d96dee 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -1278,7 +1278,7 @@  int& int_if_addable<Y>(A<sizeof ((*((Y*)(0)))+(*((Y*)(0))))>*)
 #
 --format=gnu-v3
 _Z3bazIiEvP1AIXszcl3foocvT__ELCf00000000_00000000EEEE
-void baz<int>(A<sizeof (foo((int)(), (floatcomplex )00000000_00000000))>*)
+void baz<int>(A<sizeof (foo((int)(), (float _Complex)00000000_00000000))>*)
 #
 --format=gnu-v3
 _Z3fooI1FEN1XIXszdtcl1PclcvT__EEE5arrayEE4TypeEv
@@ -1446,3 +1446,7 @@  Foo<int>()::X::fn
 _ZZZ3FooIiEfvENKUlT_E_clIcEEDaS0_EN1X2fnEv
 Foo<int>()::{lambda(auto:1)#1}::operator()<char>(char) const::X::fn()
 Foo<int>()::{lambda(auto:1)#1}::operator()<char>(char) const::X::fn
+#PR91979 demangling nullptr expression
+
+_Z3fooILPv0EEvPN9enable_ifIXeqT_LDnEEvE4typeE
+void foo<(void*)0>(enable_if<((void*)0)==((decltype(nullptr))), void>::type*)
diff --git a/libiberty/testsuite/demangler-fuzzer.c b/libiberty/testsuite/demangler-fuzzer.c
index c291e6c12e..9e35caa142 100644
--- a/libiberty/testsuite/demangler-fuzzer.c
+++ b/libiberty/testsuite/demangler-fuzzer.c
@@ -1,6 +1,6 @@ 
 /* Demangler fuzzer.
 
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
 
    This file is part of GNU libiberty.
 
diff --git a/libiberty/testsuite/rust-demangle-expected b/libiberty/testsuite/rust-demangle-expected
index 0b4288fc37..7477479473 100644
--- a/libiberty/testsuite/rust-demangle-expected
+++ b/libiberty/testsuite/rust-demangle-expected
@@ -41,7 +41,7 @@  main::main::he714a2e23ed7db2g
 # $XX$ substitutions should not contain just numbers.
 --format=auto
 _ZN4main4$99$17he714a2e23ed7db23E
-main::$99$::he714a2e23ed7db23
+main::$99$
 # _ at start of path should be removed.
 # ".." translates to "::" "$GT$" to ">" and "$LT$" to "<".
 --format=rust
@@ -159,3 +159,7 @@  _ZN68_$LT$core..nonzero..NonZero$LT$T$GT$$u20$as$u20$core..ops..Deref$GT$5deref1
 --format=rust
 _ZN63_$LT$core..ptr..Unique$LT$T$GT$$u20$as$u20$core..ops..Deref$GT$5deref17h19f2ad4920655e85E
 <core::ptr::Unique<T> as core::ops::Deref>::deref
+#
+--format=rust
+_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h059a991a004536adE
+issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo
diff --git a/libiberty/testsuite/test-demangle.c b/libiberty/testsuite/test-demangle.c
index 9943b1cc72..eb3bcbde60 100644
--- a/libiberty/testsuite/test-demangle.c
+++ b/libiberty/testsuite/test-demangle.c
@@ -1,5 +1,5 @@ 
 /* Demangler test program,
-   Copyright (C) 2002-2019 Free Software Foundation, Inc.
+   Copyright (C) 2002-2020 Free Software Foundation, Inc.
    Written by Zack Weinberg <zack@codesourcery.com
 
    This file is part of GNU libiberty.
diff --git a/libiberty/testsuite/test-expandargv.c b/libiberty/testsuite/test-expandargv.c
index 234de9ae6b..66bc010434 100644
--- a/libiberty/testsuite/test-expandargv.c
+++ b/libiberty/testsuite/test-expandargv.c
@@ -1,5 +1,5 @@ 
 /* expandargv test program,
-   Copyright (C) 2006-2019 Free Software Foundation, Inc.
+   Copyright (C) 2006-2020 Free Software Foundation, Inc.
    Written by Carlos O'Donell <carlos@codesourcery.com>
 
    This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/testsuite/test-pexecute.c b/libiberty/testsuite/test-pexecute.c
index a92fae7a62..30c990dfae 100644
--- a/libiberty/testsuite/test-pexecute.c
+++ b/libiberty/testsuite/test-pexecute.c
@@ -1,5 +1,5 @@ 
 /* Pexecute test program,
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@airs.com>.
 
    This file is part of GNU libiberty.
diff --git a/libiberty/testsuite/test-strtol.c b/libiberty/testsuite/test-strtol.c
index 28cce83feb..fd5f89d2a4 100644
--- a/libiberty/testsuite/test-strtol.c
+++ b/libiberty/testsuite/test-strtol.c
@@ -1,5 +1,5 @@ 
 /* Test program for strtol family of funtions,
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
    Written by Yury Gribov <y.gribov@samsung.com>
 
    This file is part of the libiberty library, which is part of GCC.
diff --git a/libiberty/timeval-utils.c b/libiberty/timeval-utils.c
index 90dc765e2a..ee46b5633e 100644
--- a/libiberty/timeval-utils.c
+++ b/libiberty/timeval-utils.c
@@ -1,5 +1,5 @@ 
 /* Basic struct timeval utilities.
-   Copyright (C) 2011-2019 Free Software Foundation, Inc.
+   Copyright (C) 2011-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/unlink-if-ordinary.c b/libiberty/unlink-if-ordinary.c
index dbaf31d804..b4d6f0a841 100644
--- a/libiberty/unlink-if-ordinary.c
+++ b/libiberty/unlink-if-ordinary.c
@@ -1,5 +1,5 @@ 
 /* unlink-if-ordinary.c - remove link to a file unless it is special
-   Copyright (C) 2004-2019 Free Software Foundation, Inc.
+   Copyright (C) 2004-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c
index cc04248b5c..0bdd41a5e3 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-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/vfprintf.c b/libiberty/vfprintf.c
index 2fb6bf0709..433d12db66 100644
--- a/libiberty/vfprintf.c
+++ b/libiberty/vfprintf.c
@@ -1,6 +1,6 @@ 
 /* Provide a version vfprintf in terms of _doprnt.
    By Kaveh Ghazi  (ghazi@caip.rutgers.edu)  3/29/98
-   Copyright (C) 1998-2019 Free Software Foundation, Inc.
+   Copyright (C) 1998-2020 Free Software Foundation, Inc.
  */
 
 #include "ansidecl.h"
diff --git a/libiberty/vprintf-support.c b/libiberty/vprintf-support.c
index aabc3d2ef0..52e7378ea9 100644
--- a/libiberty/vprintf-support.c
+++ b/libiberty/vprintf-support.c
@@ -1,6 +1,6 @@ 
 /* Estimate the length of the string generated by a vprintf-like
    function.  Used by vasprintf and xvasprintf.
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/vprintf-support.h b/libiberty/vprintf-support.h
index 51c2decd80..ea689df6d1 100644
--- a/libiberty/vprintf-support.h
+++ b/libiberty/vprintf-support.h
@@ -1,6 +1,6 @@ 
 /* Estimate the length of the string generated by a vprintf-like
    function.  Use by vasprintf and xvasprintf.
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/vsnprintf.c b/libiberty/vsnprintf.c
index 647fb7a357..76a7711d1e 100644
--- a/libiberty/vsnprintf.c
+++ b/libiberty/vsnprintf.c
@@ -1,5 +1,5 @@ 
 /* Implement the vsnprintf function.
-   Copyright (C) 2003-2019 Free Software Foundation, Inc.
+   Copyright (C) 2003-2020 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
diff --git a/libiberty/vsprintf.c b/libiberty/vsprintf.c
index a2ec5aef91..6337569565 100644
--- a/libiberty/vsprintf.c
+++ b/libiberty/vsprintf.c
@@ -3,7 +3,7 @@ 
    implementations of stdio; newer ones should already have vsprintf.
    Written by Per Bothner of Cygnus Support.
    Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
-   Copyright (C) 1991-2019 Free Software Foundation, Inc.
+   Copyright (C) 1991-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.  This library is free
 software; you can redistribute it and/or modify it under the
diff --git a/libiberty/xasprintf.c b/libiberty/xasprintf.c
index 5af97e4eb4..76fb4b34d4 100644
--- a/libiberty/xasprintf.c
+++ b/libiberty/xasprintf.c
@@ -1,5 +1,5 @@ 
 /* Implement the xasprintf function.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
    Contributed by Manuel Lopez-Ibanez.
 
 This file is part of the libiberty library.
diff --git a/libiberty/xexit.c b/libiberty/xexit.c
index 7cbebc8420..268aef1595 100644
--- a/libiberty/xexit.c
+++ b/libiberty/xexit.c
@@ -1,5 +1,5 @@ 
 /* xexit.c -- Run any exit handlers, then exit.
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c
index e39ab3b9f9..96d51b5778 100644
--- a/libiberty/xmalloc.c
+++ b/libiberty/xmalloc.c
@@ -1,5 +1,5 @@ 
 /* memory allocation routines with error checking.
-   Copyright (C) 1989-2019 Free Software Foundation, Inc.
+   Copyright (C) 1989-2020 Free Software Foundation, Inc.
    
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
diff --git a/libiberty/xstrndup.c b/libiberty/xstrndup.c
index bb0b512dce..32ba832427 100644
--- a/libiberty/xstrndup.c
+++ b/libiberty/xstrndup.c
@@ -1,5 +1,5 @@ 
 /* Implement the xstrndup function.
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
diff --git a/libiberty/xvasprintf.c b/libiberty/xvasprintf.c
index c4ab52e34c..1ac513e189 100644
--- a/libiberty/xvasprintf.c
+++ b/libiberty/xvasprintf.c
@@ -1,5 +1,5 @@ 
 /* Implement the xvasprintf function.
-   Copyright (C) 2014-2019 Free Software Foundation, Inc.
+   Copyright (C) 2014-2020 Free Software Foundation, Inc.
    Contributed by Manuel Lopez-Ibanez.
 
 This file is part of the libiberty library.