-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LLVM 12 regression: ld.lld: error: test.o:(.rodata.str1.1): offset is outside the section #49165
Comments
assigned to @tstellar |
In what previous LLVM version did it work correctly? |
LLVM 11 |
Can we get a bisect on this? |
The reason why I asked when it worked is that the minimal reproducer failed on LLVM11 too for me, so I couldn't bisect, but I think I figured out what I was doing wrong before. Bisect running! |
I got the bisect-run condition backwards (ugh) but it landed me on (a revert of) https://reviews.llvm.org/D64327 which seems plausible. Running it properly now, hopefully I will get the same result. |
I confirm doing the bisect correctly ends up here: https://reviews.llvm.org/rG72e75ca343c6ff927a2242efee3f4640943eedd6
So if I understand this correctly, lld never supported this, but llvm 11 MC didn't emit it and llvm 12 does? That explains my problem bisecting it before, I was only re-running lld (and in llvm 11 it failed in the same way given the same .o) but I wasn't re-assembling the .s into .o. |
Same here when building mips world for FreeBSD: ... I guess reverting rG72e75ca343c6ff927a2242efee3f4640943eedd6 is not feasible? |
Alternatively, maybe put an exception there for EM_MIPS in the mean time? |
I think now it's the best workaround. A root of the problem is in the R_MIPS_LO16 relocation handling. Both R_MIPS_HI16 and R_MIPS_LO16 are considered as absolute relocations (the type is R_ABS). When we calculate R_MIPS_HI16's addend we find a paired R_MIPS_LO16, generate combined addend and return correct symbol value from the InputSectionBase::getRelocTargetVA. For R_MIPS_LO16 we do not do that and use its addend as is. Probably we should introduce new expression type for these relocations (like R_RISCV_PC_INDIRECT for R_RISCV_PCREL_HI20 / R_RISCV_PCREL_LO12) and calculate a correct symbol value for both relocations at the InputSectionBase::getRelocTargetVA. Unfortunately I do not have a time to fix it by myself right now. |
As a local workaround I now have: --- a/contrib/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp
|
I'd suggest we split the
out to a separate condition with a new comment describing the issue from comment #9. |
Review posted at https://reviews.llvm.org/D101773. |
Fix re-landed in: Tom, can we please merge this to the 12.x branch after it has baked a little? (I'm removing bug 48902 from the "Blocks:" field, but not bug 49317) |
I just tested with LLVM 12.0.1 RC1, and the bug is still present. Did the fix get cherry picked into the release/12.x branch? |
Not yet, it seems; but it's still marked as a blocker for bug 49317, so hopefully it'll get picked up for rc2. |
The MC/Mips/elf-relsym.s test fails when I backport this patch. Can someone take a look at this? |
Additional patch for 7e83a7f1fdfcc2edde61f0a535f9d7a56f531db9 cherry-pick
For some reason, 12.0 outputs the symbols in a different order, so the following adjustment is needed, on top of the cherry-pick: diff --git a/llvm/test/MC/Mips/elf-relsym.s b/llvm/test/MC/Mips/elf-relsym.s // CHECK: Symbols [
(I don't think FileCheck can be told the order doesn't matter...) |
Merged: fec90b2 |
Extended Description
A regression in LLVM12 (tested on rc2, rc4) is causing Zig test suite to fail on the target mips-linux.
ld.lld: error: /home/andy/Downloads/zig/zig-cache/o/7da08f6c0f092ce043d5af1591728354/test.o:(.rodata.str1.1): offset is outside the section
The following command exited with error code 1:
/home/andy/Downloads/zig/build-llvm12/zig test /home/andy/Downloads/zig/test/stage1/behavior.zig --test-name-prefix behavior-mips-linux-none-Debug-bare-multi --cache-dir /home/andy/Downloads/zig/zig-cache --global-cache-dir /home/andy/.cache/zig --name test -target mips-linux-none --test-cmd qemu-mips --test-cmd-bin -I /home/andy/Downloads/zig/test -L /home/andy/local/llvm12-release/lib -isystem /home/andy/local/llvm12-release/include --override-lib-dir /home/andy/Downloads/zig/lib
downstream issue: ziglang/zig#8155
content copied here for convenience:
Minimal reproducer:
The
0x8000
gap simulates the previous content in the.rodata.str1.1
section, it's big enough to get sign-extended and small enough to fit in 16bit. The problem is in LLD'sMarkLive::resolveReloc
, the code is not able to handle the HI16/LO16 relocation pairs.It's the 32bit one that's showing this problem:
The text was updated successfully, but these errors were encountered: