aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
diff options
context:
space:
mode:
authorHiroshi Yamauchi <hjyamauchi@gmail.com>2023-08-03 15:57:28 -0700
committerHiroshi Yamauchi <hjyamauchi@gmail.com>2023-08-04 13:38:30 -0700
commite9040e875d9252f726c41579f70663154718c3c6 (patch)
tree61003ff32967d1ea97a7d8267957839577e6bd61 /lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
parent2b1bdc9f0bc64af02204c746eead0dd304c128da (diff)
downloadllvm-e9040e875d9252f726c41579f70663154718c3c6.zip
llvm-e9040e875d9252f726c41579f70663154718c3c6.tar.gz
llvm-e9040e875d9252f726c41579f70663154718c3c6.tar.bz2
[lldb][PECOFF] Exclude alignment padding when reading section data
There can be zero padding bytes at a section end for file alignment in PECOFF. Exclude those padding bytes when reading the section data. Differential Revision: https://reviews.llvm.org/D157059
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 77506b40..3941d6b 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1027,6 +1027,16 @@ SectionType ObjectFilePECOFF::GetSectionType(llvm::StringRef sect_name,
return eSectionTypeOther;
}
+size_t ObjectFilePECOFF::GetSectionDataSize(Section *section) {
+ // For executables, SizeOfRawData (getFileSize()) is aligned by
+ // FileAlignment and the actual section size is in VirtualSize
+ // (getByteSize()). See the comment on
+ // llvm::object::COFFObjectFile::getSectionSize().
+ if (m_binary->getPE32Header() || m_binary->getPE32PlusHeader())
+ return std::min(section->GetByteSize(), section->GetFileSize());
+ return section->GetFileSize();
+}
+
void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
if (m_sections_up)
return;