diff options
author | Jinyang He <hejinyang@loongson.cn> | 2024-01-16 13:20:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-16 13:20:13 +0800 |
commit | ed7f4edc19ada006789318a0929b57d1b5a761bd (patch) | |
tree | c541b777582c2ccd928aeb34e2058d9e4dc91f91 /llvm/lib/Object | |
parent | 199117ae09ed6bab54277e8007f98404834e277e (diff) | |
download | llvm-ed7f4edc19ada006789318a0929b57d1b5a761bd.zip llvm-ed7f4edc19ada006789318a0929b57d1b5a761bd.tar.gz llvm-ed7f4edc19ada006789318a0929b57d1b5a761bd.tar.bz2 |
[LoongArch] Add relaxDwarfLineAddr and relaxDwarfCFA to handle the mutable label diff in dwarfinfo (#77728)
When linker-relaxation is enabled, part of the label diff in dwarfinfo
cannot be computed before static link. Refer to RISCV, we add the
relaxDwarfLineAddr and relaxDwarfCFA to add relocations for these label
diffs. Calculate whether the label diff is mutable. For immutable label
diff, return false and do the other works by its parent function.
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r-- | llvm/lib/Object/RelocationResolver.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index ae97107..564d9da 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -538,6 +538,8 @@ static bool supportsLoongArch(uint64_t Type) { case ELF::R_LARCH_32: case ELF::R_LARCH_32_PCREL: case ELF::R_LARCH_64: + case ELF::R_LARCH_ADD6: + case ELF::R_LARCH_SUB6: case ELF::R_LARCH_ADD8: case ELF::R_LARCH_SUB8: case ELF::R_LARCH_ADD16: @@ -563,6 +565,10 @@ static uint64_t resolveLoongArch(uint64_t Type, uint64_t Offset, uint64_t S, return (S + Addend - Offset) & 0xFFFFFFFF; case ELF::R_LARCH_64: return S + Addend; + case ELF::R_LARCH_ADD6: + return (LocData & 0xC0) | ((LocData + S + Addend) & 0x3F); + case ELF::R_LARCH_SUB6: + return (LocData & 0xC0) | ((LocData - (S + Addend)) & 0x3F); case ELF::R_LARCH_ADD8: return (LocData + (S + Addend)) & 0xFF; case ELF::R_LARCH_SUB8: @@ -879,8 +885,10 @@ uint64_t resolveRelocation(RelocationResolver Resolver, const RelocationRef &R, if (GetRelSectionType() == ELF::SHT_RELA) { Addend = getELFAddend(R); - // RISCV relocations use both LocData and Addend. - if (Obj->getArch() != Triple::riscv32 && + // LoongArch and RISCV relocations use both LocData and Addend. + if (Obj->getArch() != Triple::loongarch32 && + Obj->getArch() != Triple::loongarch64 && + Obj->getArch() != Triple::riscv32 && Obj->getArch() != Triple::riscv64) LocData = 0; } |