[PATCH] D145850: [AsmPrinter] Use linker-private symbols in xray_instr_map

Oleksii Lozovskyi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 11 08:03:18 PST 2023


ilammy created this revision.
ilammy added reviewers: MaskRay, ianlevesque, dberris.
ilammy added a project: LLVM.
Herald added subscribers: pengfei, arphaman, hiraditya.
Herald added a project: All.
ilammy requested review of this revision.
Herald added a subscriber: llvm-commits.

When compiling with -fxray-instrument for Apple platforms, XRay pass
generates relocation entries that offend Mach-O linker on x86_64.

All emitted entries in xray_instr_map use local labels, so the entire
section ends up filled with local (r_extern=0) relocations, which is
not allowed on x86_64 in Mach-O.

The linker is able to figure it out as long as there is at least one
external relocation in the section, making all local relocations
piggyback on the external one before them. Indulge the linker with
some "private" symbols, which are considered external for relocation
purposes, but are otherwise local to object files (i.e., "static",
do not get globally exported and are generally removed after linking).

Depends on D145291 <https://reviews.llvm.org/D145291>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145850

Files:
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
  llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
  llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-entry.ll
  llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-exit.ll
  llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
  llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
  llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
  llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
  llvm/test/CodeGen/X86/xray-custom-log.ll
  llvm/test/CodeGen/X86/xray-log-args.ll
  llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
  llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
  llvm/test/CodeGen/X86/xray-tail-call-sled.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145850.504370.patch
Type: text/x-patch
Size: 17470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230311/c6710ad1/attachment-0001.bin>


More information about the llvm-commits mailing list