[llvm] [BOLT] Add validation for direct call/branch targets, bypassing invalid functions (PR #165406)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 20:07:50 PST 2025


================
@@ -531,20 +531,39 @@ BinaryContext::handleAddressRef(uint64_t Address, BinaryFunction &BF,
 }
 
 MCSymbol *BinaryContext::handleExternalBranchTarget(uint64_t Address,
-                                                    BinaryFunction &BF) {
-  if (BF.isInConstantIsland(Address)) {
-    BF.setIgnored();
-    this->outs() << "BOLT-WARNING: ignoring entry point at address 0x"
-                 << Twine::utohexstr(Address)
-                 << " in constant island of function " << BF << '\n';
-    return nullptr;
+                                                    BinaryFunction &Source,
+                                                    BinaryFunction &Target) {
+  const uint64_t Offset = Address - Target.getAddress();
+  assert(Offset < Target.getSize() &&
+         "Address should be inside the referenced function");
+
+  bool IsValid = true;
+  if (Source.NeedBranchValidation) {
----------------
maksfb wrote:

Is this a problem beyond the function being reported twice?

https://github.com/llvm/llvm-project/pull/165406


More information about the llvm-commits mailing list