diff --git a/Elf2Mac/LdScript.cc b/Elf2Mac/LdScript.cc index a28e584d90..45fc65e3a9 100644 --- a/Elf2Mac/LdScript.cc +++ b/Elf2Mac/LdScript.cc @@ -20,11 +20,13 @@ #include "Elf2Mac.h" #include "SegmentMap.h" +#include #include -#include -#include +#include #include +#include + using std::string; const char * scriptStart = R"ld(/* ld script for Elf2Mac */ @@ -214,7 +216,11 @@ void SegmentInfo::WriteFiltersKeep(std::ostream &out, string section) void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint) { - out << "\t.code" << id << " : {\n"; + std::ostringstream ss; + ss << std::setw(5) << std::setfill('0') << id; + const std::string zero_padded_id = ss.str(); + + out << "\t.code" << zero_padded_id << " : {\n"; out << "\t\tFILL(0x4E71);\n"; if(id == 1) { @@ -259,7 +265,7 @@ void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint) if(id == 1) out << "\t\t__EH_FRAME_BEGIN__" << " = .;\n"; else - out << "\t\t__EH_FRAME_BEGIN__" << id << " = .;\n"; + out << "\t\t__EH_FRAME_BEGIN__" << zero_padded_id << " = .;\n"; WriteFiltersKeep(out, ".eh_frame"); out << "\t\tLONG(0);\n"; WriteFiltersKeep(out, ".gcc_except_table"); @@ -278,7 +284,7 @@ void SegmentInfo::CreateLdScript(std::ostream &out, string entryPoint) FILL(0); . += 32; LONG(__EH_FRAME_BEGIN__@N@ - .); -)ld", "@N@", boost::lexical_cast(id)); +)ld", "@N@", zero_padded_id); } out << "\t}\n"; diff --git a/Elf2Mac/Object.cc b/Elf2Mac/Object.cc index f765133260..a90abb3cfc 100644 --- a/Elf2Mac/Object.cc +++ b/Elf2Mac/Object.cc @@ -29,11 +29,12 @@ #include #include #include -#include +#include #include +#include +#include #include -#include #include "ResourceFork.h" #include "BinaryIO.h" @@ -315,7 +316,12 @@ void Object::MultiSegmentApp(string output, SegmentMap& segmentMap) string exceptionInfoMarker = "__EH_FRAME_BEGIN__"; if(id != 1) - exceptionInfoMarker += boost::lexical_cast(id); + { + std::ostringstream ss; + ss << std::setw(5) << std::setfill('0') << id; + const std::string zero_padded_id = ss.str(); + exceptionInfoMarker += zero_padded_id; + } int exceptionInfoSym = symtab->FindSym(exceptionInfoMarker); if(exceptionInfoSym != -1) {