diff options
author | YunQiang Su <syq@debian.org> | 2024-05-08 17:30:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-08 17:30:14 +0800 |
commit | 8f21294897befee48f9f72734ea1b0ad4c920aa0 (patch) | |
tree | f48fb0d77663f8fd1ed6f3d0cace1a25dd278ed9 /llvm/lib/MC/MCObjectFileInfo.cpp | |
parent | dd4bf22b9380e797362fac1415a1796da338b2db (diff) | |
download | llvm-8f21294897befee48f9f72734ea1b0ad4c920aa0.zip llvm-8f21294897befee48f9f72734ea1b0ad4c920aa0.tar.gz llvm-8f21294897befee48f9f72734ea1b0ad4c920aa0.tar.bz2 |
MIPS: Use pcrel|sdata4 for eh_frame (#91291)
Gas uses encoding DW_EH_PE_absptr for PIC, and gnu ld converts it to
DW_EH_PE_sdata4|DW_EH_PE_pcrel.
LLD doesn't have this workarounding, thus complains
```
relocation R_MIPS_32 cannot be used against local symbol; recompile with -fPIC
relocation R_MIPS_64 cannot be used against local symbol; recompile with -fPIC
```
So, let's generates asm/obj files with `DW_EH_PE_sdata4|DW_EH_PE_pcrel`
encoding. In fact, GNU ld supports such OBJs well.
For N64, maybe we should use sdata8, while GNU ld doesn't support it
well, and in fact sdata4 is enough now. So we just ignore the `Large`
for `MCObjectFileInfo::initELFMCObjectFileInfo`. Maybe we should switch
back to sdata8 once GNU LD supports it well.
Fixes: #58377.
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectFileInfo.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 1f8f8ec..045b566 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -343,7 +343,9 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) { case Triple::mips64el: // We cannot use DW_EH_PE_sdata8 for the large PositionIndependent case // since there is no R_MIPS_PC64 relocation (only a 32-bit version). - if (PositionIndependent && !Large) + // In fact DW_EH_PE_sdata4 is enough for us now, and GNU ld doesn't + // support pcrel|sdata8 well. Let's use sdata4 for now. + if (PositionIndependent) FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; else FDECFIEncoding = Ctx->getAsmInfo()->getCodePointerSize() == 4 |