forked from OSchip/llvm-project
Check to make sure we have a valid N_GSYM symbol name before we use it for anything.
llvm-svn: 241210
This commit is contained in:
parent
e521457db3
commit
14cd13c513
lldb/source/Plugins/ObjectFile/Mach-O
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue