summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2018-12-11 15:21:15 +0000
committerPavel Labath <pavel@labath.sk>2018-12-11 15:21:15 +0000
commitd1e3fe2190acbd9b38a2badf6e40d2f7014b9ed4 (patch)
treeb9503ea6dfb91ff5720eb6653125cac4c8ab7551
parent2d7f3a3132c4ee87548279faaf10e0eeab7edb36 (diff)
downloadbcm5719-llvm-d1e3fe2190acbd9b38a2badf6e40d2f7014b9ed4.tar.gz
bcm5719-llvm-d1e3fe2190acbd9b38a2badf6e40d2f7014b9ed4.zip
Rename ObjectFile::GetHeaderAddress to GetBaseAddress
Summary: This function was named such because in the case of MachO files, the mach header is located at this address. However all (most?) usages of this function were not interested in that fact, but the fact that this address is used as the base address for expressing various relative addresses in the object file. For other object file formats, this name is not appropriate (and it's probably the reason why this function was not implemented in these classes). In the ELF case the ELF header will usually end up at this address, but this is a result of the linker optimizing the file layout and not a requirement of the spec. For COFF files, I believe the is no header located at this address either. Reviewers: clayborg, jasonmolenda, amccarth, lemo, stella.stamenova Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D55422 llvm-svn: 348849
-rw-r--r--lldb/include/lldb/Symbol/ObjectFile.h18
-rw-r--r--lldb/source/API/SBModule.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectTarget.cpp22
-rw-r--r--lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp12
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h2
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp4
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h2
-rw-r--r--lldb/source/Symbol/CompactUnwindInfo.cpp28
9 files changed, 45 insertions, 47 deletions
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index 1c1e2292cd9..5e66ae4c3af 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -551,18 +551,16 @@ public:
virtual lldb_private::Address GetEntryPointAddress() { return Address(); }
//------------------------------------------------------------------
- /// Returns the address that represents the header of this object file.
+ /// Returns base address of this object file.
///
- /// The header address is defined as where the header for the object file is
- /// that describes the content of the file. If the header doesn't appear in
- /// a section that is defined in the object file, an address with no section
- /// is returned that has the file offset set in the m_file_offset member of
- /// the lldb_private::Address object.
- ///
- /// @return
- /// Returns the entry address for this module.
+ /// This also sometimes referred to as the "preferred load address" or the
+ /// "image base address". Addresses within object files are often expressed
+ /// relative to this base. If this address corresponds to a specific section
+ /// (usually the first byte of the first section) then the returned address
+ /// will have this section set. Otherwise, the address will just have the
+ /// offset member filled in, indicating that this represents a file address.
//------------------------------------------------------------------
- virtual lldb_private::Address GetHeaderAddress() {
+ virtual lldb_private::Address GetBaseAddress() {
return Address(m_memory_addr);
}
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 9c029c518e0..183eae1c2e9 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -587,7 +587,7 @@ lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const {
if (module_sp) {
ObjectFile *objfile_ptr = module_sp->GetObjectFile();
if (objfile_ptr)
- sb_addr.ref() = objfile_ptr->GetHeaderAddress();
+ sb_addr.ref() = objfile_ptr->GetBaseAddress();
}
return sb_addr;
}
diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp
index 4eddc0f9f1c..4a4d0d2d609 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -2969,8 +2969,8 @@ static constexpr OptionDefinition g_target_modules_list_options[] = {
{ LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Display the image at this address." },
{ LLDB_OPT_SET_1, false, "arch", 'A', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the architecture when listing images." },
{ LLDB_OPT_SET_1, false, "triple", 't', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the triple when listing images." },
- { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image header address as a load address if debugging, a file address otherwise." },
- { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image header address offset from the header file address (the slide amount)." },
+ { LLDB_OPT_SET_1, false, "header", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image base address as a load address if debugging, a file address otherwise." },
+ { LLDB_OPT_SET_1, false, "offset", 'o', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the image load address offset from the base file address (the slide amount)." },
{ LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the UUID when listing images." },
{ LLDB_OPT_SET_1, false, "fullpath", 'f', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the fullpath to the image object file." },
{ LLDB_OPT_SET_1, false, "directory", 'd', OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth, "Display the directory with optional width for the image object file." },
@@ -3229,13 +3229,13 @@ protected:
ObjectFile *objfile = module->GetObjectFile();
if (objfile) {
- Address header_addr(objfile->GetHeaderAddress());
- if (header_addr.IsValid()) {
+ Address base_addr(objfile->GetBaseAddress());
+ if (base_addr.IsValid()) {
if (target && !target->GetSectionLoadList().IsEmpty()) {
- lldb::addr_t header_load_addr =
- header_addr.GetLoadAddress(target);
- if (header_load_addr == LLDB_INVALID_ADDRESS) {
- header_addr.Dump(&strm, target,
+ lldb::addr_t load_addr =
+ base_addr.GetLoadAddress(target);
+ if (load_addr == LLDB_INVALID_ADDRESS) {
+ base_addr.Dump(&strm, target,
Address::DumpStyleModuleWithFileAddress,
Address::DumpStyleFileAddress);
} else {
@@ -3243,18 +3243,18 @@ protected:
// Show the offset of slide for the image
strm.Printf(
"0x%*.*" PRIx64, addr_nibble_width, addr_nibble_width,
- header_load_addr - header_addr.GetFileAddress());
+ load_addr - base_addr.GetFileAddress());
} else {
// Show the load address of the image
strm.Printf("0x%*.*" PRIx64, addr_nibble_width,
- addr_nibble_width, header_load_addr);
+ addr_nibble_width, load_addr);
}
}
break;
}
// The address was valid, but the image isn't loaded, output the
// address in an appropriate format
- header_addr.Dump(&strm, target, Address::DumpStyleFileAddress);
+ base_addr.Dump(&strm, target, Address::DumpStyleFileAddress);
break;
}
}
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
index 862e4895022..551f038fa20 100644
--- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -211,13 +211,13 @@ DynamicLoaderDarwinKernel::SearchForKernelAtSameLoadAddr(Process *process) {
exe_objfile->GetStrata() != ObjectFile::eStrataKernel)
return LLDB_INVALID_ADDRESS;
- if (!exe_objfile->GetHeaderAddress().IsValid())
+ if (!exe_objfile->GetBaseAddress().IsValid())
return LLDB_INVALID_ADDRESS;
if (CheckForKernelImageAtAddress(
- exe_objfile->GetHeaderAddress().GetFileAddress(), process) ==
+ exe_objfile->GetBaseAddress().GetFileAddress(), process) ==
exe_module->GetUUID())
- return exe_objfile->GetHeaderAddress().GetFileAddress();
+ return exe_objfile->GetBaseAddress().GetFileAddress();
return LLDB_INVALID_ADDRESS;
}
@@ -931,7 +931,7 @@ bool DynamicLoaderDarwinKernel::KextImageInfo::LoadImageUsingMemoryModule(
ObjectFile *kernel_object_file = m_module_sp->GetObjectFile();
if (kernel_object_file) {
addr_t file_address =
- kernel_object_file->GetHeaderAddress().GetFileAddress();
+ kernel_object_file->GetBaseAddress().GetFileAddress();
if (m_load_address != LLDB_INVALID_ADDRESS &&
file_address != LLDB_INVALID_ADDRESS) {
s->Printf("Kernel slid 0x%" PRIx64 " in memory.\n",
@@ -1005,10 +1005,10 @@ void DynamicLoaderDarwinKernel::LoadKernelModuleIfNeeded() {
ObjectFile *kernel_object_file = m_kernel.GetModule()->GetObjectFile();
if (kernel_object_file) {
addr_t load_address =
- kernel_object_file->GetHeaderAddress().GetLoadAddress(
+ kernel_object_file->GetBaseAddress().GetLoadAddress(
&m_process->GetTarget());
addr_t file_address =
- kernel_object_file->GetHeaderAddress().GetFileAddress();
+ kernel_object_file->GetBaseAddress().GetFileAddress();
if (load_address != LLDB_INVALID_ADDRESS && load_address != 0) {
m_kernel.SetLoadAddress(load_address);
if (load_address != file_address) {
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
index af040322ec5..53eb820746e 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -184,7 +184,7 @@ lldb_private::Address ObjectFileJIT::GetEntryPointAddress() {
return Address();
}
-lldb_private::Address ObjectFileJIT::GetHeaderAddress() { return Address(); }
+lldb_private::Address ObjectFileJIT::GetBaseAddress() { return Address(); }
ObjectFile::Type ObjectFileJIT::CalculateType() { return eTypeJIT; }
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
index 6ff1ecbd297..ec01f1f3eb6 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
@@ -89,7 +89,7 @@ public:
lldb_private::Address GetEntryPointAddress() override;
- lldb_private::Address GetHeaderAddress() override;
+ lldb_private::Address GetBaseAddress() override;
ObjectFile::Type CalculateType() override;
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index dafbb64847c..e6b9c520dd1 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1674,7 +1674,7 @@ void ObjectFileMachO::ProcessSegmentCommand(const load_command &load_cmd_,
} else if (unified_section_sp) {
if (is_dsym && unified_section_sp->GetFileAddress() != load_cmd.vmaddr) {
// Check to see if the module was read from memory?
- if (module_sp->GetObjectFile()->GetHeaderAddress().IsValid()) {
+ if (module_sp->GetObjectFile()->GetBaseAddress().IsValid()) {
// We have a module that is in memory and needs to have its file
// address adjusted. We need to do this because when we load a file
// from memory, its addresses will be slid already, yet the addresses
@@ -5339,7 +5339,7 @@ lldb_private::Address ObjectFileMachO::GetEntryPointAddress() {
return m_entry_point_address;
}
-lldb_private::Address ObjectFileMachO::GetHeaderAddress() {
+lldb_private::Address ObjectFileMachO::GetBaseAddress() {
lldb_private::Address header_addr;
SectionList *section_list = GetSectionList();
if (section_list) {
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
index 50a930aa9c2..02546a5344f 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
@@ -104,7 +104,7 @@ public:
lldb_private::Address GetEntryPointAddress() override;
- lldb_private::Address GetHeaderAddress() override;
+ lldb_private::Address GetBaseAddress() override;
uint32_t GetNumThreadContexts() override;
diff --git a/lldb/source/Symbol/CompactUnwindInfo.cpp b/lldb/source/Symbol/CompactUnwindInfo.cpp
index 7dda877582c..87104707683 100644
--- a/lldb/source/Symbol/CompactUnwindInfo.cpp
+++ b/lldb/source/Symbol/CompactUnwindInfo.cpp
@@ -204,7 +204,7 @@ bool CompactUnwindInfo::GetUnwindPlan(Target &target, Address addr,
if (sl) {
addr_t func_range_start_file_addr =
function_info.valid_range_offset_start +
- m_objfile.GetHeaderAddress().GetFileAddress();
+ m_objfile.GetBaseAddress().GetFileAddress();
AddressRange func_range(func_range_start_file_addr,
function_info.valid_range_offset_end -
function_info.valid_range_offset_start,
@@ -513,7 +513,7 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction(
return false;
addr_t function_offset =
- address.GetFileAddress() - m_objfile.GetHeaderAddress().GetFileAddress();
+ address.GetFileAddress() - m_objfile.GetBaseAddress().GetFileAddress();
UnwindIndex key;
key.function_offset = function_offset;
@@ -578,10 +578,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction(
if (sl) {
uint32_t lsda_offset = GetLSDAForFunctionOffset(
lsda_array_start, lsda_array_count, function_offset);
- addr_t objfile_header_file_address =
- m_objfile.GetHeaderAddress().GetFileAddress();
+ addr_t objfile_base_address =
+ m_objfile.GetBaseAddress().GetFileAddress();
unwind_info.lsda_address.ResolveAddressUsingFileSections(
- objfile_header_file_address + lsda_offset, sl);
+ objfile_base_address + lsda_offset, sl);
}
}
if (unwind_info.encoding & UNWIND_PERSONALITY_MASK) {
@@ -596,10 +596,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction(
SectionList *sl = m_objfile.GetSectionList();
if (sl) {
uint32_t personality_offset = m_unwindinfo_data.GetU32(&offset);
- addr_t objfile_header_file_address =
- m_objfile.GetHeaderAddress().GetFileAddress();
+ addr_t objfile_base_address =
+ m_objfile.GetBaseAddress().GetFileAddress();
unwind_info.personality_ptr_address.ResolveAddressUsingFileSections(
- objfile_header_file_address + personality_offset, sl);
+ objfile_base_address + personality_offset, sl);
}
}
}
@@ -662,10 +662,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction(
if (sl) {
uint32_t lsda_offset = GetLSDAForFunctionOffset(
lsda_array_start, lsda_array_count, function_offset);
- addr_t objfile_header_file_address =
- m_objfile.GetHeaderAddress().GetFileAddress();
+ addr_t objfile_base_address =
+ m_objfile.GetBaseAddress().GetFileAddress();
unwind_info.lsda_address.ResolveAddressUsingFileSections(
- objfile_header_file_address + lsda_offset, sl);
+ objfile_base_address + lsda_offset, sl);
}
}
if (unwind_info.encoding & UNWIND_PERSONALITY_MASK) {
@@ -680,10 +680,10 @@ bool CompactUnwindInfo::GetCompactUnwindInfoForFunction(
SectionList *sl = m_objfile.GetSectionList();
if (sl) {
uint32_t personality_offset = m_unwindinfo_data.GetU32(&offset);
- addr_t objfile_header_file_address =
- m_objfile.GetHeaderAddress().GetFileAddress();
+ addr_t objfile_base_address =
+ m_objfile.GetBaseAddress().GetFileAddress();
unwind_info.personality_ptr_address.ResolveAddressUsingFileSections(
- objfile_header_file_address + personality_offset, sl);
+ objfile_base_address + personality_offset, sl);
}
}
}
OpenPOWER on IntegriCloud