[all-commits] [llvm/llvm-project] 33e030: [BOLT] Add validation for direct call/branch targe...

Jinjie Huang via All-commits all-commits at lists.llvm.org
Tue Dec 9 00:17:41 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 33e0301b072860259cfd0a5032e69f92d7e2784c
      https://github.com/llvm/llvm-project/commit/33e0301b072860259cfd0a5032e69f92d7e2784c
  Author: Jinjie Huang <huangjinjie at bytedance.com>
  Date:   2025-12-09 (Tue, 09 Dec 2025)

  Changed paths:
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    M bolt/test/AArch64/constant-island-alignment.s
    A bolt/test/AArch64/validate-branch-target.s
    A bolt/test/X86/validate-branch-target.s

  Log Message:
  -----------
  [BOLT] Add validation for direct call/branch targets (#165406)

In some edge cases, a binary may contain direct `branch` or `call`
instructions whose target do not point to a valid executable
instruction. This can occur due to compiler bugs, hand-written assembly,
obfuscation technique, **or when control flow targets a data by
mistake.**

We also encountered the problems as described in this
[issue](https://github.com/llvm/llvm-project/issues/149382), where "data
in code" within OpenSSL's hand-written assembly was misidentified as
instructions(island identification seems fail due to the absence of a
corresponding data symbol). The problem occurred because a data sequence
was incorrectly disassembled as a "jb" instruction.

The point here is that the data should not be pointed to by any edge, so
this patch tries to address this by validating the destination address
for **direct branches and calls**. If the target instruction is
invalid(implies a corrupted control flow), this function will be set
ignored.

Although this approach appears helpful for addressing the 'data in code'
problem, its validation might be compromised if the data can be
disassembled as normal instruction.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list