aboutsummaryrefslogtreecommitdiff
path: root/bolt/lib/Rewrite/RewriteInstance.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'bolt/lib/Rewrite/RewriteInstance.cpp')
-rw-r--r--bolt/lib/Rewrite/RewriteInstance.cpp45
1 files changed, 12 insertions, 33 deletions
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 96045a9..9f243a1 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -714,21 +714,6 @@ Error RewriteInstance::run() {
preprocessProfileData();
- // Skip disassembling if we have a translation table and we are running an
- // aggregation job.
- if (opts::AggregateOnly && BAT->enabledFor(InputFile)) {
- // YAML profile in BAT mode requires CFG for .bolt.org.text functions
- if (!opts::SaveProfile.empty() ||
- opts::ProfileFormat == opts::ProfileFormatKind::PF_YAML) {
- selectFunctionsToProcess();
- disassembleFunctions();
- processMetadataPreCFG();
- buildFunctionsCFG();
- }
- processProfileData();
- return Error::success();
- }
-
selectFunctionsToProcess();
readDebugInfo();
@@ -4260,31 +4245,25 @@ void RewriteInstance::patchELFPHDRTable() {
const ELFFile<ELF64LE> &Obj = ELF64LEFile->getELFFile();
raw_fd_ostream &OS = Out->os();
- // Write/re-write program headers.
Phnum = Obj.getHeader().e_phnum;
- if (PHDRTableOffset) {
- // Writing new pheader table and adding one new entry for R+X segment.
- Phnum += 1;
- if (NewWritableSegmentSize) {
- // Adding one more entry for R+W segment.
- Phnum += 1;
- }
- } else {
+
+ if (BC->NewSegments.empty()) {
+ BC->outs() << "BOLT-INFO: not adding new segments\n";
+ return;
+ }
+
+ if (opts::UseGnuStack) {
assert(!PHDRTableAddress && "unexpected address for program header table");
- PHDRTableOffset = Obj.getHeader().e_phoff;
- if (NewWritableSegmentSize) {
+ if (BC->NewSegments.size() > 1) {
BC->errs() << "BOLT-ERROR: unable to add writable segment\n";
exit(1);
}
+ } else {
+ Phnum += BC->NewSegments.size();
}
- if (opts::Instrument)
- Phnum += 2;
-
- if (BC->NewSegments.empty()) {
- BC->outs() << "BOLT-INFO: not adding new segments\n";
- return;
- }
+ if (!PHDRTableOffset)
+ PHDRTableOffset = Obj.getHeader().e_phoff;
const uint64_t SavedPos = OS.tell();
OS.seek(PHDRTableOffset);