Resubmitting 240466 after fixing the linux test suite failures.
A few extras were fixed
- Symbol::GetAddress() now returns an Address object, not a reference. There were places where people were accessing the address of a symbol when the symbol's value wasn't an address symbol. On MacOSX, undefined symbols have a value zero and some places where using the symbol's address and getting an absolute address of zero (since an Address object with no section and an m_offset whose value isn't LLDB_INVALID_ADDRESS is considered an absolute address). So fixing this required some changes to make sure people were getting what they expected.
- Since some places want to access the address as a reference, I added a few new functions to symbol:
Address &Symbol::GetAddressRef();
const Address &Symbol::GetAddressRef() const;
Linux test suite passes just fine now.
<rdar://problem/21494354>
llvm-svn: 240702
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index bdc13e7..1ceaa2c 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2381,7 +2381,7 @@
symbol = symtab->FindSymbolByID(reloc_symbol(rel));
if (symbol)
{
- addr_t value = symbol->GetAddress().GetFileAddress();
+ addr_t value = symbol->GetAddressRef().GetFileAddress();
DataBufferSP& data_buffer_sp = debug_data.GetSharedDataBuffer();
uint64_t* dst = reinterpret_cast<uint64_t*>(data_buffer_sp->GetBytes() + rel_section->GetFileOffset() + ELFRelocation::RelocOffset64(rel));
*dst = value + ELFRelocation::RelocAddend64(rel);
@@ -2394,7 +2394,7 @@
symbol = symtab->FindSymbolByID(reloc_symbol(rel));
if (symbol)
{
- addr_t value = symbol->GetAddress().GetFileAddress();
+ addr_t value = symbol->GetAddressRef().GetFileAddress();
value += ELFRelocation::RelocAddend32(rel);
assert((reloc_type(rel) == R_X86_64_32 && (value <= UINT32_MAX)) ||
(reloc_type(rel) == R_X86_64_32S &&
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index c61f871..511d73d 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1271,7 +1271,7 @@
{
if (symbol->ValueIsAddress())
{
- SectionSP section_sp (symbol->GetAddress().GetSection());
+ SectionSP section_sp (symbol->GetAddressRef().GetSection());
if (section_sp)
{
const lldb::SectionType section_type = section_sp->GetType();
@@ -3521,8 +3521,8 @@
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].GetAddress().SetSection (symbol_section);
- sym[GSYM_sym_idx].GetAddress().SetOffset (symbol_value);
+ 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);
@@ -3537,8 +3537,8 @@
sym[sym_idx].SetType (type);
if (set_value)
{
- sym[sym_idx].GetAddress().SetSection (symbol_section);
- sym[sym_idx].GetAddress().SetOffset (symbol_value);
+ sym[sym_idx].GetAddressRef().SetSection (symbol_section);
+ sym[sym_idx].GetAddressRef().SetOffset (symbol_value);
}
sym[sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc);
@@ -4364,8 +4364,8 @@
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].GetAddress().SetSection (symbol_section);
- sym[GSYM_sym_idx].GetAddress().SetOffset (symbol_value);
+ 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);
@@ -4380,8 +4380,8 @@
sym[sym_idx].SetType (type);
if (set_value)
{
- sym[sym_idx].GetAddress().SetSection (symbol_section);
- sym[sym_idx].GetAddress().SetOffset (symbol_value);
+ sym[sym_idx].GetAddressRef().SetSection (symbol_section);
+ sym[sym_idx].GetAddressRef().SetOffset (symbol_value);
}
sym[sym_idx].SetFlags (nlist.n_type << 16 | nlist.n_desc);
@@ -4475,7 +4475,7 @@
sym[sym_idx].GetMangled().SetDemangledName(ConstString(synthetic_function_symbol));
sym[sym_idx].SetType (eSymbolTypeCode);
sym[sym_idx].SetIsSynthetic (true);
- sym[sym_idx].GetAddress() = symbol_addr;
+ sym[sym_idx].GetAddressRef() = symbol_addr;
if (symbol_flags)
sym[sym_idx].SetFlags (symbol_flags);
if (symbol_byte_size)
@@ -4559,7 +4559,7 @@
else
stub_symbol->SetType (eSymbolTypeResolver);
stub_symbol->SetExternal (false);
- stub_symbol->GetAddress() = so_addr;
+ stub_symbol->GetAddressRef() = so_addr;
stub_symbol->SetByteSize (symbol_stub_byte_size);
}
else
@@ -4578,7 +4578,7 @@
else
sym[sym_idx].SetType (eSymbolTypeResolver);
sym[sym_idx].SetIsSynthetic (true);
- sym[sym_idx].GetAddress() = so_addr;
+ sym[sym_idx].GetAddressRef() = so_addr;
sym[sym_idx].SetByteSize (symbol_stub_byte_size);
++sym_idx;
}
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 5f7935e..8189f10 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -574,7 +574,7 @@
if ((int16_t)symbol.sect >= 1)
{
Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
- symbols[i].GetAddress() = symbol_addr;
+ symbols[i].GetAddressRef() = symbol_addr;
}
if (symbol.naux > 0)
@@ -633,7 +633,7 @@
Address symbol_addr(m_coff_header_opt.image_base + function_rva, sect_list);
symbols[i].GetMangled().SetValue(ConstString(symbol_name.c_str()));
- symbols[i].GetAddress() = symbol_addr;
+ symbols[i].GetAddressRef() = symbol_addr;
symbols[i].SetType(lldb::eSymbolTypeCode);
symbols[i].SetDebug(true);
}