mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[AMDGPU][MC] Corrected branch relocation handling to detect undefined labels
Fixed ELF object writer to die gracefully when an undefined label is encountered in a branch instruction. See https://bugs.llvm.org/show_bug.cgi?id=41914. Reviewers: arsenm, rampitec Differential Revision: https://reviews.llvm.org/D79943
This commit is contained in:
parent
6004a9d575
commit
549758f522
@ -6,8 +6,10 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "AMDGPUFixupKinds.h"
|
||||||
#include "AMDGPUMCTargetDesc.h"
|
#include "AMDGPUMCTargetDesc.h"
|
||||||
#include "llvm/BinaryFormat/ELF.h"
|
#include "llvm/BinaryFormat/ELF.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/MC/MCELFObjectWriter.h"
|
#include "llvm/MC/MCELFObjectWriter.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCFixup.h"
|
#include "llvm/MC/MCFixup.h"
|
||||||
@ -80,6 +82,15 @@ unsigned AMDGPUELFObjectWriter::getRelocType(MCContext &Ctx,
|
|||||||
return ELF::R_AMDGPU_ABS64;
|
return ELF::R_AMDGPU_ABS64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Fixup.getTargetKind() == AMDGPU::fixup_si_sopp_br) {
|
||||||
|
const auto *SymA = Target.getSymA();
|
||||||
|
assert(SymA);
|
||||||
|
|
||||||
|
Ctx.reportError(Fixup.getLoc(),
|
||||||
|
Twine("undefined label '") + SymA->getSymbol().getName() + "'");
|
||||||
|
return ELF::R_AMDGPU_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
llvm_unreachable("unhandled relocation type");
|
llvm_unreachable("unhandled relocation type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
test/MC/AMDGPU/labels-branch-err.s
Normal file
4
test/MC/AMDGPU/labels-branch-err.s
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// RUN: not llvm-mc -arch=amdgcn -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=ERROR %s
|
||||||
|
// ERROR: error: undefined label 'undef_label'
|
||||||
|
|
||||||
|
s_branch undef_label
|
Loading…
Reference in New Issue
Block a user