From a8053399cde847dfce88d7d1fa2a2099f3a58c40 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 12 May 2021 12:38:27 -0700 Subject: [PATCH] [ELF][AVR] Add explicit relocation types to getRelExpr --- lld/ELF/Arch/AVR.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lld/ELF/Arch/AVR.cpp b/lld/ELF/Arch/AVR.cpp index 010e5c9..d0d2472 100644 --- a/lld/ELF/Arch/AVR.cpp +++ b/lld/ELF/Arch/AVR.cpp @@ -56,11 +56,38 @@ AVR::AVR() { noneRel = R_AVR_NONE; } RelExpr AVR::getRelExpr(RelType type, const Symbol &s, const uint8_t *loc) const { switch (type) { + case R_AVR_6: + case R_AVR_6_ADIW: + case R_AVR_8: + case R_AVR_16: + case R_AVR_16_PM: + case R_AVR_32: + case R_AVR_LDI: + case R_AVR_LO8_LDI: + case R_AVR_LO8_LDI_NEG: + case R_AVR_HI8_LDI: + case R_AVR_HI8_LDI_NEG: + case R_AVR_HH8_LDI_NEG: + case R_AVR_HH8_LDI: + case R_AVR_MS8_LDI_NEG: + case R_AVR_MS8_LDI: + case R_AVR_LO8_LDI_PM: + case R_AVR_LO8_LDI_PM_NEG: + case R_AVR_HI8_LDI_PM: + case R_AVR_HI8_LDI_PM_NEG: + case R_AVR_HH8_LDI_PM: + case R_AVR_HH8_LDI_PM_NEG: + case R_AVR_PORT5: + case R_AVR_PORT6: + case R_AVR_CALL: + return R_ABS; case R_AVR_7_PCREL: case R_AVR_13_PCREL: return R_PC; default: - return R_ABS; + error(getErrorLocation(loc) + "unknown relocation (" + Twine(type) + + ") against symbol " + toString(s)); + return R_NONE; } } @@ -188,8 +215,7 @@ void AVR::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const { break; } default: - error(getErrorLocation(loc) + "unrecognized relocation " + - toString(rel.type)); + llvm_unreachable("unknown relocation"); } } -- 2.7.4