Skip to content

Commit

Permalink
[BOLT][NFC] Better diagnostics for unsupported relocation types
Browse files Browse the repository at this point in the history
Summary: Print the relocation name instead of just the number.

(cherry picked from FBD32704832)
  • Loading branch information
aaupov authored and maksfb committed Nov 29, 2021
1 parent 76cd07f commit eb9f4eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bolt/lib/Core/Relocation.cpp
Expand Up @@ -11,6 +11,7 @@
#include "bolt/Core/Relocation.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Object/ELF.h"

using namespace llvm;
using namespace bolt;
Expand Down Expand Up @@ -87,6 +88,7 @@ bool isSupportedAArch64(uint64_t Type) {
size_t getSizeForTypeX86(uint64_t Type) {
switch (Type) {
default:
errs() << object::getELFRelocationTypeName(ELF::EM_X86_64, Type) << '\n';
llvm_unreachable("unsupported relocation type");
case ELF::R_X86_64_8:
case ELF::R_X86_64_PC8:
Expand All @@ -112,7 +114,7 @@ size_t getSizeForTypeX86(uint64_t Type) {
size_t getSizeForTypeAArch64(uint64_t Type) {
switch (Type) {
default:
dbgs() << "Reloc num: " << Type << "\n";
errs() << object::getELFRelocationTypeName(ELF::EM_AARCH64, Type) << '\n';
llvm_unreachable("unsupported relocation type");
case ELF::R_AARCH64_ABS16:
return 2;
Expand Down Expand Up @@ -231,6 +233,7 @@ uint64_t extractValueX86(uint64_t Type, uint64_t Contents, uint64_t PC) {
uint64_t extractValueAArch64(uint64_t Type, uint64_t Contents, uint64_t PC) {
switch (Type) {
default:
errs() << object::getELFRelocationTypeName(ELF::EM_AARCH64, Type) << '\n';
llvm_unreachable("unsupported relocation type");
case ELF::R_AARCH64_ABS16:
case ELF::R_AARCH64_ABS32:
Expand Down

0 comments on commit eb9f4eb

Please sign in to comment.