diff options
author | Fangrui Song <i@maskray.me> | 2020-11-18 13:52:33 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-11-18 13:52:33 -0800 |
commit | 96d40df71ecee07c69aea512f6c04fc4fbe6acfb (patch) | |
tree | bf31404c269d492403e0cb234321441f766d9108 /lldb/source/Commands/CommandObjectThreadUtil.cpp | |
parent | e597116f055d2e82d9179f6edcb49dd015c514c2 (diff) | |
download | llvm-96d40df71ecee07c69aea512f6c04fc4fbe6acfb.zip llvm-96d40df71ecee07c69aea512f6c04fc4fbe6acfb.tar.gz llvm-96d40df71ecee07c69aea512f6c04fc4fbe6acfb.tar.bz2 |
MCExpr::evaluateAsRelocatableImpl : allow evaluation of non-VK_None MCSymbolRefExpr when MCAsmLayout is available
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4acf8c78e659833be8be047ba2f8561386a11d4b
(1994) introduced this behavior:
if a fixup symbol is equated to an expression with an undefined symbol, convert
the fixup to be against the target symbol. glibc relies on this behavior to perform
assembly level indirection
```
asm("memcpy = __GI_memcpy"); // from sysdeps/generic/symbol-hacks.h
...
// call memcpy@PLT
// The relocation references __GI_memcpy in GNU as, but memcpy in MC (without the patch)
memcpy (...);
```
(1) It complements `extern __typeof(memcpy) memcpy asm("__GI_memcpy");` The frontend asm label does not redirect synthesized memcpy in the middle-end. (See D88712 for details)
(2) `asm("memcpy = __GI_memcpy");` is in every translation unit, but the memcpy declaration may not be visible in the translation unit where memcpy is synthesized.
MC already redirects `memcpy = __GI_memcpy; call memcpy` but not `memcpy = __GI_memcpy; call memcpy@plt`.
This patch fixes the latter by allowing MCExpr::evaluateAsRelocatableImpl to
evaluate a non-VK_None MCSymbolRefExpr, which is only done after the layout is available.
GNU as allows `memcpy = __GI_memcpy+1; call memcpy@PLT` which seems nonsensical, so we don't allow it.
`MC/PowerPC/pr38945.s` `NUMBER = 0x6ffffff9; cmpwi 8,NUMBER@l` requires the
`symbol@l` form in AsmMatcher, so evaluation needs to be deferred. This is the
place whether future simplification may be possible.
Note, if we suppress the VM_None evaluation when MCAsmLayout is nullptr, we may
lose the `invalid reassignment of non-absolute variable` diagnostic
(`ARM/thumb_set-diagnostics.s` and `MC/AsmParser/variables-invalid.s`).
We know that this diagnostic is troublesome in some cases
(https://github.com/ClangBuiltLinux/linux/issues/1008), so we can consider
making simplification in the future.
Reviewed By: jyknight
Differential Revision: https://reviews.llvm.org/D88625
Diffstat (limited to 'lldb/source/Commands/CommandObjectThreadUtil.cpp')
0 files changed, 0 insertions, 0 deletions