[PATCH] D131432: [Thumb] Baseline test for incorrect relocation with -ffunction-sections

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 13:21:33 PDT 2022


arichardson created this revision.
Herald added a project: All.
arichardson requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When calling a dso_local function, we end up creating a call against the
.Lfoo$local label. This might be converted to a relocation against a
section if there is such a matching one (which is a lot more likely with
-ffunction-sections) and then the LSB (Thumb flag) will be lost.

I originally noticed this with Morello LLVM (which uses the LSB to indicate
a C64 encoding mode function). The missing LSB meant that ld.lld would
insert a thunk that switches encoding mode which then resulted in errors
at runtime since functions were being entered with the wrong encoding mode.
Since the Morello backend is not upstream, I looked if any in-tree
backends could also be affected by the missing STT_FUNC flag and noticed
that Thumb is also affected (although the bug is rather difficult to
trigger - it currently requires inline assembly).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131432

Files:
  llvm/test/CodeGen/ARM/thumb-function-section-reloc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131432.450918.patch
Type: text/x-patch
Size: 4314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220808/b390e0d6/attachment.bin>


More information about the llvm-commits mailing list