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/CodeGen/TargetLoweringObjectFileImpl.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/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 622773c..3e1897c 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -212,13 +212,11 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx, // identify N64 from just a triple. TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; - // We don't support PC-relative LSDA references in GAS so we use the default - // DW_EH_PE_absptr for those. // FreeBSD must be explicit about the data size and using pcrel since it's // assembler/linker won't do the automatic conversion that the Linux tools // do. - if (TgtM.getTargetTriple().isOSFreeBSD()) { + if (isPositionIndependent() || TgtM.getTargetTriple().isOSFreeBSD()) { PersonalityEncoding |= dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; } |