diff --git a/Elf2Mac/Object.cc b/Elf2Mac/Object.cc index 3d583ae3e9..2ff4a590aa 100644 --- a/Elf2Mac/Object.cc +++ b/Elf2Mac/Object.cc @@ -133,11 +133,11 @@ void Object::FlatCode(std::ostream& out) { for(auto sec : codeSections) { - sec->FixRelocs(); + sec->FixRelocs(true); out << sec->GetData(); } - dataSection->FixRelocs(); + dataSection->FixRelocs(true); out << dataSection->GetData(); std::vector relocs; @@ -338,7 +338,7 @@ void Object::MultiSegmentApp(string output, SegmentMap& segmentMap) for(auto namedSec : sections) { - namedSec.second->FixRelocs(); + namedSec.second->FixRelocs(false); } for(auto sec : codeSections) diff --git a/Elf2Mac/Section.cc b/Elf2Mac/Section.cc index fd14ccaf5d..677fc255e3 100644 --- a/Elf2Mac/Section.cc +++ b/Elf2Mac/Section.cc @@ -150,7 +150,7 @@ void Section::ScanRelocs() } } -void Section::FixRelocs() +void Section::FixRelocs(bool allowDirectCodeRefs) { for(Reloc& rela : relocs) { @@ -189,7 +189,7 @@ void Section::FixRelocs() assert(sym.section.get() == this); } } - else + else if(!allowDirectCodeRefs) { if(sym.section.get() != this) { diff --git a/Elf2Mac/Section.h b/Elf2Mac/Section.h index e85930a861..c1a12f1b77 100644 --- a/Elf2Mac/Section.h +++ b/Elf2Mac/Section.h @@ -67,7 +67,7 @@ public: std::vector GetRelocations(bool useOffsets); void ScanRelocs(); - void FixRelocs(); + void FixRelocs(bool allowDirectCodeRefs); };