Skip to content

Commit c16fad4

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/85447
2 parents f4e4e7b + 0647b2a commit c16fad4

File tree

1,124 files changed

+223422
-91590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,124 files changed

+223422
-91590
lines changed

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ class RewriteInstance {
422422
/// Section name used for extra BOLT code in addition to .text.
423423
static StringRef getBOLTTextSectionName() { return ".bolt.text"; }
424424

425+
/// Symbol markers for BOLT reserved area.
426+
static StringRef getBOLTReservedStart() { return "__bolt_reserved_start"; }
427+
static StringRef getBOLTReservedEnd() { return "__bolt_reserved_end"; }
428+
425429
/// Common section names.
426430
static StringRef getEHFrameSectionName() { return ".eh_frame"; }
427431
static StringRef getEHFrameHdrSectionName() { return ".eh_frame_hdr"; }
@@ -494,6 +498,9 @@ class RewriteInstance {
494498
/// Store all non-zero symbols in this map for a quick address lookup.
495499
std::map<uint64_t, llvm::object::SymbolRef> FileSymRefs;
496500

501+
/// FILE symbols used for disambiguating split function parents.
502+
std::vector<ELFSymbolRef> FileSymbols;
503+
497504
std::unique_ptr<DWARFRewriter> DebugInfoRewriter;
498505

499506
std::unique_ptr<BoltAddressTranslation> BAT;

bolt/include/bolt/Utils/NameResolver.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,23 @@ class NameResolver {
2828
static constexpr char Sep = '/';
2929

3030
public:
31-
/// Return unique version of the \p Name in the form "Name<Sep><Number>".
31+
/// Return the number of uniquified versions of a given \p Name.
32+
uint64_t getUniquifiedNameCount(StringRef Name) const {
33+
if (Counters.contains(Name))
34+
return Counters.at(Name);
35+
return 0;
36+
}
37+
38+
/// Return unique version of the \p Name in the form "Name<Sep><ID>".
39+
std::string getUniqueName(StringRef Name, const uint64_t ID) const {
40+
return (Name + Twine(Sep) + Twine(ID)).str();
41+
}
42+
43+
/// Register new version of \p Name and return unique version in the form
44+
/// "Name<Sep><Number>".
3245
std::string uniquify(StringRef Name) {
3346
const uint64_t ID = ++Counters[Name];
34-
return (Name + Twine(Sep) + Twine(ID)).str();
47+
return getUniqueName(Name, ID);
3548
}
3649

3750
/// For uniquified \p Name, return the original form (that may no longer be

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
248248
/// Update ORC data in the binary.
249249
Error rewriteORCTables();
250250

251+
/// Validate written ORC tables after binary emission.
252+
Error validateORCTables();
253+
251254
/// Static call table handling.
252255
Error readStaticCalls();
253256
Error rewriteStaticCalls();
@@ -358,6 +361,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
358361
if (Error E = updateStaticKeysJumpTablePostEmit())
359362
return E;
360363

364+
if (Error E = validateORCTables())
365+
return E;
366+
361367
return Error::success();
362368
}
363369
};
@@ -837,6 +843,32 @@ Error LinuxKernelRewriter::rewriteORCTables() {
837843
return Error::success();
838844
}
839845

846+
Error LinuxKernelRewriter::validateORCTables() {
847+
if (!ORCUnwindIPSection)
848+
return Error::success();
849+
850+
const uint64_t IPSectionAddress = ORCUnwindIPSection->getAddress();
851+
DataExtractor IPDE = DataExtractor(ORCUnwindIPSection->getOutputContents(),
852+
BC.AsmInfo->isLittleEndian(),
853+
BC.AsmInfo->getCodePointerSize());
854+
DataExtractor::Cursor IPCursor(0);
855+
uint64_t PrevIP = 0;
856+
for (uint32_t Index = 0; Index < NumORCEntries; ++Index) {
857+
const uint64_t IP =
858+
IPSectionAddress + IPCursor.tell() + (int32_t)IPDE.getU32(IPCursor);
859+
if (!IPCursor)
860+
return createStringError(errc::executable_format_error,
861+
"out of bounds while reading ORC IP table: %s",
862+
toString(IPCursor.takeError()).c_str());
863+
864+
assert(IP >= PrevIP && "Unsorted ORC table detected");
865+
(void)PrevIP;
866+
PrevIP = IP;
867+
}
868+
869+
return Error::success();
870+
}
871+
840872
/// The static call site table is created by objtool and contains entries in the
841873
/// following format:
842874
///

0 commit comments

Comments
 (0)