Skip to content

Commit 431f321

Browse files
hjl-toolsH.J. Lu
authored andcommitted
Properly demangle a global constructor symbol.
2010-11-16 H.J. Lu <[email protected]> PR other/42670 PR binutils/11137 * cp-demangle.c (d_make_demangle_mangled_name): New. (d_demangle_callback): Use it on DCT_GLOBAL_XTORS. * testsuite/demangle-expected: Updated. From-SVN: r166810
1 parent b9b9d34 commit 431f321

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

libiberty/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2010-11-16 H.J. Lu <[email protected]>
2+
3+
PR other/42670
4+
PR binutils/11137
5+
* cp-demangle.c (d_make_demangle_mangled_name): New.
6+
(d_demangle_callback): Use it on DCT_GLOBAL_XTORS.
7+
8+
* testsuite/demangle-expected: Updated.
9+
110
2010-11-14 Kai Tietz <[email protected]>
211

312
* simple-object-coff.c (simple_object_coff_read_strtab): Fix reading

libiberty/cp-demangle.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,9 @@ d_make_comp (struct d_info *, enum demangle_component_type,
321321
static struct demangle_component *
322322
d_make_name (struct d_info *, const char *, int);
323323

324+
static struct demangle_component *
325+
d_make_demangle_mangled_name (struct d_info *, const char *);
326+
324327
static struct demangle_component *
325328
d_make_builtin_type (struct d_info *,
326329
const struct demangle_builtin_type_info *);
@@ -869,6 +872,17 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
869872
return p;
870873
}
871874

875+
/* Add a new demangle mangled name component. */
876+
877+
static struct demangle_component *
878+
d_make_demangle_mangled_name (struct d_info *di, const char *s)
879+
{
880+
if (d_peek_char (di) != '_' || d_peek_next_char (di) != 'Z')
881+
return d_make_name (di, s, strlen (s));
882+
d_advance (di, 2);
883+
return d_encoding (di, 0);
884+
}
885+
872886
/* Add a new name component. */
873887

874888
static struct demangle_component *
@@ -4823,7 +4837,7 @@ d_demangle_callback (const char *mangled, int options,
48234837
(type == DCT_GLOBAL_CTORS
48244838
? DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS
48254839
: DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS),
4826-
d_make_name (&di, d_str (&di), strlen (d_str (&di))),
4840+
d_make_demangle_mangled_name (&di, d_str (&di)),
48274841
NULL);
48284842
d_advance (&di, strlen (d_str (&di)));
48294843
break;

libiberty/testsuite/demangle-expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,8 +3610,8 @@ std::_Alloc_traits<std::basic_string<char, std::string_char_traits<char>, libcw:
36103610
#
36113611
--format=gnu-v3 --no-params
36123612
_GLOBAL__I__Z2fnv
3613-
global constructors keyed to _Z2fnv
3614-
global constructors keyed to _Z2fnv
3613+
global constructors keyed to fn()
3614+
global constructors keyed to fn()
36153615
#
36163616
--format=gnu-v3 --no-params
36173617
_Z1rM1GFivEMS_KFivES_M1HFivES1_4whatIKS_E5what2IS8_ES3_

0 commit comments

Comments
 (0)