[PATCH] D153239: [XRay] Make xray_instr_map compatible with Mach-O

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 18 21:18:42 PDT 2023


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

The `__DATA,xray_instr_map` section has label differences like
`.quad Lxray_sled_0-Ltmp0` that is represented as a pair of UNSIGNED and SUBTRACTOR relocations.
The SUBTRACTOR external relocation needs to reference a non-temporary symbol while
`__DATA,xray_instr_map` doesn't currently define one, therefore we will see
linker errors like:

  error: SUBTRACTOR relocation must be extern at offset 0 of __DATA,xray_instr_map in a.o

To fix this, change `Lxray_sleds_start0` to `lxray_sleds_start0` to provide an
non-temporary symbol that is linker private (which will not appear in the linked
image).

`lxray_sleds_start0` also serves as the atom for this dead-strippable
subsection. With the `S_ATTR_LIVE_SUPPORT` attribute, `ld -dead_strip` will
retain subsections that reference live functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153239

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.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-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: D153239.532526.patch
Type: text/x-patch
Size: 14332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230619/5e01721a/attachment.bin>


More information about the llvm-commits mailing list