summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/ELF
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2019-01-11 10:18:40 +0000
committerPavel Labath <pavel@labath.sk>2019-01-11 10:18:40 +0000
commit43ddbc0b6c089185eafa3ebd92de2b1120577ac4 (patch)
tree29d064dab31878a11519b08ee0c0c19e1f1026a6 /lldb/source/Plugins/ObjectFile/ELF
parent98ef5337c9dfab72ad8f93a83b6429dfd0da168e (diff)
downloadbcm5719-llvm-43ddbc0b6c089185eafa3ebd92de2b1120577ac4.tar.gz
bcm5719-llvm-43ddbc0b6c089185eafa3ebd92de2b1120577ac4.zip
ELF: Fix base address computation code for files generated by yaml2obj
The code was assuming that the elf file will have a PT_LOAD segment starting from the first byte of the file. While this is true for files generated by most linkers (it's a way of saving space), it is not a requirement. And files not satisfying this constraint can still be perfectly executable. yaml2obj is one of the tools which produces files like this. This patch relaxes the check in ObjectFileELF to take the address of the first PT_LOAD segment as the base address of the object (instead of the one with the offset 0). Since the PT_LOAD segments are supposed to be sorted according to the VM address, this entry will also be the one with the lowest VM address. If we ever run into files which don't have the PT_LOAD segments sorted, we can easily change this code to return the lowest VM address as the base address (if that is the correct thing to do for these files). llvm-svn: 350923
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF')
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 71b535e055b..9a6563afa0a 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1051,7 +1051,7 @@ lldb_private::Address ObjectFileELF::GetEntryPointAddress() {
Address ObjectFileELF::GetBaseAddress() {
for (const auto &EnumPHdr : llvm::enumerate(ProgramHeaders())) {
const ELFProgramHeader &H = EnumPHdr.value();
- if (H.p_type != PT_LOAD || H.p_offset != 0)
+ if (H.p_type != PT_LOAD)
continue;
return Address(
OpenPOWER on IntegriCloud