[all-commits] [llvm/llvm-project] 22a4aa: [BOLT] Don't use section relocations when computin...

treapster via All-commits all-commits at lists.llvm.org
Fri Mar 24 12:08:42 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 22a4aaf2b0d2f54a4db79777273938fc5de75b39
      https://github.com/llvm/llvm-project/commit/22a4aaf2b0d2f54a4db79777273938fc5de75b39
  Author: Denis Revunov <revunov.denis at huawei-partners.com>
  Date:   2023-03-24 (Fri, 24 Mar 2023)

  Changed paths:
    M bolt/lib/Core/BinarySection.cpp
    A bolt/test/AArch64/Inputs/symbol-hashes.yaml
    A bolt/test/AArch64/symbol-hashes.test

  Log Message:
  -----------
  [BOLT] Don't use section relocations when computing hash for data from other section

When computing symbol hashes in BinarySection::hash, we try to find relocations
in the section which reference the passed BinaryData. We do so by doing
lower_bound on data begin offset and upper_bound on data end offset. Since
offsets are relative to the current section, if it is a data from the previous
section, we get underflow when computing offset and lower_bound returns
Relocations.end(). If this data also ends where current section begins,
upper_bound on zero offset will return some valid iterator if we have any
relocations after the first byte. Then we'll try to iterate from lower_bound to
upper_bound, since they're not equal, which in that case means we'll dereference
Relocations.end(), increment it, and try to do so until we reach the second
valid iterator. Of course we reach segfault earlier. In this patch we stop BOLT
from searching relocations for symbols outside of the current section.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D146620




More information about the All-commits mailing list