forked from OSchip/llvm-project
[Mips] Show error message and stop linking in case of cross mode jump errors
llvm-svn: 231640
This commit is contained in:
parent
9af798f5e4
commit
e604e8f970
|
@ -148,28 +148,31 @@ static void reloc32hi16(uint32_t &ins, uint64_t S, int64_t A) {
|
|||
applyReloc(ins, (S + A + 0x8000) & 0xffff0000, 0xffffffff);
|
||||
}
|
||||
|
||||
static void adjustJumpOpCode(uint32_t &ins, uint64_t tgt, CrossJumpMode mode) {
|
||||
static std::error_code adjustJumpOpCode(uint32_t &ins, uint64_t tgt,
|
||||
CrossJumpMode mode) {
|
||||
if (mode == CrossJumpMode::None)
|
||||
return;
|
||||
return std::error_code();
|
||||
|
||||
bool toMicro = mode == CrossJumpMode::ToMicro;
|
||||
uint32_t opNative = toMicro ? 0x03 : 0x3d;
|
||||
uint32_t opCross = toMicro ? 0x1d : 0x3c;
|
||||
|
||||
// FIXME (simon): Convert this into the regular fatal error.
|
||||
if ((tgt & 1) != toMicro)
|
||||
llvm_unreachable("Incorrect bit 0 for the jalx target");
|
||||
return make_dynamic_error_code(
|
||||
Twine("Incorrect bit 0 for the jalx target"));
|
||||
|
||||
if (tgt & 2)
|
||||
llvm::errs() << "The jalx target " << llvm::format_hex(tgt, 10)
|
||||
<< " is not word-aligned.\n";
|
||||
|
||||
return make_dynamic_error_code(Twine("The jalx target 0x") +
|
||||
Twine::utohexstr(tgt) +
|
||||
" is not word-aligned");
|
||||
uint8_t op = ins >> 26;
|
||||
if (op != opNative && op != opCross)
|
||||
llvm::errs() << "Unsupported jump opcode (" << llvm::format_hex(op, 4)
|
||||
<< ") for ISA modes cross call.\n";
|
||||
else
|
||||
ins = (ins & ~(0x3f << 26)) | (opCross << 26);
|
||||
return make_dynamic_error_code(Twine("Unsupported jump opcode (0x") +
|
||||
Twine::utohexstr(op) +
|
||||
") for ISA modes cross call");
|
||||
|
||||
ins = (ins & ~(0x3f << 26)) | (opCross << 26);
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
static bool isMicroMipsAtom(const Atom *a) {
|
||||
|
@ -273,7 +276,8 @@ std::error_code RelocationHandler<ELFT>::applyRelocation(
|
|||
targetVAddress |= 1;
|
||||
|
||||
CrossJumpMode crossJump = getCrossJumpMode(ref);
|
||||
adjustJumpOpCode(ins, targetVAddress, crossJump);
|
||||
if (auto ec = adjustJumpOpCode(ins, targetVAddress, crossJump))
|
||||
return ec;
|
||||
|
||||
switch (ref.kindValue()) {
|
||||
case R_MIPS_NONE:
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# Check that LLD shows an error if jalx target value is not word-aligned.
|
||||
|
||||
# RUN: yaml2obj -format=elf %s > %t-obj
|
||||
# RUN: lld -flavor gnu -target mipsel -e T0 -o %t-exe %t-obj 2>&1 | FileCheck %s
|
||||
# RUN: not lld -flavor gnu -target mipsel -e T0 -o %t-exe %t-obj 2>&1 \
|
||||
# RUN: | FileCheck %s
|
||||
|
||||
# CHECK: The jalx target 0x00400116 is not word-aligned.
|
||||
# CHECK: The jalx target 0x400116 is not word-aligned
|
||||
|
||||
!ELF
|
||||
FileHeader: !FileHeader
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# of replacing an unknown unstruction by jalx.
|
||||
|
||||
# RUN: yaml2obj -format=elf %s > %t-obj
|
||||
# RUN: lld -flavor gnu -target mipsel -o %t-exe %t-obj 2>&1 | FileCheck %s
|
||||
# RUN: not lld -flavor gnu -target mipsel -o %t-exe %t-obj 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: Unsupported jump opcode (0x00) for ISA modes cross call.
|
||||
# CHECK: Unsupported jump opcode (0x0) for ISA modes cross call
|
||||
|
||||
!ELF
|
||||
FileHeader: !FileHeader
|
||||
|
|
|
@ -73,7 +73,8 @@ Sections:
|
|||
Type: SHT_PROGBITS
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
AddressAlign: 0x04
|
||||
Size: 0x20
|
||||
Content: '000000000000000000f4000000000000f400000000000000f400000000000000'
|
||||
# jal .text jal glob jal T1
|
||||
- Name: .rel.text
|
||||
Type: SHT_REL
|
||||
Link: .symtab
|
||||
|
|
Loading…
Reference in New Issue