summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2015-07-01 23:29:06 +0000
committerGreg Clayton <gclayton@apple.com>2015-07-01 23:29:06 +0000
commit14cd13c51313e3a53a403eeb32b091d9c6a3011c (patch)
treec7a274303b3e65b43a56424332671d7dd50156aa
parente521457db3f52f8e425752cf5faa216fbc5ad1bc (diff)
downloadbcm5719-llvm-14cd13c51313e3a53a403eeb32b091d9c6a3011c.tar.gz
bcm5719-llvm-14cd13c51313e3a53a403eeb32b091d9c6a3011c.zip
Check to make sure we have a valid N_GSYM symbol name before we use it for anything.
llvm-svn: 241210
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp74
1 files changed, 45 insertions, 29 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 015798f749b..4c4fb3def9a 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -3386,7 +3386,11 @@ ObjectFileMachO::ParseSymtab ()
ConstString const_symbol_name(symbol_name);
sym[sym_idx].GetMangled().SetValue(const_symbol_name, symbol_name_is_mangled);
if (is_gsym && is_debug)
- N_GSYM_name_to_sym_idx[sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString()] = sym_idx;
+ {
+ const char *gsym_name = sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString();
+ if (gsym_name)
+ N_GSYM_name_to_sym_idx[gsym_name] = sym_idx;
+ }
}
}
if (symbol_section)
@@ -3513,21 +3517,25 @@ ObjectFileMachO::ParseSymtab ()
}
else
{
- // Combine N_GSYM stab entries with the non stab symbol
- ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString());
- if (pos != N_GSYM_name_to_sym_idx.end())
+ const char *gsym_name = sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString();
+ if (gsym_name)
{
- const uint32_t GSYM_sym_idx = pos->second;
- m_nlist_idx_to_sym_idx[nlist_idx] = GSYM_sym_idx;
- // Copy the address, because often the N_GSYM address has an invalid address of zero
- // when the global is a common symbol
- sym[GSYM_sym_idx].GetAddressRef().SetSection (symbol_section);
- sym[GSYM_sym_idx].GetAddressRef().SetOffset (symbol_value);
- // We just need the flags from the linker symbol, so put these flags
- // into the N_GSYM flags to avoid duplicate symbols in the symbol table
- sym[GSYM_sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc);
- sym[sym_idx].Clear();
- continue;
+ // Combine N_GSYM stab entries with the non stab symbol
+ ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(gsym_name);
+ if (pos != N_GSYM_name_to_sym_idx.end())
+ {
+ const uint32_t GSYM_sym_idx = pos->second;
+ m_nlist_idx_to_sym_idx[nlist_idx] = GSYM_sym_idx;
+ // Copy the address, because often the N_GSYM address has an invalid address of zero
+ // when the global is a common symbol
+ sym[GSYM_sym_idx].GetAddressRef().SetSection (symbol_section);
+ sym[GSYM_sym_idx].GetAddressRef().SetOffset (symbol_value);
+ // We just need the flags from the linker symbol, so put these flags
+ // into the N_GSYM flags to avoid duplicate symbols in the symbol table
+ sym[GSYM_sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc);
+ sym[sym_idx].Clear();
+ continue;
+ }
}
}
}
@@ -4235,7 +4243,11 @@ ObjectFileMachO::ParseSymtab ()
}
if (is_gsym)
- N_GSYM_name_to_sym_idx[sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString()] = sym_idx;
+ {
+ const char *gsym_name = sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString();
+ if (gsym_name)
+ N_GSYM_name_to_sym_idx[gsym_name] = sym_idx;
+ }
if (symbol_section)
{
@@ -4357,20 +4369,24 @@ ObjectFileMachO::ParseSymtab ()
else
{
// Combine N_GSYM stab entries with the non stab symbol
- ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString());
- if (pos != N_GSYM_name_to_sym_idx.end())
+ const char *gsym_name = sym[sym_idx].GetMangled().GetName(Mangled::ePreferMangled).GetCString();
+ if (gsym_name)
{
- const uint32_t GSYM_sym_idx = pos->second;
- m_nlist_idx_to_sym_idx[nlist_idx] = GSYM_sym_idx;
- // Copy the address, because often the N_GSYM address has an invalid address of zero
- // when the global is a common symbol
- sym[GSYM_sym_idx].GetAddressRef().SetSection (symbol_section);
- sym[GSYM_sym_idx].GetAddressRef().SetOffset (symbol_value);
- // We just need the flags from the linker symbol, so put these flags
- // into the N_GSYM flags to avoid duplicate symbols in the symbol table
- sym[GSYM_sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc);
- sym[sym_idx].Clear();
- continue;
+ ConstNameToSymbolIndexMap::const_iterator pos = N_GSYM_name_to_sym_idx.find(gsym_name);
+ if (pos != N_GSYM_name_to_sym_idx.end())
+ {
+ const uint32_t GSYM_sym_idx = pos->second;
+ m_nlist_idx_to_sym_idx[nlist_idx] = GSYM_sym_idx;
+ // Copy the address, because often the N_GSYM address has an invalid address of zero
+ // when the global is a common symbol
+ sym[GSYM_sym_idx].GetAddressRef().SetSection (symbol_section);
+ sym[GSYM_sym_idx].GetAddressRef().SetOffset (symbol_value);
+ // We just need the flags from the linker symbol, so put these flags
+ // into the N_GSYM flags to avoid duplicate symbols in the symbol table
+ sym[GSYM_sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc);
+ sym[sym_idx].Clear();
+ continue;
+ }
}
}
}
OpenPOWER on IntegriCloud