diff options
| author | Jan Kratochvil <[email protected]> | 2014-01-15 21:16:57 +0100 |
|---|---|---|
| committer | Jan Kratochvil <[email protected]> | 2014-01-15 21:16:57 +0100 |
| commit | 7c6e785e6eca774080a64801f950bd61785c469e (patch) | |
| tree | 4429967bfda9c63803a4180d5e52f91a731fb6f4 /src | |
| parent | e922ec4e3bcd7c164a9ce424accac4394e7d5afd (diff) | |
Fix corruption of non-C++ symbols by the demangler.
Signed-off-by: Jan Kratochvil <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/nm.c | 16 | ||||
| -rw-r--r-- | src/stack.c | 5 |
3 files changed, 18 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d37cd1bb..50b6b588 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2014-01-15 Jan Kratochvil <[email protected]> + + Fix corruption of non-C++ symbols by the demangler. + * nm.c (show_symbols_sysv, show_symbols_bsd, show_symbols_posix) + (show_symbols): Check for _Z. + * stack.c (print_frames) <USE_DEMANGLE>: Check for _Z. + 2014-01-02 Mark Wielaard <[email protected]> * stack.c (show_raw): Declare unconditionally. @@ -820,8 +820,8 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname, symstrbuf, sizeof symstrbuf); #ifdef USE_DEMANGLE - /* Demangle if necessary. */ - if (demangle) + /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */ + if (demangle && symstr[0] == '_' && symstr[1] == 'Z') { int status = -1; char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, @@ -965,8 +965,8 @@ show_symbols_bsd (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, continue; #ifdef USE_DEMANGLE - /* Demangle if necessary. */ - if (demangle) + /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */ + if (demangle && symstr[0] == '_' && symstr[1] == 'Z') { int status = -1; char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, @@ -1076,8 +1076,8 @@ show_symbols_posix (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, continue; #ifdef USE_DEMANGLE - /* Demangle if necessary. */ - if (demangle) + /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */ + if (demangle && symstr[0] == '_' && symstr[1] == 'Z') { int status = -1; char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, @@ -1244,8 +1244,8 @@ show_symbols (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, Elf_Scn *xndxscn, continue; #ifdef USE_DEMANGLE - /* Demangle if necessary. */ - if (demangle) + /* Demangle if necessary. Require GNU v3 ABI by the "_Z" prefix. */ + if (demangle && symstr[0] == '_' && symstr[1] == 'Z') { int status = -1; char *dmsymstr = __cxa_demangle (symstr, demangle_buffer, diff --git a/src/stack.c b/src/stack.c index fdf4b074..275be08c 100644 --- a/src/stack.c +++ b/src/stack.c @@ -1,5 +1,5 @@ /* Unwinding of frames like gstack/pstack. - Copyright (C) 2013 Red Hat, Inc. + Copyright (C) 2013-2014 Red Hat, Inc. This file is part of elfutils. This file is free software; you can redistribute it and/or modify @@ -220,7 +220,8 @@ print_frames (struct frames *frames, pid_t tid, int dwflerr, const char *what) if (symname != NULL) { #ifdef USE_DEMANGLE - if (! show_raw) + // Require GNU v3 ABI by the "_Z" prefix. + if (! show_raw && symname[0] == '_' && symname[1] == 'Z') { int status = -1; char *dsymname = __cxa_demangle (symname, demangle_buffer, |
