[all-commits] [llvm/llvm-project] 475a93: [BOLT] Calculate output values using BOLTLinker

Job Noorman via All-commits all-commits at lists.llvm.org
Mon Aug 28 01:13:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 475a93a07a6a5d152a2f90ad5510a068f6773357
      https://github.com/llvm/llvm-project/commit/475a93a07a6a5d152a2f90ad5510a068f6773357
  Author: Job Noorman <jnoorman at igalia.com>
  Date:   2023-08-28 (Mon, 28 Aug 2023)

  Changed paths:
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Core/Linker.h
    M bolt/include/bolt/Rewrite/JITLinkLinker.h
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Rewrite/JITLinkLinker.cpp
    M bolt/lib/Rewrite/MachORewriteInstance.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Calculate output values using BOLTLinker

BOLT uses `MCAsmLayout` to calculate the output values of functions and
basic blocks. This means output values are calculated based on a
pre-linking state and any changes to symbol values during linking will
cause incorrect values to be used.

This issue can be triggered by enabling linker relaxation on RISC-V.
Since linker relaxation can remove instructions, symbol values may
change. This causes, among other things, the symbol table created by
BOLT in the output executable to be incorrect.

This patch solves this issue by using `BOLTLinker` to get symbol values
instead of `MCAsmLayout`. This way, output values are calculated based
on a post-linking state. To make sure the linker can update all
necessary symbols, this patch also makes sure all these symbols are not
marked as temporary so that they end-up in the object file's symbol
table.

Note that this patch only deals with symbols of binary functions
(`BinaryFunction::updateOutputValues`). The technique described above
turned out to be too expensive for basic block symbols so those are
handled differently in D155604.

Reviewed By: maksfb

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




More information about the All-commits mailing list