From 6355d6c7e2e8f4ea4cfd3fed8da6677106937f66 Mon Sep 17 00:00:00 2001 From: David Crawshaw Date: Sat, 21 Oct 2017 07:29:46 -0400 Subject: cmd/link, plugin: always encode path Both the linker and the plugin package were inconsistent about when they applied the path encoding defined in objabi.PathToPrefix. As a result, only some symbols from a package path that required encoding were being found. So always encoding the path. Fixes #22295 Change-Id: Ife86c79ca20b2e9307008ed83885e193d32b7dc4 Reviewed-on: https://go-review.googlesource.com/72390 Run-TryBot: David Crawshaw TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/plugin/plugin_dlopen.go | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'src/plugin/plugin_dlopen.go') diff --git a/src/plugin/plugin_dlopen.go b/src/plugin/plugin_dlopen.go index 37380989d7..47f2b29a80 100644 --- a/src/plugin/plugin_dlopen.go +++ b/src/plugin/plugin_dlopen.go @@ -49,37 +49,6 @@ func lastIndexByte(s string, c byte) int { return -1 } -// pathToPrefix converts raw string to the prefix that will be used in the symbol -// table. If modifying, modify the version in internal/obj/sym.go as well. -func pathToPrefix(s string) string { - slash := lastIndexByte(s, '/') - // check for chars that need escaping - n := 0 - for r := 0; r < len(s); r++ { - if c := s[r]; c <= ' ' || (c == '.' && r > slash) || c == '%' || c == '"' || c >= 0x7F { - n++ - } - } - - // quick exit - if n == 0 { - return s - } - - // escape - const hex = "0123456789abcdef" - p := make([]byte, 0, len(s)+2*n) - for r := 0; r < len(s); r++ { - if c := s[r]; c <= ' ' || (c == '.' && r > slash) || c == '%' || c == '"' || c >= 0x7F { - p = append(p, '%', hex[c>>4], hex[c&0xF]) - } else { - p = append(p, c) - } - } - - return string(p) -} - func open(name string) (*Plugin, error) { cPath := make([]byte, C.PATH_MAX+1) cRelName := make([]byte, len(name)+1) @@ -153,7 +122,7 @@ func open(name string) (*Plugin, error) { symName = symName[1:] } - fullName := pathToPrefix(pluginpath) + "." + symName + fullName := pluginpath + "." + symName cname := make([]byte, len(fullName)+1) copy(cname, fullName) -- cgit v1.3