From 1bf9012d5ec7bff6a26bb15bc3643913e097b993 Mon Sep 17 00:00:00 2001 From: Wolfgang Thaller Date: Thu, 22 Feb 2018 22:05:35 +0100 Subject: [PATCH] fix data-to-code references for single-segment apps and code resources --- Elf2Mac/Object.cc | 6 +++--- Elf2Mac/Section.cc | 4 ++-- Elf2Mac/Section.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) 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); };