Skip to content

Commit 7f7d4af

Browse files
committed
Add an option to use PT_GNU_STACK for new segment.
Summary: Added an option to reuse existing program header entry. This option allows for bfd tools like strip and objcopy to operate on the optimized binary without destroying it. Also, all new sections are now properly marked in ELF. (cherry picked from FBD2943339)
1 parent 50c895a commit 7f7d4af

File tree

4 files changed

+264
-93
lines changed

4 files changed

+264
-93
lines changed

bolt/BinaryFunction.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ bool BinaryFunction::fixCFIState() {
879879
return false;
880880
}
881881

882-
for(auto CFI : NewCFIs) {
882+
for (auto CFI : NewCFIs) {
883883
InsertIt = addCFIPseudo(InBB, InsertIt, CFI);
884884
++InsertIt;
885885
}
@@ -977,7 +977,7 @@ void BinaryFunction::modifyLayout(LayoutType Type, bool Split) {
977977
BasicBlockOrderType ReverseOrder;
978978
auto FirstBB = BasicBlocksLayout.front();
979979
ReverseOrder.push_back(FirstBB);
980-
for(auto RBBI = BasicBlocksLayout.rbegin(); *RBBI != FirstBB; ++RBBI)
980+
for (auto RBBI = BasicBlocksLayout.rbegin(); *RBBI != FirstBB; ++RBBI)
981981
ReverseOrder.push_back(*RBBI);
982982
BasicBlocksLayout.swap(ReverseOrder);
983983

@@ -1227,7 +1227,7 @@ void BinaryFunction::modifyLayout(LayoutType Type, bool Split) {
12271227
if (opts::PrintClusters) {
12281228
errs() << "New cluster order: ";
12291229
auto Sep = "";
1230-
for(auto O : Order) {
1230+
for (auto O : Order) {
12311231
errs() << Sep << O;
12321232
Sep = ", ";
12331233
}

bolt/Exceptions.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ void BinaryFunction::updateEHRanges() {
310310
// If previous call can throw, this is its exception handler.
311311
EHInfo PreviousEH = {nullptr, 0};
312312

313-
for(auto &BB : BasicBlocksLayout) {
313+
for (auto &BB : BasicBlocksLayout) {
314314
for (auto II = BB->begin(); II != BB->end(); ++II) {
315315
auto Instr = *II;
316316

@@ -409,7 +409,7 @@ void BinaryFunction::emitLSDA(MCStreamer *Streamer) {
409409
//
410410
// sizeof(dwarf::DW_EH_PE_udata4) * 3 + sizeof(uleb128(action))
411411
uint64_t CallSiteTableLength = CallSites.size() * 4 * 3;
412-
for(const auto &CallSite : CallSites) {
412+
for (const auto &CallSite : CallSites) {
413413
CallSiteTableLength+= getULEB128Size(CallSite.Action);
414414
}
415415

@@ -481,10 +481,10 @@ void BinaryFunction::emitLSDA(MCStreamer *Streamer) {
481481
// There's no need to change the original format we saw on input
482482
// unless we are doing a function splitting in which case we can
483483
// perhaps split and optimize the tables.
484-
for(auto const &Byte : LSDAActionAndTypeTables) {
484+
for (auto const &Byte : LSDAActionAndTypeTables) {
485485
Streamer->EmitIntValue(Byte, 1);
486486
}
487-
for(auto const &Byte : LSDATypeIndexTable) {
487+
for (auto const &Byte : LSDATypeIndexTable) {
488488
Streamer->EmitIntValue(Byte, 1);
489489
}
490490
}

0 commit comments

Comments
 (0)