forked from OSchip/llvm-project
Improve error message for unknown relocations.
Previously, we showed the following message for an unknown relocation: foo.o: unrecognized reloc 256 This patch improves it so that the error message includes a symbol name: foo.o: unknown relocation (256) against symbol bar llvm-svn: 354040
This commit is contained in:
parent
aa0b77d339
commit
b8b81e9b43
|
@ -74,7 +74,7 @@ void AMDGPU::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
|
|||
write32le(Loc, Val >> 32);
|
||||
break;
|
||||
default:
|
||||
error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
|
||||
llvm_unreachable("unknown relocation");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,9 @@ RelExpr AMDGPU::getRelExpr(RelType Type, const Symbol &S,
|
|||
case R_AMDGPU_GOTPCREL32_HI:
|
||||
return R_GOT_PC;
|
||||
default:
|
||||
return R_INVALID;
|
||||
error(getErrorLocation(Loc) + "unknown relocation (" + Twine(Type) +
|
||||
") against symbol " + toString(S));
|
||||
return R_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,9 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType Type, const Symbol &S,
|
|||
case R_MIPS_NONE:
|
||||
return R_NONE;
|
||||
default:
|
||||
return R_INVALID;
|
||||
error(getErrorLocation(Loc) + "unknown relocation (" + Twine(Type) +
|
||||
") against symbol " + toString(S));
|
||||
return R_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -631,7 +633,7 @@ void MIPS<ELFT>::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
|
|||
writeShuffleValue<E>(Loc, Val, 23, 2);
|
||||
break;
|
||||
default:
|
||||
error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
|
||||
llvm_unreachable("unknown relocation");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,9 @@ RelExpr SPARCV9::getRelExpr(RelType Type, const Symbol &S,
|
|||
case R_SPARC_NONE:
|
||||
return R_NONE;
|
||||
default:
|
||||
return R_INVALID;
|
||||
error(getErrorLocation(Loc) + "unknown relocation (" + Twine(Type) +
|
||||
") against symbol " + toString(S));
|
||||
return R_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +120,7 @@ void SPARCV9::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
|
|||
write64be(Loc, Val);
|
||||
break;
|
||||
default:
|
||||
error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
|
||||
llvm_unreachable("unknown relocation");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,7 +149,9 @@ RelExpr X86::getRelExpr(RelType Type, const Symbol &S,
|
|||
case R_386_NONE:
|
||||
return R_NONE;
|
||||
default:
|
||||
return R_INVALID;
|
||||
error(getErrorLocation(Loc) + "unknown relocation (" + Twine(Type) +
|
||||
") against symbol " + toString(S));
|
||||
return R_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,7 +320,7 @@ void X86::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
|
|||
write32le(Loc, Val);
|
||||
break;
|
||||
default:
|
||||
error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
|
||||
llvm_unreachable("unknown relocation");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,9 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType Type, const Symbol &S,
|
|||
case R_X86_64_NONE:
|
||||
return R_NONE;
|
||||
default:
|
||||
return R_INVALID;
|
||||
error(getErrorLocation(Loc) + "unknown relocation (" + Twine(Type) +
|
||||
") against symbol " + toString(S));
|
||||
return R_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,7 +373,7 @@ void X86_64<ELFT>::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
|
|||
write64le(Loc, Val);
|
||||
break;
|
||||
default:
|
||||
error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
|
||||
llvm_unreachable("unknown relocation");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -600,8 +600,6 @@ static int64_t getTlsTpOffset() {
|
|||
static uint64_t getRelocTargetVA(const InputFile *File, RelType Type, int64_t A,
|
||||
uint64_t P, const Symbol &Sym, RelExpr Expr) {
|
||||
switch (Expr) {
|
||||
case R_INVALID:
|
||||
return 0;
|
||||
case R_ABS:
|
||||
case R_RELAX_TLS_LD_TO_LE_ABS:
|
||||
case R_RELAX_GOT_PC_NOPIC:
|
||||
|
|
|
@ -29,7 +29,6 @@ typedef uint32_t RelType;
|
|||
// from files are converted to these types so that the main code
|
||||
// doesn't have to know about architecture-specific details.
|
||||
enum RelExpr {
|
||||
R_INVALID,
|
||||
R_ABS,
|
||||
R_ADDEND,
|
||||
R_AARCH64_GOT_PAGE_PC,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# RUN: yaml2obj %s -o %t.o
|
||||
# RUN: not ld.lld -gdb-index %t.o -o %t.exe 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: error: {{.*}}invalid-debug-relocations.test.tmp.o:(.debug_info+0x0): has non-ABS relocation Unknown (255) against symbol '_start'
|
||||
# CHECK: error: {{.*}}invalid-debug-relocations.test.tmp.o:(.debug_info+0x0): unknown relocation (255) against symbol _start
|
||||
|
||||
!ELF
|
||||
FileHeader:
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# RUN: echo ".global foo; foo:" > %t2.s
|
||||
# RUN: llvm-mc %t2.s -o %t2.o -filetype=obj -triple x86_64-pc-linux
|
||||
# RUN: not ld.lld %t1.o %t2.o -o /dev/null 2>&1 | FileCheck %s
|
||||
# CHECK: error: unrecognized reloc 152
|
||||
# CHECK: error: unrecognized reloc 153
|
||||
# CHECK: error: unknown relocation (152) against symbol foo
|
||||
# CHECK: error: unknown relocation (153) against symbol foo
|
||||
|
||||
!ELF
|
||||
FileHeader:
|
||||
|
|
Loading…
Reference in New Issue