Commit 4a035cf7 by Carlo Wood Committed by Carlo Wood

demangle.h (demangle<Allocator>::symbol(char const*)): Decode symbols that start…

demangle.h (demangle<Allocator>::symbol(char const*)): Decode symbols that start with _GLOBAL_[ID]_ differently...

* include/bits/demangle.h (demangle<Allocator>::symbol(char const*)):
Decode symbols that start with _GLOBAL_[ID]_ differently: the
trailing part ends with a terminating zero and is not necessarily an
encoding.
* src/demangle.cc (): Same.
* testsuite/demangle/regression/cw-13.cc: Adjust for new output.

From-SVN: r72027
parent 28a60850
2003-10-02 Carlo Wood <carlo@alinoe.com>
* include/bits/demangle.h (demangle<Allocator>::symbol(char const*)):
Decode symbols that start with _GLOBAL_[ID]_ differently: the
trailing part ends with a terminating zero and is not necessarily an
encoding.
* src/demangle.cc (): Same.
* testsuite/demangle/regression/cw-13.cc: Adjust for new output.
2003-10-02 Paolo Carlini <pcarlini@unitus.it> 2003-10-02 Paolo Carlini <pcarlini@unitus.it>
* testsuite/22_locale/locale/cons/12438.cc: Use * testsuite/22_locale/locale/cons/12438.cc: Use
......
...@@ -2293,7 +2293,7 @@ namespace __gnu_cxx ...@@ -2293,7 +2293,7 @@ namespace __gnu_cxx
demangle<Allocator>::symbol(char const* input) demangle<Allocator>::symbol(char const* input)
{ {
// <mangled-name> ::= _Z <encoding> // <mangled-name> ::= _Z <encoding>
// <mangled-name> ::= _GLOBAL_ _<type>_ _Z <encoding> // <mangled-name> ::= _GLOBAL_ _<type>_ <disambiguation part>
// <type> can be I or D (GNU extension) // <type> can be I or D (GNU extension)
typedef demangler::session<Allocator> demangler_type; typedef demangler::session<Allocator> demangler_type;
string_type result; string_type result;
...@@ -2305,16 +2305,14 @@ namespace __gnu_cxx ...@@ -2305,16 +2305,14 @@ namespace __gnu_cxx
{ {
if (!strncmp(input, "_GLOBAL__", 9) if (!strncmp(input, "_GLOBAL__", 9)
&& (input[9] == 'D' || input[9] == 'I') && (input[9] == 'D' || input[9] == 'I')
&& input[10] == '_' && input[11] == '_' && input[12] == 'Z') && input[10] == '_')
{ {
if (input[9] == 'D') if (input[9] == 'D')
result.assign("global destructors keyed to ", 28); result.assign("global destructors keyed to ", 28);
else else
result.assign("global constructors keyed to ", 29); result.assign("global constructors keyed to ", 29);
int cnt = demangler_type::decode_encoding(result, input + 13, // Output the disambiguation part as-is.
INT_MAX); result += input + 11;
if (cnt < 0 || input[cnt + 13] != 0)
failure = true;
} }
else else
failure = true; failure = true;
......
...@@ -130,17 +130,14 @@ namespace __cxxabiv1 ...@@ -130,17 +130,14 @@ namespace __cxxabiv1
// Possible _GLOBAL__ extension? // Possible _GLOBAL__ extension?
if (!std::strncmp(mangled_name, "_GLOBAL__", 9) if (!std::strncmp(mangled_name, "_GLOBAL__", 9)
&& (mangled_name[9] == 'D' || mangled_name[9] == 'I') && (mangled_name[9] == 'D' || mangled_name[9] == 'I')
&& mangled_name[10] == '_' && mangled_name[11] == '_' && mangled_name[10] == '_')
&& mangled_name[12] == 'Z')
{ {
if (mangled_name[9] == 'D') if (mangled_name[9] == 'D')
result.assign("global destructors keyed to ", 28); result.assign("global destructors keyed to ", 28);
else else
result.assign("global constructors keyed to ", 29); result.assign("global constructors keyed to ", 29);
int cnt = session_type:: // Output the disambiguation part as-is.
decode_encoding(result, mangled_name + 13, INT_MAX); result += mangled_name + 11;
if (cnt < 0 || mangled_name[cnt + 13] != 0)
return failure(invalid_mangled_name, status);
return finish(result.data(), result.size(), buf, n, status); return finish(result.data(), result.size(), buf, n, status);
} }
} }
......
...@@ -28,7 +28,7 @@ int main() ...@@ -28,7 +28,7 @@ int main()
using namespace __gnu_test; using namespace __gnu_test;
// cplus-dem CORE // cplus-dem CORE
verify_demangle("_GLOBAL__I__Z2fnv", "global constructors keyed to fn()"); verify_demangle("_GLOBAL__I__Z2fnv", "global constructors keyed to _Z2fnv");
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment