Import libiberty from gcc

This commit is contained in:
Alan Modra
2022-05-13 16:43:15 +09:30
parent 845cbaa9ff
commit 31b15688c4
28 changed files with 165 additions and 148 deletions

View File

@ -1375,13 +1375,19 @@ rust_demangle_callback (const char *mangled, int options,
/* Rust symbols (v0) use only [_0-9a-zA-Z] characters. */
for (p = rdm.sym; *p; p++)
{
/* Rust v0 symbols can have '.' suffixes, ignore those. */
if (rdm.version == 0 && *p == '.')
break;
rdm.sym_len++;
if (*p == '_' || ISALNUM (*p))
continue;
/* Legacy Rust symbols can also contain [.:$] characters. */
if (rdm.version == -1 && (*p == '$' || *p == '.' || *p == ':'))
/* Legacy Rust symbols can also contain [.:$] characters.
Or @ in the .suffix (which will be skipped, see below). */
if (rdm.version == -1 && (*p == '$' || *p == '.' || *p == ':'
|| *p == '@'))
continue;
return 0;
@ -1390,7 +1396,16 @@ rust_demangle_callback (const char *mangled, int options,
/* Legacy Rust symbols need to be handled separately. */
if (rdm.version == -1)
{
/* Legacy Rust symbols always end with E. */
/* Legacy Rust symbols always end with E. But can be followed by a
.suffix (which we want to ignore). */
int dot_suffix = 1;
while (rdm.sym_len > 0 &&
!(dot_suffix && rdm.sym[rdm.sym_len - 1] == 'E'))
{
dot_suffix = rdm.sym[rdm.sym_len - 1] == '.';
rdm.sym_len--;
}
if (!(rdm.sym_len > 0 && rdm.sym[rdm.sym_len - 1] == 'E'))
return 0;
rdm.sym_len--;