@@ -474,7 +474,7 @@ bool ElfView::Init()
474
474
{
475
475
if (settings->Contains (" loader.imageBase" ))
476
476
preferredImageBase = settings->Get <uint64_t >(" loader.imageBase" , this );
477
-
477
+
478
478
if (settings->Contains (" loader.platform" ))
479
479
{
480
480
BNSettingsScope scope = SettingsAutoScope;
@@ -658,11 +658,10 @@ bool ElfView::Init()
658
658
semantics = ReadOnlyDataSectionSemantics;
659
659
else if ((m_elfSections[i].flags & ELF_SHF_WRITE) || In (sectionNames[i], readWriteDataSectionNames))
660
660
semantics = ReadWriteDataSectionSemantics;
661
-
662
661
if (m_elfSections[i].size != 0 )
663
662
{
664
663
if (m_programHeaders.size () == 0 )
665
- {
664
+ {
666
665
// We have an object file so we'll just create segments for the sections
667
666
uint32_t flags = 0 ;
668
667
if (semantics == ReadOnlyCodeSectionSemantics)
@@ -671,11 +670,22 @@ bool ElfView::Init()
671
670
flags = SegmentReadable | SegmentWritable;
672
671
else if (semantics == ReadOnlyDataSectionSemantics)
673
672
flags = SegmentReadable;
674
- m_elfSections[i].address = segmentStart;
675
- size_t size = m_elfSections[i].type == ELF_SHT_NOBITS ? 0 : m_elfSections[i].size ;
676
- uint64_t adjustedSectionAddr = m_elfSections[i].address + imageBaseAdjustment;
677
- AddAutoSegment (adjustedSectionAddr, m_elfSections[i].size , m_elfSections[i].offset , size, flags);
678
- segmentStart += ((m_elfSections[i].size + 15 ) & ~15 );
673
+ if ((m_commonHeader.type == ET_DYN) && (!m_parseOnly))
674
+ {
675
+ // We have a shared object file without program headers so we'll create segments for the sections
676
+ // based on the section address.
677
+ size_t size = m_elfSections[i].type == ELF_SHT_NOBITS ? 0 : m_elfSections[i].size ;
678
+ uint64_t adjustedSectionAddr = m_elfSections[i].address + imageBaseAdjustment;
679
+ AddAutoSegment (adjustedSectionAddr, m_elfSections[i].size , m_elfSections[i].offset , size, flags);
680
+ }
681
+ else
682
+ {
683
+ m_elfSections[i].address = segmentStart;
684
+ size_t size = m_elfSections[i].type == ELF_SHT_NOBITS ? 0 : m_elfSections[i].size ;
685
+ uint64_t adjustedSectionAddr = m_elfSections[i].address + imageBaseAdjustment;
686
+ AddAutoSegment (adjustedSectionAddr, m_elfSections[i].size , m_elfSections[i].offset , size, flags);
687
+ segmentStart += ((m_elfSections[i].size + 15 ) & ~15 );
688
+ }
679
689
}
680
690
else if ((m_elfSections[i].address + m_elfSections[i].size + imageBaseAdjustment) > GetEnd () || ((m_elfSections[i].address + imageBaseAdjustment) < GetStart ()))
681
691
{
@@ -690,7 +700,6 @@ bool ElfView::Init()
690
700
GetParentView ()->AddAutoSection (sectionNames[i], m_elfSections[i].offset , m_elfSections[i].size , DefaultSectionSemantics, type, m_elfSections[i].align , m_elfSections[i].entrySize , linkedSection, infoSection, m_elfSections[i].info );
691
701
}
692
702
}
693
-
694
703
// Apply architecture and platform
695
704
if (!m_arch)
696
705
{
0 commit comments