[PATCH] D132425: [clang] Do not instrument relative vtables under hwasan

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 22 17:24:24 PDT 2022


leonardchan created this revision.
leonardchan added reviewers: mcgrathr, eugenis, phosek, vitalybuka.
leonardchan added a project: clang.
Herald added subscribers: abrachet, kristof.beyls.
Herald added a project: All.
leonardchan requested review of this revision.

Full context in https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=107017.

Instrumenting hwasan with globals results in a linker error under the relative vtables abi:

  

ld.lld: error: libunwind.cpp:(.rodata..L_ZTVN9libunwind12UnwindCursorINS_17LocalAddressSpaceENS_15Registers_arm64EEE.hwasan+0x8): relocation R_AARCH64_PLT32 out of range: 6845471433603167792 is not in [-2147483648, 2147483647]; references libunwind::AbstractUnwindCursor::~AbstractUnwindCursor()

>>> defined in libunwind/src/CMakeFiles/unwind_shared.dir/libunwind.cpp.obj

  This is because the tag is included in the vtable address when calculating the offset between the vtable and virtual function. A temporary solution until we can resolve this is to just disable hwasan instrumentation on relative vtables specifically, which can be done in the frontend.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132425

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CGVTables.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/RelativeVTablesABI/relative-vtables-hwasan.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132425.454659.patch
Type: text/x-patch
Size: 4351 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220823/f57d59ec/attachment-0001.bin>


More information about the cfe-commits mailing list