+2019-08-09 Nick Clifton <nickc@redhat.com>
+
+ * libiberty: Sync with gcc. Bring in:
+ 2019-08-08 Martin Liska <mliska@suse.cz>
+
+ PR bootstrap/91352
+ * lrealpath.c (is_valid_fd): New function.
+
+ 2019-07-24 Martin Liska <mliska@suse.cz>
+
+ PR lto/91228
+ * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+ Find first '\0' starting from gnu_lto + 1.
+
+ 2019-07-12 Ren Kimura <rkx1209dev@gmail.com>
+
+ * simple-object-elf.c (simple_object_elf_match): Check zero value shstrndx.
+ This fixes a Bug 90924.
+
+ 2019-07-22 Martin Liska <mliska@suse.cz>
+
+ * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+ Do not search for gnu_lto_v1, but search for first '\0'.
+
+ 2019-07-18 Eduard-Mihai Burtescu <eddyb@lyken.rs>
+
+ * cplus-dem.c: Include rust-demangle.h.
+ * rust-demangle.c: Include rust-demangle.h.
+ * rust-demangle.h: New file.
+
+ 2019-05-31 Michael Forney <mforney@mforney.org>
+
+ * cp-demangle.c: Don't define CP_DYNAMIC_ARRAYS if __STDC_NO_VLA__
+ is non-zero.
+
+ 2019-04-30 Ben L <bobsayshilol@live.co.uk>
+
+ * d-demangle.c (dlang_parse_assocarray): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_tuple): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_structlit): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_integer): Fix stack underflow.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
+ * testsuite/demangle-expected: Add testcase.
+
+ * cp-demangle.c (d_encoding): Guard against NULL return values from
+ d_right (dc).
+ * testsuite/demangle-expected: Add testcase.
+
+ 2019-04-29 Ben L <bobsayshilol@live.co.uk>
+
+ * cp-demangle.c (d_expression_1): Don't peek ahead unless the current
+ char is valid.
+ * testsuite/demangle-expected: Add testcase.
+
+ 2019-04-10 Nick Clifton <nickc@redhat.com>
+
+ PR 89394
+ * cp-demangle.c (cplus_demangle_fill_name): Reject negative
+ lengths.
+ (d_count_templates_scopes): Replace num_templates and num_scopes
+ parameters with a struct d_print_info pointer parameter. Adjust
+ body of the function accordingly. Add recursion counter and check
+ that the recursion limit is not reached.
+ (d_print_init): Pass dpi parameter to d_count_templates_scopes.
+ Reset recursion counter afterwards, unless the recursion limit was
+ reached.
+
2019-07-13 Joel Brobecker <brobecker@adacore.com>
* src-release (getver): If $tool/gdbsupport/create-version.sh
+2019-08-08 Martin Liska <mliska@suse.cz>
+
+ PR bootstrap/91352
+ * lrealpath.c (is_valid_fd): New function.
+
+2019-07-24 Martin Liska <mliska@suse.cz>
+
+ PR lto/91228
+ * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+ Find first '\0' starting from gnu_lto + 1.
+
+2019-07-12 Ren Kimura <rkx1209dev@gmail.com>
+
+ * simple-object-elf.c (simple_object_elf_match): Check zero value shstrndx.
+ This fixes a Bug 90924.
+
+2019-07-22 Martin Liska <mliska@suse.cz>
+
+ * simple-object-elf.c (simple_object_elf_copy_lto_debug_sections):
+ Do not search for gnu_lto_v1, but search for first '\0'.
+
+2019-07-18 Eduard-Mihai Burtescu <eddyb@lyken.rs>
+
+ * cplus-dem.c: Include rust-demangle.h.
+ * rust-demangle.c: Include rust-demangle.h.
+ * rust-demangle.h: New file.
+
+2019-05-31 Michael Forney <mforney@mforney.org>
+
+ * cp-demangle.c: Don't define CP_DYNAMIC_ARRAYS if __STDC_NO_VLA__
+ is non-zero.
+
+2019-04-30 Ben L <bobsayshilol@live.co.uk>
+
+ * d-demangle.c (dlang_parse_assocarray): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_tuple): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_structlit): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_arrayliteral): Correctly handle error result.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * d-demangle.c (dlang_parse_integer): Fix stack underflow.
+ * testsuite/d-demangle-expected: Add testcase.
+
+ * cp-demangle (d_print_comp_inner): Guard against a NULL 'typed_name'.
+ * testsuite/demangle-expected: Add testcase.
+
+ * cp-demangle.c (d_encoding): Guard against NULL return values from
+ d_right (dc).
+ * testsuite/demangle-expected: Add testcase.
+
+2019-04-29 Ben L <bobsayshilol@live.co.uk>
+
+ * cp-demangle.c (d_expression_1): Don't peek ahead unless the current
+ char is valid.
+ * testsuite/demangle-expected: Add testcase.
+
+2019-04-10 Nick Clifton <nickc@redhat.com>
+
+ PR 89394
+ * cp-demangle.c (cplus_demangle_fill_name): Reject negative
+ lengths.
+ (d_count_templates_scopes): Replace num_templates and num_scopes
+ parameters with a struct d_print_info pointer parameter. Adjust
+ body of the function accordingly. Add recursion counter and check
+ that the recursion limit is not reached.
+ (d_print_init): Pass dpi parameter to d_count_templates_scopes.
+ Reset recursion counter afterwards, unless the recursion limit was
+ reached.
+
2019-04-07 Alan Modra <amodra@gmail.com>
* functions.texi: Regenerate.
#else
#ifdef __STDC__
#ifdef __STDC_VERSION__
-#if __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__
#define CP_DYNAMIC_ARRAYS
-#endif /* __STDC__VERSION >= 199901L */
+#endif /* __STDC_VERSION__ >= 199901L && !__STDC_NO_VLA__ */
#endif /* defined (__STDC_VERSION__) */
#endif /* defined (__STDC__) */
#endif /* ! defined (__GNUC__) */
really apply here; this happens when parsing a class
which is local to a function. */
if (dc->type == DEMANGLE_COMPONENT_LOCAL_NAME)
- while (is_fnqual_component_type (d_right (dc)->type))
- d_right (dc) = d_left (d_right (dc));
+ {
+ while (d_right (dc) != NULL
+ && is_fnqual_component_type (d_right (dc)->type))
+ d_right (dc) = d_left (d_right (dc));
+
+ if (d_right (dc) == NULL)
+ dc = NULL;
+ }
}
else
{
d_advance (di, 2);
if (peek == 't')
type = cplus_demangle_type (di);
- if (!d_peek_next_char (di))
+ if (!d_peek_char (di) || !d_peek_next_char (di))
return NULL;
return d_make_comp (di, DEMANGLE_COMPONENT_INITIALIZER_LIST,
type, d_exprlist (di, 'E'));
typed_name = d_right (typed_name);
if (typed_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG)
typed_name = typed_name->u.s_unary_num.sub;
- if (typed_name == NULL)
- {
- d_print_error (dpi);
- return;
- }
- while (is_fnqual_component_type (typed_name->type))
+ while (typed_name != NULL
+ && is_fnqual_component_type (typed_name->type))
{
if (i >= sizeof adpm / sizeof adpm[0])
{
typed_name = d_left (typed_name);
}
+ if (typed_name == NULL)
+ {
+ d_print_error (dpi);
+ return;
+ }
}
/* If typed_name is a template, then it applies to the
#define CURRENT_DEMANGLING_STYLE options
#include "libiberty.h"
+#include "rust-demangle.h"
enum demangling_styles current_demangling_style = auto_demangling;
if (type == 'a' || type == 'u' || type == 'w')
{
/* Parse character value. */
- char value[10];
- int pos = 10;
+ char value[20];
+ int pos = sizeof(value);
int width = 0;
long val;
for (; width > 0; width--)
value[--pos] = '0';
- string_appendn (decl, &(value[pos]), 10 - pos);
+ string_appendn (decl, &(value[pos]), sizeof(value) - pos);
}
string_append (decl, "'");
}
while (elements--)
{
mangled = dlang_value (decl, mangled, NULL, '\0');
+ if (mangled == NULL)
+ return NULL;
+
if (elements != 0)
string_append (decl, ", ");
}
while (elements--)
{
mangled = dlang_value (decl, mangled, NULL, '\0');
+ if (mangled == NULL)
+ return NULL;
+
string_append (decl, ":");
mangled = dlang_value (decl, mangled, NULL, '\0');
+ if (mangled == NULL)
+ return NULL;
if (elements != 0)
string_append (decl, ", ");
while (args--)
{
mangled = dlang_value (decl, mangled, NULL, '\0');
+ if (mangled == NULL)
+ return NULL;
+
if (args != 0)
string_append (decl, ", ");
}
while (elements--)
{
mangled = dlang_type (decl, mangled);
+ if (mangled == NULL)
+ return NULL;
+
if (elements != 0)
string_append (decl, ", ");
}
#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) \
/* 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
+}
#include <demangle.h>
#include "libiberty.h"
+#include "rust-demangle.h"
/* Mangled Rust symbols look like this:
--- /dev/null
+/* Internal demangler interface for the Rust programming language.
+ Copyright (C) 2016-2019 Free Software Foundation, Inc.
+ Written by David Tolnay (dtolnay@gmail.com).
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+In addition to the permissions in the GNU Library General Public
+License, the Free Software Foundation gives you unlimited permission
+to link the compiled version of this file into combinations with other
+programs, and to distribute those combinations without any restriction
+coming from the use of this file. (The Library Public License
+restrictions do apply in other respects; for example, they cover
+modification of the file, and distribution when not linked into a
+combined executable.)
+
+Libiberty is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB.
+If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file provides some definitions shared by cplus-dem.c and
+ rust-demangle.c. It should not be included by any other files. */
+
+/* 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);
XDELETE (eor);
return NULL;
}
-
+
+ if (eor->shstrndx == 0)
+ {
+ *errmsg = "invalid ELF shstrndx == 0";
+ *err = 0;
+ XDELETE (eor);
+ return NULL;
+ }
+
return (void *) eor;
}
return errmsg;
}
- /* If we are processing .symtab purge __gnu_lto_v1 and
- __gnu_lto_slim symbols from it and any symbols in discarded
- sections. */
+ /* If we are processing .symtab purge __gnu_lto_slim symbol
+ from it and any symbols in discarded sections. */
if (sh_type == SHT_SYMTAB)
{
unsigned entsize = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
sobj->offset + stroff,
(unsigned char *)strings,
strsz, &errmsg, err);
- /* Find gnu_lto_ in strings. */
- while ((gnu_lto = (char *) memchr (gnu_lto, 'g',
- strings + strsz - gnu_lto)))
- if (strncmp (gnu_lto, "gnu_lto_v1",
- strings + strsz - gnu_lto) == 0)
- break;
- else
- gnu_lto++;
+ /* 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)
{
undefined and sharing the gnu_lto_ name. */
bind = STB_WEAK;
other = STV_HIDDEN;
- if (gnu_lto)
- ELF_SET_FIELD (type_functions, ei_class, Sym,
- ent, st_name, Elf_Word,
- gnu_lto - strings);
+ ELF_SET_FIELD (type_functions, ei_class, Sym,
+ ent, st_name, Elf_Word,
+ gnu_lto - strings);
ELF_SET_FIELD (type_functions, ei_class, Sym,
ent, st_shndx, Elf_Half, SHN_UNDEF);
}
--format=dlang
_D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const
+# Could crash
+--format=dlang
+_D8__T2fnVa8888888888888_
+_D8__T2fnVa8888888888888_
+# Could crash
+--format=dlang
+_D5__T2fnVmA1A1A911111111D
+_D5__T2fnVmA1A1A911111111D
+# Could crash
+--format=dlang
+_D7__T2fnVlS8S588888888888S6S5
+_D7__T2fnVlS8S588888888888S6S5
+# Could crash
+--format=dlang
+_D1_B699999999961*
+_D1_B699999999961*
+# Could crash
+--format=dlang
+_D5__T1fVHacA6666666666_
+_D5__T1fVHacA6666666666_
_Q8ccQ4M2e.
_Q8ccQ4M2e.
+# Could crash
+
+_ZmmAtl
+_ZmmAtl
+# Could crash
+--no-params
+_ZZaSFvOEES_
+_ZZaSFvOEES_
+_ZZaSFvOEES_
+# Could crash
+
+_ZZeqFvOEES_z
+_ZZeqFvOEES_z
#
# demangler/80513 Test for bogus characters after __thunk_