[PATCH] D109651: [Win64EH] Write .pdata symbol relocations relative to the temporary begin symbol

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 11 12:28:42 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma.
Herald added a subscriber: hiraditya.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

Previously the relocations pointed at the public user facing,
possibly external symbol.

When the function itself is weak, that symbol may be overridden at
link time, pointing at another strong implementation of the same
function instead. In that case, there's two conflicting pdata entries
pointing at the same address, and the wrong unwind info might end up
used.

Both GCC/binutils and MSVC produce pdata pointing at internal static
symbols. (GCC/binutils point at the .text section just as LLVM does
after this change, MSVC points at special label type symbols with the
type IMAGE_SYM_CLASS_LABEL and names like '$LN4'.)

This fixes unwinding through an overridden "operator new" with a
statically linked C++ library in MinGW mode. (Building libc++ with
-ffunction-sections and linking with --gc-sections might avoid the
issue too.)

This makes the produced object files a little less user friendly
to debug, but with the other llvm-readobj patches, the unwind info
debugging experience should be pretty much the same.

Alternatively, we could choose to only do this if the function is
marked as weak - producing less consistent output but more
straightforward object files in most cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109651

Files:
  llvm/lib/MC/MCWin64EH.cpp
  llvm/test/MC/AArch64/seh.s
  llvm/test/MC/COFF/seh-align1.s
  llvm/test/MC/COFF/seh-align2.s
  llvm/test/MC/COFF/seh-align3.s
  llvm/test/MC/COFF/seh.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109651.372094.patch
Type: text/x-patch
Size: 6727 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210911/d9c08381/attachment.bin>


More information about the llvm-commits mailing list