aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-callers.c
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-01-24 23:50:09 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-01-24 23:50:09 +0000
commit4880b994d63ffb014a5a547239e9cd8402bb014a (patch)
treea782ef29045ab50de17cac215b8c30c9a3b61aa2 /libgo/runtime/go-callers.c
parentd3719ee2c078a1518c9e21efae0cf438d4ffb8d6 (diff)
downloadgcc-4880b994d63ffb014a5a547239e9cd8402bb014a.zip
gcc-4880b994d63ffb014a5a547239e9cd8402bb014a.tar.gz
gcc-4880b994d63ffb014a5a547239e9cd8402bb014a.tar.bz2
compiler: rationalize external symbol names
Encode all external symbol names using only ASCII alphanumeric characters, underscore, and dot. Use a scheme that can be reliably demangled to a somewhat readable version as described in the long comment in names.cc. A minor cleanup discovered during this was that we were treating function types as different if one had a NULL parameters_ field and another has a non-NULL parameters_ field that has no parameters. This worked because we mangled them slightly differently. We now mangle them the same, so we treat them as equal, as we should anyhow. Reviewed-on: https://go-review.googlesource.com/89555 * go.go-torture/execute/names-1.go: New test. From-SVN: r257033
Diffstat (limited to 'libgo/runtime/go-callers.c')
-rw-r--r--libgo/runtime/go-callers.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libgo/runtime/go-callers.c b/libgo/runtime/go-callers.c
index 9f376c7..2eaac68 100644
--- a/libgo/runtime/go-callers.c
+++ b/libgo/runtime/go-callers.c
@@ -68,13 +68,14 @@ callback (void *data, uintptr_t pc, const char *filename, int lineno,
{
const char *p;
- p = __builtin_strchr (function, '.');
- if (p != NULL && __builtin_strncmp (p + 1, "$thunk", 6) == 0)
+ p = function + __builtin_strlen (function);
+ while (p > function && p[-1] >= '0' && p[-1] <= '9')
+ --p;
+ if (p - function > 7 && __builtin_strncmp (p - 7, "..thunk", 7) == 0)
return 0;
- p = __builtin_strrchr (function, '$');
- if (p != NULL && __builtin_strcmp(p, "$recover") == 0)
+ if (p - function > 3 && __builtin_strcmp (p - 3, "..r") == 0)
return 0;
- if (p != NULL && __builtin_strncmp(p, "$stub", 5) == 0)
+ if (p - function > 6 && __builtin_strcmp (p - 6, "..stub") == 0)
return 0;
}