[llvm-dev] Assertion error with @PLT modifier

Leonard Chan via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 4 14:58:31 PDT 2020


Hi all,

I'm hitting this assertion error in llvm:

```
clang-11:
/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-2/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp:119:
virtual unsigned int (anonymous
namespace)::AArch64ELFObjectWriter::getRelocType(llvm::MCContext &, const
llvm::MCValue &, const llvm::MCFixup &, bool) const: Assertion
`(!Target.getSymA() || Target.getSymA()->getKind() ==
MCSymbolRefExpr::VK_None) && "Should only be expression-level modifiers
here"' failed.
```

when attempting to compile

```
obj:
  .word func at PLT - .
```

for aarch64-unknown-linux. This assertion only appears when adding the
`@PLT`. Otherwise, it compiles without errors. From what I understand, this
syntax should still be valid for AArch64. Is there another reason this
assertion is triggered, or perhaps there's something invalid with my
example?

The context is I'm attempting to implement a new AArch64 relocation (see
https://reviews.llvm.org/D81184 for reference) which attempts to take the
relative offset to a function. If it's not dso_local, we should instead
take the offset to the PLT entry for it. I know how to programatically add
it through `PLTRelativeVariantKind
<https://cs.corp.google.com/piper///depot/google3/third_party/llvm/llvm-project/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?l=36&gs=kythe%253A%252F%252Fgoogle3%253Flang%253Dc%25252B%25252B%253Fpath%253Dthird_party%252Fllvm%252Fllvm-project%252Fllvm%252Finclude%252Fllvm%252FCodeGen%252FTargetLoweringObjectFileImpl.h%2523An-UbhAAWTwX3e3EcidlHLg-1PQfGVpIcOAJZBma4ZQ&gsn=PLTRelativeVariantKind&ct=xref_usages>`
used by `lowerRelativeReference()`, but setting this to anything other than
`VK_None` for AArch64 results in this assertion error.

Thanks,
Leonard

CCing Tim Northover who authored the assertion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200604/bd966ebe/attachment.html>


More information about the llvm-dev mailing list