[all-commits] [llvm/llvm-project] 70bf5e: [BOLT][AArch64] Symbolize ADRP after relaxation (#...

Maksim Panchenko via All-commits all-commits at lists.llvm.org
Tue Mar 18 14:31:52 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 70bf5e514b21b34b01fb572428f8fbdf267d5c3b
      https://github.com/llvm/llvm-project/commit/70bf5e514b21b34b01fb572428f8fbdf267d5c3b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2025-03-18 (Tue, 18 Mar 2025)

  Changed paths:
    M bolt/lib/Target/AArch64/AArch64MCSymbolizer.cpp
    M bolt/lib/Target/AArch64/AArch64MCSymbolizer.h
    A bolt/test/AArch64/got-load-symbolization.s

  Log Message:
  -----------
  [BOLT][AArch64] Symbolize ADRP after relaxation (#131414)

When the linker relaxes a GOT load, it changes ADRP+LDR instruction pair
into ADRP+ADD. It is relatively straightforward to detect and symbolize
the second instruction in the disassembler. However, it is not always
possible to properly symbolize the ADRP instruction without looking at
the second instruction. Hence, we have the FixRelaxationPass that adjust
the operand of ADRP by looking at the corresponding ADD.

This PR tries to properly symbolize ADRP earlier in the pipeline, i.e.
in AArch64MCSymbolizer. This change makes it easier to adjust the
instruction once we add AArch64 support in `scanExternalRefs()`.
Additionally, we get a benefit of looking at proper operands while
observing the function state prior to running FixRelaxationPass.

To disambiguate the operand of ADRP that has a GOT relocation against
it, we look at the contents/value of the operand. If it contains an
address of a page that is valid for GOT, we assume that the operand
wasn't modified by the linker and leave it up to FixRelaxationPass to do
a proper adjustment. If the page referenced by ADRP cannot point to GOT,
then it's an indication that the linker has modified the operand and we
substitute the operand with a non-GOT reference to the symbol.



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