[all-commits] [llvm/llvm-project] 62213b: [LLD][RISCV] Fix incorrect call relaxation when mi...
Philip Reames via All-commits
all-commits at lists.llvm.org
Fri Dec 1 11:03:09 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 62213be8726d8b036c1c1b8fa1f0228608350f17
https://github.com/llvm/llvm-project/commit/62213be8726d8b036c1c1b8fa1f0228608350f17
Author: Philip Reames <preames at rivosinc.com>
Date: 2023-12-01 (Fri, 01 Dec 2023)
Changed paths:
M lld/ELF/Arch/RISCV.cpp
A lld/test/ELF/riscv-relax-call-mixed-rvc.s
Log Message:
-----------
[LLD][RISCV] Fix incorrect call relaxation when mixing +c and -c objects (#73977)
This fixes a mis-link when mixing compressed and non-compressed input to
LLD. When relaxing calls, we must respect the source file that the
section came from when deciding whether it's legal to use compressed
instructions. If the call in question comes from a non-rvc source, then it will not
expect 2-byte alignments and cascading failures may result.
This fixes https://github.com/llvm/llvm-project/issues/63964. The symptom
seen there is that a latter RISCV_ALIGN can't be satisfied and we either
fail an assert or produce a totally bogus link result. (It can be easily
reproduced by putting .p2align 5 right before the nop in the reduced
test case and running check-lld on an assertions enabled build.) However,
it's important to note this is just one possible symptom of the problem.
If the resulting binary has a runtime switch between rvc and non-rvc
routines (via e.g. ifuncs), then even if we manage to link we may execute invalid
instructions on a machine which doesn't implement compressed instructions.
More information about the All-commits
mailing list