Skip to content

Commit aa0fcc4

Browse files
[MC][AMDGPU] Support .reloc BFD_RELOC_{NONE,32,64}
Emitting BFD_RELOC_* reloc directives can cause internal errors on AMDGPU
1 parent 57183b6 commit aa0fcc4

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,17 @@ void AMDGPUAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
163163

164164
std::optional<MCFixupKind>
165165
AMDGPUAsmBackend::getFixupKind(StringRef Name) const {
166-
return StringSwitch<std::optional<MCFixupKind>>(Name)
167-
#define ELF_RELOC(Name, Value) \
168-
.Case(#Name, MCFixupKind(FirstLiteralRelocationKind + Value))
166+
auto Type = StringSwitch<unsigned>(Name)
167+
#define ELF_RELOC(Name, Value) .Case(#Name, Value)
169168
#include "llvm/BinaryFormat/ELFRelocs/AMDGPU.def"
170169
#undef ELF_RELOC
171-
.Default(std::nullopt);
170+
.Case("BFD_RELOC_NONE", ELF::R_AMDGPU_NONE)
171+
.Case("BFD_RELOC_32", ELF::R_AMDGPU_ABS32)
172+
.Case("BFD_RELOC_64", ELF::R_AMDGPU_ABS64)
173+
.Default(-1u);
174+
if (Type != -1u)
175+
return static_cast<MCFixupKind>(FirstLiteralRelocationKind + Type);
176+
return std::nullopt;
172177
}
173178

174179
const MCFixupKindInfo &AMDGPUAsmBackend::getFixupKindInfo(

0 commit comments

Comments
 (0)