fix data-to-code references for single-segment apps and code resources

This commit is contained in:
Wolfgang Thaller 2018-02-22 22:05:35 +01:00
parent 88d7614612
commit 1bf9012d5e
3 changed files with 6 additions and 6 deletions

View File

@ -133,11 +133,11 @@ void Object::FlatCode(std::ostream& out)
{ {
for(auto sec : codeSections) for(auto sec : codeSections)
{ {
sec->FixRelocs(); sec->FixRelocs(true);
out << sec->GetData(); out << sec->GetData();
} }
dataSection->FixRelocs(); dataSection->FixRelocs(true);
out << dataSection->GetData(); out << dataSection->GetData();
std::vector<RuntimeReloc> relocs; std::vector<RuntimeReloc> relocs;
@ -338,7 +338,7 @@ void Object::MultiSegmentApp(string output, SegmentMap& segmentMap)
for(auto namedSec : sections) for(auto namedSec : sections)
{ {
namedSec.second->FixRelocs(); namedSec.second->FixRelocs(false);
} }
for(auto sec : codeSections) for(auto sec : codeSections)

View File

@ -150,7 +150,7 @@ void Section::ScanRelocs()
} }
} }
void Section::FixRelocs() void Section::FixRelocs(bool allowDirectCodeRefs)
{ {
for(Reloc& rela : relocs) for(Reloc& rela : relocs)
{ {
@ -189,7 +189,7 @@ void Section::FixRelocs()
assert(sym.section.get() == this); assert(sym.section.get() == this);
} }
} }
else else if(!allowDirectCodeRefs)
{ {
if(sym.section.get() != this) if(sym.section.get() != this)
{ {

View File

@ -67,7 +67,7 @@ public:
std::vector<RuntimeReloc> GetRelocations(bool useOffsets); std::vector<RuntimeReloc> GetRelocations(bool useOffsets);
void ScanRelocs(); void ScanRelocs();
void FixRelocs(); void FixRelocs(bool allowDirectCodeRefs);
}; };