diff options
author | Ian Lance Taylor <iant@golang.org> | 2018-01-24 23:50:09 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-01-24 23:50:09 +0000 |
commit | 4880b994d63ffb014a5a547239e9cd8402bb014a (patch) | |
tree | a782ef29045ab50de17cac215b8c30c9a3b61aa2 /libgo | |
parent | d3719ee2c078a1518c9e21efae0cf438d4ffb8d6 (diff) | |
download | gcc-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')
-rw-r--r-- | libgo/go/runtime/crash_test.go | 4 | ||||
-rw-r--r-- | libgo/go/runtime/panic.go | 2 | ||||
-rw-r--r-- | libgo/go/runtime/pprof/pprof_test.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/wait.c | 18 | ||||
-rw-r--r-- | libgo/runtime/go-callers.c | 11 | ||||
-rw-r--r-- | libgo/runtime/go-unsafe-pointer.c | 12 |
6 files changed, 25 insertions, 24 deletions
diff --git a/libgo/go/runtime/crash_test.go b/libgo/go/runtime/crash_test.go index 8ec0348..06200c7 100644 --- a/libgo/go/runtime/crash_test.go +++ b/libgo/go/runtime/crash_test.go @@ -425,7 +425,7 @@ func TestPanicTraceback(t *testing.T) { // Check functions in the traceback. fns := []string{"main.pt1.func1", "panic", "main.pt2.func1", "panic", "main.pt2", "main.pt1"} if runtime.Compiler == "gccgo" { - fns = []string{"main.$nested", "panic", "main.$nested", "panic", "main.pt2", "main.pt1"} + fns = []string{"main.pt1..func1", "panic", "main.pt2..func1", "panic", "main.pt2", "main.pt1"} } for _, fn := range fns { var re *regexp.Regexp @@ -570,7 +570,7 @@ func TestPanicInlined(t *testing.T) { buf = buf[:n] want := []byte("(*point).negate(") if runtime.Compiler == "gccgo" { - want = []byte("negate.pN18_runtime_test.point") + want = []byte("point.negate") } if !bytes.Contains(buf, want) { t.Logf("%s", buf) diff --git a/libgo/go/runtime/panic.go b/libgo/go/runtime/panic.go index b2deb6e..24d78eca 100644 --- a/libgo/go/runtime/panic.go +++ b/libgo/go/runtime/panic.go @@ -656,7 +656,7 @@ func canrecover(retaddr uintptr) bool { } // Ignore other functions in the reflect package. - if hasprefix(name, "reflect.") { + if hasprefix(name, "reflect.") || hasprefix(name, ".1reflect.") { continue } diff --git a/libgo/go/runtime/pprof/pprof_test.go b/libgo/go/runtime/pprof/pprof_test.go index 08a4f96..ae6ec6d 100644 --- a/libgo/go/runtime/pprof/pprof_test.go +++ b/libgo/go/runtime/pprof/pprof_test.go @@ -730,7 +730,7 @@ func TestMutexProfile(t *testing.T) { stks := stacks(p) for _, want := range [][]string{ // {"sync.(*Mutex).Unlock", "pprof.blockMutex.func1"}, - {"sync.Unlock.pN10_sync.Mutex", "pprof.$nested17"}, + {".1sync.Mutex.Unlock", "pprof.blockMutex..func1"}, } { if !containsStack(stks, want) { t.Errorf("No matching stack entry for %+v", want) diff --git a/libgo/go/syscall/wait.c b/libgo/go/syscall/wait.c index a50f7d6..c0c5cca 100644 --- a/libgo/go/syscall/wait.c +++ b/libgo/go/syscall/wait.c @@ -17,7 +17,7 @@ #endif extern _Bool Exited (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Exited.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.Exited"); _Bool Exited (uint32_t *w) @@ -26,7 +26,7 @@ Exited (uint32_t *w) } extern _Bool Signaled (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Signaled.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.Signaled"); _Bool Signaled (uint32_t *w) @@ -35,7 +35,7 @@ Signaled (uint32_t *w) } extern _Bool Stopped (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Stopped.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.Stopped"); _Bool Stopped (uint32_t *w) @@ -44,7 +44,7 @@ Stopped (uint32_t *w) } extern _Bool Continued (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Continued.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.Continued"); _Bool Continued (uint32_t *w) @@ -53,7 +53,7 @@ Continued (uint32_t *w) } extern _Bool CoreDump (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.CoreDump.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.CoreDump"); _Bool CoreDump (uint32_t *w) @@ -62,7 +62,7 @@ CoreDump (uint32_t *w) } extern int ExitStatus (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.ExitStatus.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.ExitStatus"); int ExitStatus (uint32_t *w) @@ -73,7 +73,7 @@ ExitStatus (uint32_t *w) } extern int Signal (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.Signal.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.Signal"); int Signal (uint32_t *w) @@ -84,7 +84,7 @@ Signal (uint32_t *w) } extern int StopSignal (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.StopSignal.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.StopSignal"); int StopSignal (uint32_t *w) @@ -95,7 +95,7 @@ StopSignal (uint32_t *w) } extern int TrapCause (uint32_t *w) - __asm__ (GOSYM_PREFIX "syscall.TrapCause.N18_syscall.WaitStatus"); + __asm__ (GOSYM_PREFIX "syscall.WaitStatus.TrapCause"); int TrapCause (uint32_t *w __attribute__ ((unused))) 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; } diff --git a/libgo/runtime/go-unsafe-pointer.c b/libgo/runtime/go-unsafe-pointer.c index 9df7f3a..5afd011 100644 --- a/libgo/runtime/go-unsafe-pointer.c +++ b/libgo/runtime/go-unsafe-pointer.c @@ -15,10 +15,10 @@ descriptor. */ extern const struct __go_type_descriptor unsafe_Pointer - __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer"); + __asm__ (GOSYM_PREFIX "unsafe.Pointer..d"); extern const byte unsafe_Pointer_gc[] - __asm__ (GOSYM_PREFIX "__go_tdn_unsafe.Pointer$gc"); + __asm__ (GOSYM_PREFIX "unsafe.Pointer..g"); /* Used to determine the field alignment. */ struct field_align @@ -38,9 +38,9 @@ static const String reflection_string = const byte unsafe_Pointer_gc[] = { 1 }; extern const FuncVal runtime_pointerhash_descriptor - __asm__ (GOSYM_PREFIX "runtime.pointerhash$descriptor"); + __asm__ (GOSYM_PREFIX "runtime.pointerhash..f"); extern const FuncVal runtime_pointerequal_descriptor - __asm__ (GOSYM_PREFIX "runtime.pointerequal$descriptor"); + __asm__ (GOSYM_PREFIX "runtime.pointerequal..f"); const struct __go_type_descriptor unsafe_Pointer = { @@ -75,7 +75,7 @@ const struct __go_type_descriptor unsafe_Pointer = it to be defined elsewhere. */ extern const struct __go_ptr_type pointer_unsafe_Pointer - __asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer"); + __asm__ (GOSYM_PREFIX "type...1unsafe.Pointer"); /* The reflection string. */ #define PREFLECTION "*unsafe.Pointer" @@ -86,7 +86,7 @@ static const String preflection_string = }; extern const byte pointer_unsafe_Pointer_gc[] - __asm__ (GOSYM_PREFIX "__go_td_pN14_unsafe.Pointer$gc"); + __asm__ (GOSYM_PREFIX "type...1unsafe.Pointer..g"); const byte pointer_unsafe_Pointer_gc[] = { 1 }; |