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.cpp59
1 files changed, 26 insertions, 33 deletions
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 96045a9..fe4a23c 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();
@@ -911,6 +896,20 @@ void RewriteInstance::discoverFileObjects() {
continue;
MarkerSymType MarkerType = BC->getMarkerType(SymInfo.Symbol);
+
+ // Treat ST_Function as code.
+ Expected<object::SymbolRef::Type> TypeOrError = SymInfo.Symbol.getType();
+ consumeError(TypeOrError.takeError());
+ if (TypeOrError && *TypeOrError == SymbolRef::ST_Function) {
+ if (IsData) {
+ Expected<StringRef> NameOrError = SymInfo.Symbol.getName();
+ consumeError(NameOrError.takeError());
+ BC->errs() << "BOLT-WARNING: function symbol " << *NameOrError
+ << " lacks code marker\n";
+ }
+ MarkerType = MarkerSymType::CODE;
+ }
+
if (MarkerType != MarkerSymType::NONE) {
SortedMarkerSymbols.push_back(MarkerSym{SymInfo.Address, MarkerType});
LastAddr = SymInfo.Address;
@@ -4260,31 +4259,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);