// SPDX-FileCopyrightText: 2024-2025 RizinOrg <info@rizin.re>
// SPDX-FileCopyrightText: 2009-2021 nibble <nibble.ds@gmail.com>
// SPDX-FileCopyrightText: 2009-2021 pancake <pancake@nopcode.org>
// SPDX-License-Identifier: LGPL-3.0-only

#include "elf.h"

RZ_OWN RzBinSymbol *Elf_(rz_bin_elf_convert_symbol)(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RzBinElfSymbol *elf_symbol) {
	rz_return_val_if_fail(bin && elf_symbol, NULL);

	RzBinSymbol *result = RZ_NEW0(RzBinSymbol);
	if (!result) {
		return NULL;
	}

	result->paddr = elf_symbol->paddr;
	result->vaddr = elf_symbol->vaddr;
	if (RZ_STR_ISNOTEMPTY(elf_symbol->name)) {
		result->name = rz_str_dup(elf_symbol->name);
	} else {
		result->name = rz_str_newf("unknown_%u", elf_symbol->ordinal);
	}
	result->forwarder = "NONE";
	result->bind = elf_symbol->bind;
	result->type = elf_symbol->type;
	result->size = elf_symbol->size;
	result->ordinal = elf_symbol->ordinal;
	result->bits = bin->bits;

	if (Elf_(rz_bin_elf_is_arm_binary_supporting_thumb)(bin)) {
		Elf_(rz_bin_elf_fix_arm_thumb_symbol)(result);
	}

	return result;
}

static RzBinSymbol *get_symbol(ELFOBJ *bin, ut32 ordinal) {
	RzBinElfSymbol *symbol = Elf_(rz_bin_elf_get_symbol)(bin, ordinal);
	if (!symbol) {
		return NULL;
	}

	return Elf_(rz_bin_elf_convert_symbol)(bin, symbol);
}

RZ_OWN RzBinImport *Elf_(rz_bin_elf_convert_import)(RZ_NONNULL RzBinElfSymbol *elf_symbol) {
	rz_return_val_if_fail(elf_symbol, NULL);

	RzBinImport *result = RZ_NEW0(RzBinImport);
	if (!result) {
		return NULL;
	}

	result->name = rz_str_dup(elf_symbol->name);
	result->bind = elf_symbol->bind;
	result->type = elf_symbol->type;
	result->ordinal = elf_symbol->ordinal;

	return result;
}

static RzBinImport *get_import(RZ_NONNULL ELFOBJ *bin, ut32 ordinal) {
	RzBinElfSymbol *symbol = Elf_(rz_bin_elf_get_import)(bin, ordinal);
	if (!symbol) {
		return NULL;
	}

	return Elf_(rz_bin_elf_convert_import)(symbol);
}

static RzBinReloc *reloc_convert_new(ELFOBJ *bin, RzBinElfReloc *rel) {
	RzBinReloc *reloc = RZ_NEW0(RzBinReloc);
	if (!reloc) {
		return NULL;
	}

	reloc->addend = rel->addend;
	if (rel->sym) {
		reloc->import = get_import(bin, rel->sym);
		if (!reloc->import) {
			reloc->symbol = get_symbol(bin, rel->sym);
		}
	}
	reloc->vaddr = rel->vaddr;
	reloc->paddr = rel->paddr;
	reloc->target_vaddr = rel->target_vaddr;

	RzBinElfSection *section = rel->section > 0 ? Elf_(rz_bin_elf_get_section)(bin, rel->section) : NULL;
	if (section) {
		reloc->section_vaddr = section->rva;
	}
	return reloc;
}

static RzBinReloc *reloc_convert_set(ELFOBJ *bin, RzBinElfReloc *rel, RzBinRelocType type, const char *print_name) {
	RzBinReloc *r = reloc_convert_new(bin, rel);
	if (!r) {
		return NULL;
	}

	r->type = type;
	r->print_name = print_name;
	return r;
}

static RzBinReloc *reloc_convert_add(ELFOBJ *bin, RzBinElfReloc *rel, RzBinRelocType type, st64 addend, const char *print_name, RzRelocBase reloc_base) {
	RzBinReloc *r = reloc_convert_new(bin, rel);
	if (!r) {
		return NULL;
	}

	r->reloc_base = reloc_base;
	r->addend += addend;
	r->type = type;
	r->print_name = print_name;
	return r;
}

static RzBinReloc *reloc_convert_ifunc(ELFOBJ *bin, RzBinElfReloc *rel, RzBinRelocType type, const char *print_name) {
	RzBinReloc *r = reloc_convert_new(bin, rel);
	if (!r) {
		return NULL;
	}

	r->is_ifunc = true;
	r->type = type;
	r->print_name = print_name;
	return r;
}

// Custom function for arm specific relocations
static RzBinReloc *reloc_convert_add_t(ELFOBJ *bin, RzBinElfReloc *rel, RzBinRelocType type, bool T, st64 addend, const char *print_name, RzRelocBase reloc_base) {
	RzBinReloc *r = reloc_convert_new(bin, rel);
	if (!r) {
		return NULL;
	}

	r->reloc_base = reloc_base;
	r->addend = (r->addend | T) + addend;
	r->type = type;
	r->print_name = print_name;
	return r;
}

#define UNSUPP_RELOC(NAME, V) \
	RZ_LOG_WARN(NAME ": Unsupported conversion of ELF reloc %u (0x%x)\n", (ut32)V, (ut32)V); \
	return reloc_convert_new(bin, rel)

#define UNSUPP(NAME) UNSUPP_RELOC(NAME, rel->type)

#define UNHANDL(RELOC_NAME) \
	RZ_LOG_WARN("Unhandled conversion of ELF reloc %d (" RELOC_NAME ")\n", rel->type); \
	return reloc_convert_set(bin, rel, 0, RELOC_NAME)

#define SET(BIT_SIZE, RELOC_NAME) \
	return reloc_convert_set(bin, rel, RZ_BIN_RELOC_##BIT_SIZE, RELOC_NAME)

#define ADD(BIT_SIZE, ADDEND, RELOC_NAME, RELOC_BASE) \
	return reloc_convert_add(bin, rel, RZ_BIN_RELOC_##BIT_SIZE, ADDEND, RELOC_NAME, RELOC_BASE)

#define IFCN(BIT_SIZE, RELOC_NAME) \
	return reloc_convert_ifunc(bin, rel, RZ_BIN_RELOC_##BIT_SIZE, RELOC_NAME)

/*
Custom add for arm specific relocations
We do A|T this would result the same as (S+A)|T
*/
#define ADD_T(BIT_SIZE, T, ADDEND, RELOC_NAME, RELOC_BASE) \
	return reloc_convert_add_t(bin, rel, RZ_BIN_RELOC_##BIT_SIZE, T, ADDEND, RELOC_NAME, RELOC_BASE)

static RzBinReloc *reloc_convert_intel_80386(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_386_NONE:
		return reloc_convert_set(bin, rel, 0, "R_386_NONE");
	case R_386_32: ADD(32, 0, "R_386_32", RZ_RELOC_BASE_SYMBOL);
	case R_386_PC32: ADD(32, -P, "R_386_PC32", RZ_RELOC_BASE_SYMBOL);
	case R_386_GLOB_DAT: SET(32, "R_386_GLOB_DAT");
	case R_386_JMP_SLOT: SET(32, "R_386_JMP_SLOT");
	case R_386_RELATIVE: ADD(32, 0, "R_386_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_386_GOTOFF: ADD(32, -GOT, "R_386_GOTOFF", RZ_RELOC_BASE_SYMBOL);
	case R_386_GOTPC: ADD(32, GOT - P, "R_386_GOTPC", RZ_RELOC_BASE_GOT);
	case R_386_16: ADD(16, 0, "R_386_16", RZ_RELOC_BASE_SYMBOL);
	case R_386_PC16: ADD(16, -P, "R_386_PC16", RZ_RELOC_BASE_SYMBOL);
	case R_386_8: ADD(8, 0, "R_386_8", RZ_RELOC_BASE_SYMBOL);
	case R_386_PC8: ADD(8, -P, "R_386_PC8", RZ_RELOC_BASE_SYMBOL);
	case R_386_COPY: ADD(32, 0, "R_386_COPY", RZ_RELOC_BASE_UNKNOWN); // copy symbol at runtime
	case R_386_IRELATIVE: IFCN(32, "R_386_IRELATIVE");
	case R_386_32PLT: ADD(32, 0, "R_386_32PLT", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_386_TLS_TPOFF: UNHANDL("R_386_TLS_TPOFF");
	case R_386_TLS_IE: UNHANDL("R_386_TLS_IE");
	case R_386_TLS_GOTIE: UNHANDL("R_386_TLS_GOTIE");
	case R_386_TLS_LE: UNHANDL("R_386_TLS_LE");
	case R_386_TLS_GD: UNHANDL("R_386_TLS_GD");
	case R_386_TLS_LDM: UNHANDL("R_386_TLS_LDM");
	case R_386_TLS_GD_32: UNHANDL("R_386_TLS_GD_32");
	case R_386_TLS_GD_PUSH: UNHANDL("R_386_TLS_GD_PUSH");
	case R_386_TLS_GD_CALL: UNHANDL("R_386_TLS_GD_CALL");
	case R_386_TLS_GD_POP: UNHANDL("R_386_TLS_GD_POP");
	case R_386_TLS_LDM_32: UNHANDL("R_386_TLS_LDM_32");
	case R_386_TLS_LDM_PUSH: UNHANDL("R_386_TLS_LDM_PUSH");
	case R_386_TLS_LDM_CALL: UNHANDL("R_386_TLS_LDM_CALL");
	case R_386_TLS_LDM_POP: UNHANDL("R_386_TLS_LDM_POP");
	case R_386_TLS_LDO_32: UNHANDL("R_386_TLS_LDO_32");
	case R_386_TLS_IE_32: UNHANDL("R_386_TLS_IE_32");
	case R_386_TLS_LE_32: UNHANDL("R_386_TLS_LE_32");
	case R_386_TLS_DTPMOD32: UNHANDL("R_386_TLS_DTPMOD32");
	case R_386_TLS_DTPOFF32: UNHANDL("R_386_TLS_DTPOFF32");
	case R_386_TLS_TPOFF32: UNHANDL("R_386_TLS_TPOFF32");
	case R_386_SIZE32: UNHANDL("R_386_SIZE32");
	case R_386_TLS_GOTDESC: UNHANDL("R_386_TLS_GOTDESC");
	case R_386_TLS_DESC_CALL: UNHANDL("R_386_TLS_DESC_CALL");
	case R_386_TLS_DESC: UNHANDL("R_386_TLS_DESC");
	case R_386_GOT32X: UNHANDL("R_386_GOT32X");

	// FIXME: Quite a few relocations missing here.
	default: UNSUPP("X86_32");
	}
}

static RzBinReloc *reloc_convert_amd64(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_X86_64_NONE:
		return reloc_convert_set(bin, rel, 0, "R_X86_64_NONE");
	case R_X86_64_64: ADD(64, 0, "R_X86_64_64", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_PLT32: ADD(32, -P /* +L */, "R_X86_64_PLT32", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_X86_64_GOT32: ADD(32, GOT, "R_X86_64_GOT32", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_PC32: ADD(32, -P, "R_X86_64_PC32", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_GLOB_DAT: ADD(64, 0, "R_X86_64_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_JUMP_SLOT: ADD(64, 0, "R_X86_64_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_RELATIVE: ADD(64, 0, "R_X86_64_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_X86_64_32: ADD(32, 0, "R_X86_64_32", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_32S: ADD(32, 0, "R_X86_64_32S", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_16: ADD(16, 0, "R_X86_64_16", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_PC16: ADD(16, -P, "R_X86_64_PC16", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_8: ADD(8, 0, "R_X86_64_8", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_PC8: ADD(8, -P, "R_X86_64_PC8", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_GOTPCREL: ADD(64, P, "R_X86_64_GOTPCREL", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_COPY: ADD(64, 0, "R_X86_64_COPY", RZ_RELOC_BASE_UNKNOWN); // copy symbol at runtime
	case R_X86_64_IRELATIVE: IFCN(64, "R_X86_64_IRELATIVE");
	case R_X86_64_DTPMOD64: UNHANDL("R_X86_64_DTPMOD64");
	case R_X86_64_DTPOFF64: UNHANDL("R_X86_64_DTPOFF64");
	case R_X86_64_TPOFF64: UNHANDL("R_X86_64_TPOFF64");
	case R_X86_64_TLSGD: UNHANDL("R_X86_64_TLSGD");
	case R_X86_64_TLSLD: UNHANDL("R_X86_64_TLSLD");
	case R_X86_64_DTPOFF32: UNHANDL("R_X86_64_DTPOFF32");
	case R_X86_64_GOTTPOFF: UNHANDL("R_X86_64_GOTTPOFF");
	case R_X86_64_TPOFF32: UNHANDL("R_X86_64_TPOFF32");
	case R_X86_64_PC64: ADD(64, -P, "R_X86_64_PC64", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_GOTOFF64: ADD(64, -GOT, "R_X86_64_GOTOFF64", RZ_RELOC_BASE_SYMBOL);
	case R_X86_64_GOTPC32: ADD(32, -P, "R_X86_64_GOTPC32", RZ_RELOC_BASE_GOT);
	case R_X86_64_GOT64: ADD(64, 0, "R_X86_64_GOT64", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_GOTPCREL64: ADD(64, P, "R_X86_64_GOTPCREL64", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_GOTPC64: ADD(64, GOT - P, "R_X86_64_GOTPC64", RZ_RELOC_BASE_GOT);
	case R_X86_64_GOTPLT64: ADD(64, 0, "R_X86_64_GOTPLT64", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_PLTOFF64: ADD(64, -GOT, "R_X86_64_PLTOFF64", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_X86_64_SIZE32: UNHANDL("R_X86_64_SIZE32");
	case R_X86_64_SIZE64: UNHANDL("R_X86_64_SIZE64");
	case R_X86_64_GOTPC32_TLSDESC: UNHANDL("R_X86_64_GOTPC32_TLSDESC");
	case R_X86_64_TLSDESC_CALL: UNHANDL("R_X86_64_TLSDESC_CALL");
	case R_X86_64_TLSDESC: UNHANDL("R_X86_64_TLSDESC");
	case R_X86_64_RELATIVE64: ADD(64, 0, "R_X86_64_RELATIVE64", RZ_RELOC_BASE_BASE);
	case R_X86_64_GOTPCRELX: ADD(32, P, "R_X86_64_GOTPCRELX", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_REX_GOTPCRELX: ADD(32, P, "R_X86_64_REX_GOTPCRELX", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_CODE_4_GOTPCRELX: ADD(32, P, "R_X86_64_CODE_4_GOTPCRELX", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_CODE_4_GOTTPOFF: UNHANDL("R_X86_64_CODE_4_GOTTPOFF");
	case R_X86_64_CODE_4_GOTPC32_TLSDESC: UNHANDL("R_X86_64_CODE_4_GOTPC32_TLSDESC");
	case R_X86_64_CODE_5_GOTPCRELX: ADD(32, P, "R_X86_64_CODE_5_GOTPCRELX", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_CODE_5_GOTTPOFF: UNHANDL("R_X86_64_CODE_5_GOTTPOFF");
	case R_X86_64_CODE_5_GOTPC32_TLSDESC: UNHANDL("R_X86_64_CODE_5_GOTPC32_TLSDESC");
	case R_X86_64_CODE_6_GOTPCRELX: ADD(32, P, "R_X86_64_CODE_6_GOTPCRELX", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_X86_64_CODE_6_GOTTPOFF: UNHANDL("R_X86_64_CODE_6_GOTTPOFF");
	case R_X86_64_CODE_6_GOTPC32_TLSDESC: UNHANDL("R_X86_64_CODE_6_GOTPC32_TLSDESC");

	// FIXME: Quite a few relocations missing here.
	default: UNSUPP("X86_64");
	}
}

static RzBinReloc *reloc_convert_arm(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 B = bin->baddr;
	ut64 P = rel->vaddr;
	ut64 Pa = P & 0xfffffffc;
	bool T = 0;
	RzBinElfSymbol *symbol = Elf_(rz_bin_elf_get_symbol)(bin, rel->sym);
	if (symbol && RZ_STR_EQ(symbol->type, RZ_BIN_TYPE_FUNC_STR)) {
		// Check for LSB to know if symbol addresses thumb instruction
		T = (symbol->vaddr & 1) ? 1 : 0;
	}
	rel->thumb = T;

	switch (rel->type) {
	case R_ARM_NONE:
		return reloc_convert_set(bin, rel, 0, "R_ARM_NONE");
	case R_ARM_ABS32: ADD_T(32, T, 0, "R_ARM_ABS32", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_REL32: ADD_T(32, T, -P, "R_ARM_REL32", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ABS16: ADD(16, 0, "R_ARM_ABS16", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ABS8: ADD(8, 0, "R_ARM_ABS8", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_SBREL32: ADD_T(32, T, B, "R_ARM_SBREL32", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_GLOB_DAT: ADD_T(32, T, 0, "R_ARM_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_JUMP_SLOT: ADD_T(32, T, 0, "R_ARM_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_COPY: ADD(32, 0, "R_ARM_COPY", RZ_RELOC_BASE_UNKNOWN); // copy symbol at runtime
	case R_ARM_RELATIVE: ADD(32, 0, "R_ARM_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_ARM_GOTOFF32: ADD_T(32, T, -GOT, "R_ARM_GOTOFF32", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_BASE_PREL: ADD(32, -P, "R_ARM_GOTPC", RZ_RELOC_BASE_BASE);
	case R_ARM_CALL: ADD_T(24, T, -P, "R_ARM_CALL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_JUMP24: ADD_T(24, T, -P, "R_ARM_JUMP24", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_JUMP24: ADD_T(24, T, -P, "R_ARM_THM_JUMP24", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_CALL: ADD_T(24, T, -P, "R_ARM_THM_CALL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_PREL31: ADD_T(32, T, -P, "R_ARM_PREL31", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_MOVW_PREL_NC: ADD_T(32, T, -P, "R_ARM_MOVW_PREL_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_MOVT_PREL: ADD(32, -P, "R_ARM_MOVT_PREL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVW_PREL_NC: ADD_T(32, T, -P, "R_ARM_THM_MOVW_PREL_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_REL32_NOI: ADD(32, -P, "R_ARM_REL32_NOI", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ABS32_NOI: ADD(32, 0, "R_ARM_ABS32_NOI", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_PC_G0_NC: ADD_T(32, T, -P, "R_ARM_ALU_PC_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_PC_G0: ADD_T(32, T, -P, "R_ARM_ALU_PC_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_PC_G1_NC: ADD_T(32, T, -P, "R_ARM_ALU_PC_G1_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_PC_G1: ADD_T(32, T, -P, "R_ARM_ALU_PC_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_PC_G2: ADD_T(32, T, -P, "R_ARM_ALU_PC_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDR_PC_G1: ADD(32, -P, "R_ARM_LDR_PC_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDR_PC_G2: ADD(32, -P, "R_ARM_LDR_PC_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDRS_PC_G0: ADD(32, -P, "R_ARM_LDRS_PC_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDRS_PC_G1: ADD(32, -P, "R_ARM_LDRS_PC_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDRS_PC_G2: ADD(32, -P, "R_ARM_LDRS_PC_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDC_PC_G0: ADD(32, -P, "R_ARM_LDC_PC_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDC_PC_G1: ADD(32, -P, "R_ARM_LDC_PC_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDC_PC_G2: ADD(32, -P, "R_ARM_LDC_PC_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_PC24: ADD_T(32, T, -P, "R_ARM_PC24", RZ_RELOC_BASE_SYMBOL); // Depracated
	case R_ARM_LDR_PC_G0: ADD(32, -P, "R_ARM_LDR_PC_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ABS12: ADD(32, 0, "R_ARM_ABS12", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_ABS5: ADD(16, 0, "R_ARM_THM_ABS5", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_PC8: ADD(16, -Pa, "R_ARM_THM_PC8", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_BREL_ADJ: UNHANDL("R_ARM_BREL_ADJ");
	case R_ARM_TLS_DESC: UNHANDL("R_ARM_TLS_DESC");
	case R_ARM_THM_SWI8: UNHANDL("R_ARM_THM_SWI8");
	case R_ARM_XPC25: UNHANDL("R_ARM_XPC25");
	case R_ARM_THM_XPC22: UNHANDL("R_ARM_THM_XPC22");
	case R_ARM_TLS_DTPMOD32: UNHANDL("R_ARM_TLS_DTPMOD32");
	case R_ARM_TLS_DTPOFF32: UNHANDL("R_ARM_TLS_DTPOFF32");
	case R_ARM_TLS_TPOFF32: UNHANDL("R_ARM_TLS_TPOFF32");
	case R_ARM_GOT_BREL: ADD(32, -GOT, "R_ARM_GOT_BREL", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_PLT32: ADD_T(32, T, -P, "R_ARM_PLT32", RZ_RELOC_BASE_SYMBOL); // Deprecated
	case R_ARM_BASE_ABS: ADD(32, 0, "R_ARM_BASE_ABS", RZ_RELOC_BASE_BASE);
	case R_ARM_ALU_PCREL_7_0: UNHANDL("R_ARM_ALU_PCREL_7_0");
	case R_ARM_ALU_PCREL_15_8: UNHANDL("R_ARM_ALU_PCREL_15_8");
	case R_ARM_ALU_PCREL_23_15: UNHANDL("R_ARM_ALU_PCREL_23_15");
	case R_ARM_LDR_SBREL_11_0_NC: ADD(32, -B, "R_ARM_LDR_SBREL_11_0", RZ_RELOC_BASE_SYMBOL); // Deprecated
	case R_ARM_ALU_SBREL_19_12_NC: ADD(32, -B, "R_ARM_ALU_SBREL_19_12", RZ_RELOC_BASE_SYMBOL); // Deprecated
	case R_ARM_ALU_SBREL_27_20_CK: ADD(32, -B, "R_ARM_ALU_SBREL_27_20", RZ_RELOC_BASE_SYMBOL); // Deprecated
	case R_ARM_TARGET1: UNHANDL("R_ARM_TARGET1"); // (S + A) | T or ((S + | A) | T) – P
	case R_ARM_SBREL31: ADD_T(32, T, -B, "R_ARM_SBREL31", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_V4BX: UNHANDL("R_ARM_V4BX");
	case R_ARM_TARGET2: UNHANDL("R_ARM_TARGET2");
	case R_ARM_MOVW_ABS_NC: ADD_T(32, T, 0, "R_ARM_MOVW_ABS_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_MOVT_ABS: ADD(32, 0, "R_ARM_MOVT_ABS", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVW_ABS_NC: ADD_T(32, T, 0, "R_ARM_THM_MOVW_ABS_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVT_ABS: ADD(32, 0, "R_ARM_THM_MOVT_ABS", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVT_PREL: ADD(32, -P, "R_ARM_THM_MOVT_PREL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_JUMP19: ADD_T(32, T, -P, "R_ARM_THM_JUMP19", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_JUMP6: ADD(16, -P, "R_ARM_THM_JUMP6", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_ALU_PREL_11_0: ADD_T(32, T, -Pa, "R_ARM_THM_ALU_PREL_11_0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_PC12: ADD(32, -Pa, "R_ARM_THM_PC12", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_SB_G0_NC: ADD_T(32, T, -B, "R_ARM_ALU_SB_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_SB_G0: ADD_T(32, T, -B, "R_ARM_ALU_SB_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_SB_G1_NC: ADD_T(32, T, -B, "R_ARM_ALU_SB_G1_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_SB_G1: ADD_T(32, T, -B, "R_ARM_ALU_SB_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_ALU_SB_G2: ADD_T(32, T, -B, "R_ARM_ALU_SB_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDR_SB_G0: ADD(32, -B, "R_ARM_LDR_SB_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDR_SB_G1: ADD(32, -B, "R_ARM_LDR_SB_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDR_SB_G2: ADD(32, -B, "R_ARM_LDR_SB_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDRS_SB_G0: ADD(32, -B, "R_ARM_LDRS_SB_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDRS_SB_G1: ADD(32, -B, "R_ARM_LDRS_SB_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDRS_SB_G2: ADD(32, -B, "R_ARM_LDRS_SB_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDC_SB_G0: ADD(32, -B, "R_ARM_LDC_SB_G0", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDC_SB_G1: ADD(32, -B, "R_ARM_LDC_SB_G1", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_LDC_SB_G2: ADD(32, -B, "R_ARM_LDC_SB_G2", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_MOVW_BREL_NC: ADD_T(16, T, -B, "R_ARM_MOVW_BREL_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_MOVT_BREL: ADD(32, -B, "R_ARM_MOVT_BREL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_MOVW_BREL: ADD_T(16, T, -B, "R_ARM_MOVW_BREL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVW_BREL_NC: ADD_T(32, T, -B, "R_ARM_THM_MOVW_BREL_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVT_BREL: ADD(32, -B, "R_ARM_THM_MOVT_BREL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_MOVW_BREL: ADD_T(16, T, -B, "R_ARM_THM_MOVW_BREL", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_TLS_GOTDESC: UNHANDL("R_ARM_TLS_GOTDESC");
	case R_ARM_TLS_CALL: UNHANDL("R_ARM_TLS_CALL");
	case R_ARM_TLS_DESCSEQ: UNHANDL("R_ARM_TLS_DESCSEQ");
	case R_ARM_THM_TLS_CALL: UNHANDL("R_ARM_THM_TLS_CALL");
	case R_ARM_PLT32_ABS: ADD(32, 0, "R_ARM_PLT32_ABS", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_ARM_GOT_ABS: ADD(32, 0, "R_ARM_GOT_ABS", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_GOT_PREL: ADD(32, -P, "R_ARM_GOT_PREL", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_GOT_BREL12: ADD(32, -GOT, "R_ARM_GOT_BREL12", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_GOTOFF12: ADD(32, -GOT, "R_ARM_GOTOFF12", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_GOTRELAX: UNHANDL("R_ARM_GOTRELAX");
	case R_ARM_GNU_VTENTRY: UNHANDL("R_ARM_GNU_VTENTRY");
	case R_ARM_GNU_VTINHERIT: UNHANDL("R_ARM_GNU_VTINHERIT");
	case R_ARM_THM_JUMP11: ADD(16, -P, "R_ARM_THM_JUMP11", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_JUMP8: ADD(16, -P, "R_ARM_THM_JUMP8", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_TLS_GD32: ADD(32, -P, "R_ARM_TLS_GD32", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_TLS_LDM32: ADD(32, -P, "R_ARM_TLS_LDM32", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_TLS_LDO32: UNHANDL("R_ARM_TLS_LDO32");
	case R_ARM_TLS_IE32: ADD(32, -P, "R_ARM_TLS_IE32", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_TLS_LE32: UNHANDL("R_ARM_TLS_LE32");
	case R_ARM_TLS_LDO12: UNHANDL("R_ARM_TLS_LDO12");
	case R_ARM_TLS_LE12: UNHANDL("R_ARM_TLS_LE12");
	case R_ARM_TLS_IE12GP: ADD(32, 0, "R_ARM_TLS_IE12GP", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_ME_TOO: UNHANDL("R_ARM_ME_TOO");
	case R_ARM_THM_TLS_DESCSEQ: UNHANDL("R_ARM_THM_TLS_DESCSEQ");
	case R_ARM_THM_TLS_DESCSEQ32: UNHANDL("R_ARM_THM_TLS_DESCSEQ32");
	case R_ARM_THM_GOT_BREL12: ADD(32, 0, "R_ARM_THM_GOT_BREL12", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_ARM_THM_ALU_ABS_G0_NC: ADD_T(16, T, 0, "R_ARM_THM_ALU_ABS_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_ALU_ABS_G1_NC: ADD_T(16, T, 0, "R_ARM_THM_ALU_ABS_G1_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_ALU_ABS_G2_NC: ADD_T(16, 0, T, "R_ARM_THM_ALU_ABS_G2_NC", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_ALU_ABS_G3: ADD_T(16, 0, T, "R_ARM_THM_ALU_ABS_G3", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_BF16: ADD_T(16, T, -P, "R_ARM_THM_BF16", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_BF12: ADD_T(16, T, -P, "R_ARM_THM_BF12", RZ_RELOC_BASE_SYMBOL);
	case R_ARM_THM_BF18: ADD_T(16, T, -P, "R_ARM_THM_BF18", RZ_RELOC_BASE_SYMBOL);

	// FIXME: Quite a few relocations missing here. It's incorrect to place them all under "reg relocations".
	default: ADD(32, GOT, "ARM REG RELOC", RZ_RELOC_BASE_UNKNOWN);
	}
}

static RzBinReloc *reloc_convert_riscv(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {

	switch (rel->type) {
	case R_RISCV_NONE:
		return reloc_convert_set(bin, rel, 0, "R_RISCV_NONE");
	case R_RISCV_32: ADD(32, 0, "R_RISCV_32", RZ_RELOC_BASE_SYMBOL);
	case R_RISCV_64: ADD(64, 0, "R_RISCV_64", RZ_RELOC_BASE_SYMBOL);
	case R_RISCV_RELATIVE: ADD(64, 0, "R_RISCV_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_RISCV_COPY: UNHANDL("R_RISCV_COPY");
	case R_RISCV_JUMP_SLOT: ADD(64, 0, "R_RISCV_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_RISCV_TLS_DTPMOD32: UNHANDL("R_RISCV_TLS_DTPMOD32");
	case R_RISCV_TLS_DTPMOD64: UNHANDL("R_RISCV_TLS_DTPMOD64");
	case R_RISCV_TLS_DTPREL32: UNHANDL("R_RISCV_TLS_DTPREL32");
	case R_RISCV_TLS_DTPREL64: UNHANDL("R_RISCV_TLS_DTPREL64");
	case R_RISCV_TLS_TPREL32: UNHANDL("R_RISCV_TLS_TPREL32");
	case R_RISCV_TLS_TPREL64: UNHANDL("R_RISCV_TLS_TPREL64");
	case R_RISCV_BRANCH: UNHANDL("R_RISCV_BRANCH");
	case R_RISCV_JAL: UNHANDL("R_RISCV_JAL");
	case R_RISCV_CALL: UNHANDL("R_RISCV_CALL");
	case R_RISCV_CALL_PLT: UNHANDL("R_RISCV_CALL_PLT");
	case R_RISCV_GOT_HI20: UNHANDL("R_RISCV_GOT_HI20");
	case R_RISCV_TLS_GOT_HI20: UNHANDL("R_RISCV_TLS_GOT_HI20");
	case R_RISCV_TLS_GD_HI20: UNHANDL("R_RISCV_TLS_GD_HI20");
	case R_RISCV_PCREL_HI20: UNHANDL("R_RISCV_PCREL_HI20");
	case R_RISCV_PCREL_LO12_I: UNHANDL("R_RISCV_PCREL_LO12_I");
	case R_RISCV_PCREL_LO12_S: UNHANDL("R_RISCV_PCREL_LO12_S");
	case R_RISCV_HI20: UNHANDL("R_RISCV_HI20");
	case R_RISCV_LO12_I: UNHANDL("R_RISCV_LO12_I");
	case R_RISCV_LO12_S: UNHANDL("R_RISCV_LO12_S");
	case R_RISCV_TPREL_HI20: UNHANDL("R_RISCV_TPREL_HI20");
	case R_RISCV_TPREL_LO12_I: UNHANDL("R_RISCV_TPREL_LO12_I");
	case R_RISCV_TPREL_LO12_S: UNHANDL("R_RISCV_TPREL_LO12_S");
	case R_RISCV_TPREL_ADD: UNHANDL("R_RISCV_TPREL_ADD");
	case R_RISCV_ADD8: UNHANDL("R_RISCV_ADD8");
	case R_RISCV_ADD16: UNHANDL("R_RISCV_ADD16");
	case R_RISCV_ADD32: UNHANDL("R_RISCV_ADD32");
	case R_RISCV_ADD64: UNHANDL("R_RISCV_ADD64");
	case R_RISCV_SUB8: UNHANDL("R_RISCV_SUB8");
	case R_RISCV_SUB16: UNHANDL("R_RISCV_SUB16");
	case R_RISCV_SUB32: UNHANDL("R_RISCV_SUB32");
	case R_RISCV_SUB64: UNHANDL("R_RISCV_SUB64");
	case R_RISCV_GNU_VTINHERIT: UNHANDL("R_RISCV_GNU_VTINHERIT");
	case R_RISCV_GNU_VTENTRY: UNHANDL("R_RISCV_GNU_VTENTRY");
	case R_RISCV_ALIGN: UNHANDL("R_RISCV_ALIGN");
	case R_RISCV_RVC_BRANCH: UNHANDL("R_RISCV_RVC_BRANCH");
	case R_RISCV_RVC_JUMP: UNHANDL("R_RISCV_RVC_JUMP");
	case R_RISCV_RVC_LUI: UNHANDL("R_RISCV_RVC_LUI");
	case R_RISCV_GPREL_I: UNHANDL("R_RISCV_GPREL_I");
	case R_RISCV_GPREL_S: UNHANDL("R_RISCV_GPREL_S");
	case R_RISCV_TPREL_I: UNHANDL("R_RISCV_TPREL_I");
	case R_RISCV_TPREL_S: UNHANDL("R_RISCV_TPREL_S");
	case R_RISCV_RELAX: UNHANDL("R_RISCV_RELAX");
	case R_RISCV_SUB6: UNHANDL("R_RISCV_SUB6");
	case R_RISCV_SET6: UNHANDL("R_RISCV_SET6");
	case R_RISCV_SET8: UNHANDL("R_RISCV_SET8");
	case R_RISCV_SET16: UNHANDL("R_RISCV_SET16");
	case R_RISCV_SET32: UNHANDL("R_RISCV_SET32");
	case R_RISCV_32_PCREL: UNHANDL("R_RISCV_32_PCREL");
	case R_RISCV_IRELATIVE: UNHANDL("R_RISCV_IRELATIVE");
	// FIXME: Quite a few relocations missing here. It's incorrect to place them all under "reg relocations".
	default: ADD(64, GOT, "RISC-V REG RELOC", RZ_RELOC_BASE_UNKNOWN);
	}
}

static RzBinReloc *reloc_convert_aarch64(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_AARCH64_NONE:
		return reloc_convert_set(bin, rel, 0, "R_AARCH64_NONE");
	case R_AARCH64_ABS64: ADD(64, 0, "R_AARCH64_ABS64", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_ABS32: ADD(32, 0, "R_AARCH64_ABS32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_ABS32: ADD(32, 0, "R_AARCH64_P32_ABS32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_ABS16: ADD(16, 0, "R_AARCH64_ABS16", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_ABS16: ADD(16, 0, "R_AARCH64_P32_ABS16", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_PREL64: ADD(64, -P, "R_AARCH64_PREL64", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_PREL32: ADD(32, -P, "R_AARCH64_PREL32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_PREL32: ADD(32, -P, "R_AARCH64_P32_PREL32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_PREL16: ADD(16, -P, "R_AARCH64_PREL16", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_PREL16: ADD(16, -P, "R_AARCH64_P32_PREL16", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_PLT32: ADD(32, -P, "R_AARCH64_PLT32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_PLT32: ADD(32, -P, "R_AARCH64_P32_PLT32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G0: ADD(64, 0, "R_AARCH64_MOVW_UABS_G0", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_UABS_G0: ADD(32, 0, "R_AARCH64_P32_MOVW_UABS_G0", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G0_NC: ADD(64, 0, "R_AARCH64_MOVW_UABS_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_UABS_G0_NC: ADD(32, 0, "R_AARCH64_P32_MOVW_UABS_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G1: ADD(64, 0, "R_AARCH64_MOVW_UABS_G1", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_UABS_G1: ADD(32, 0, "R_AARCH64_P32_MOVW_UABS_G1", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G1_NC: ADD(64, 0, "R_AARCH64_MOVW_UABS_G1_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G2: ADD(64, 0, "R_AARCH64_MOVW_UABS_G2", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G2_NC: ADD(64, 0, "R_AARCH64_MOVW_UABS_G2_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_UABS_G3: ADD(64, 0, "R_AARCH64_MOVW_UABS_G3", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_SABS_G0: ADD(64, 0, "R_AARCH64_MOVW_SABS_G0", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_SABS_G0: ADD(32, 0, "R_AARCH64_P32_MOVW_SABS_G0", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_SABS_G1: ADD(64, 0, "R_AARCH64_MOVW_SABS_G1", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_SABS_G2: ADD(64, 0, "R_AARCH64_MOVW_SABS_G2", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_LD_PREL_LO19: ADD(64, -P, "R_AARCH64_LD_PREL_LO19", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_LD_PREL_LO19: ADD(32, -P, "R_AARCH64_P32_LD_PREL_LO19", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_ADR_PREL_LO21: ADD(64, -P, "R_AARCH64_ADR_PREL_LO21", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_ADR_PREL_LO21: ADD(32, -P, "R_AARCH64_P32_ADR_PREL_LO21", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_ADR_PREL_PG_HI21: UNHANDL("R_AARCH64_ADR_PREL_PG_HI21"); // Page(S+A)-Page(P)
	case R_AARCH64_P32_ADR_PREL_PG_HI21: UNHANDL("R_AARCH64_P32_ADR_PREL_PG_HI21"); // Page(S+A)-Page(P)
	case R_AARCH64_ADR_PREL_PG_HI21_NC: UNHANDL("R_AARCH64_ADR_PREL_PG_HI21_NC"); // Page(S+A)-Page(P)
	case R_AARCH64_ADD_ABS_LO12_NC: ADD(64, 0, "R_AARCH64_ADD_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_ADD_ABS_LO12_NC: ADD(32, 0, "R_AARCH64_P32_ADD_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_LDST8_ABS_LO12_NC: ADD(64, 0, "R_AARCH64_LDST8_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_LDST8_ABS_LO12_NC: ADD(32, 0, "R_AARCH64_P32_LDST8_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_LDST16_ABS_LO12_NC: ADD(64, 0, "R_AARCH64_LDST16_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_LDST16_ABS_LO12_NC: ADD(32, 0, "R_AARCH64_P32_LDST16_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_LDST32_ABS_LO12_NC: ADD(64, 0, "R_AARCH64_LDST32_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_LDST32_ABS_LO12_NC: ADD(32, 0, "R_AARCH64_P32_LDST32_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_LDST64_ABS_LO12_NC: ADD(64, 0, "R_AARCH64_LDST64_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_LDST64_ABS_LO12_NC: ADD(32, 0, "R_AARCH64_P32_LDST64_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_LDST128_ABS_LO12_NC: ADD(64, 0, "R_AARCH64_LDST128_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_LDST128_ABS_LO12_NC: ADD(32, 0, "R_AARCH64_P32_LDST128_ABS_LO12_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_TSTBR14: ADD(64, -P, "R_AARCH64_TSTBR14", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_TSTBR14: ADD(32, -P, "R_AARCH64_P32_TSTBR14", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_CONDBR19: ADD(64, -P, "R_AARCH64_CONDBR19", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_CONDBR19: ADD(32, -P, "R_AARCH64_P32_CONDBR19", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_JUMP26: ADD(64, -P, "R_AARCH64_JUMP26", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_JUMP26: ADD(32, -P, "R_AARCH64_P32_JUMP26", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_CALL26: ADD(64, -P, "R_AARCH64_CALL26", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_CALL26: ADD(32, -P, "R_AARCH64_P32_CALL26", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G0: ADD(64, -P, "R_AARCH64_MOVW_PREL_G0", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_PREL_G0: ADD(32, -P, "R_AARCH64_P32_MOVW_PREL_G0", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G0_NC: ADD(64, -P, "R_AARCH64_MOVW_PREL_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_PREL_G0_NC: ADD(32, -P, "R_AARCH64_P32_MOVW_PREL_G0_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G1: ADD(64, -P, "R_AARCH64_MOVW_PREL_G1", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_MOVW_PREL_G1: ADD(32, -P, "R_AARCH64_P32_MOVW_PREL_G1", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G1_NC: ADD(64, -P, "R_AARCH64_MOVW_PREL_G1_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G2: ADD(64, -P, "R_AARCH64_MOVW_PREL_G2", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G2_NC: ADD(64, -P, "R_AARCH64_MOVW_PREL_G2_NC", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_PREL_G3: ADD(64, -P, "R_AARCH64_MOVW_PREL_G3", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_MOVW_GOTOFF_G0: UNHANDL("R_AARCH64_MOVW_GOTOFF_G0");
	case R_AARCH64_MOVW_GOTOFF_G0_NC: ADD(32, -GOT, "R_AARCH64_MOVW_GOTOFF_G0_NC", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_MOVW_GOTOFF_G1: ADD(32, -GOT, "R_AARCH64_MOVW_GOTOFF_G1", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_MOVW_GOTOFF_G1_NC: ADD(32, -GOT, "R_AARCH64_MOVW_GOTOFF_G1_NC", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_MOVW_GOTOFF_G2: ADD(32, -GOT, "R_AARCH64_MOVW_GOTOFF_G2", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_MOVW_GOTOFF_G2_NC: ADD(32, -GOT, "R_AARCH64_MOVW_GOTOFF_G2_NC", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_MOVW_GOTOFF_G3: ADD(32, -GOT, "R_AARCH64_MOVW_GOTOFF_G3", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_GOTREL64: ADD(64, -GOT, "R_AARCH64_GOTREL64", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_GOTREL32: ADD(32, -GOT, "R_AARCH64_GOTREL32", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_GOT_LD_PREL19: ADD(32, -P, "R_AARCH64_GOT_LD_PREL19", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_P32_GOT_LD_PREL19: ADD(32, -P, "R_AARCH64_P32_GOT_LD_PREL19", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_LD64_GOTOFF_LO15: ADD(32, -GOT, "R_AARCH64_LD64_GOTOFF_LO15", RZ_RELOC_BASE_GOT_SYMBOL);
	case R_AARCH64_ADR_GOT_PAGE: UNHANDL("R_AARCH64_ADR_GOT_PAGE");
	case R_AARCH64_P32_ADR_GOT_PAGE: UNHANDL("R_AARCH64_P32_ADR_GOT_PAGE");
	case R_AARCH64_LD64_GOT_LO12_NC: UNHANDL("R_AARCH64_LD64_GOT_LO12_NC");
	case R_AARCH64_P32_LD32_GOT_LO12_NC: UNHANDL("R_AARCH64_P32_LD32_GOT_LO12_NC");
	case R_AARCH64_LD64_GOTPAGE_LO15: UNHANDL("R_AARCH64_LD64_GOTPAGE_LO15");
	case R_AARCH64_P32_LD32_GOTPAGE_LO14: UNHANDL("R_AARCH64_P32_LD32_GOTPAGE_LO14");
	case R_AARCH64_TLSGD_ADR_PREL21: UNHANDL("R_AARCH64_TLSGD_ADR_PREL21");
	case R_AARCH64_P32_TLSGD_ADR_PREL21: UNHANDL("R_AARCH64_P32_TLSGD_ADR_PREL21");
	case R_AARCH64_TLSGD_ADR_PAGE21: UNHANDL("R_AARCH64_TLSGD_ADR_PAGE21");
	case R_AARCH64_P32_TLSGD_ADR_PAGE21: UNHANDL("R_AARCH64_P32_TLSGD_ADR_PAGE21");
	case R_AARCH64_TLSGD_ADD_LO12_NC: UNHANDL("R_AARCH64_TLSGD_ADD_LO12_NC");
	case R_AARCH64_P32_TLSGD_ADD_LO12_NC: UNHANDL("R_AARCH64_P32_TLSGD_ADD_LO12_NC");
	case R_AARCH64_TLSGD_MOVW_G1: UNHANDL("R_AARCH64_TLSGD_MOVW_G1");
	case R_AARCH64_TLSGD_MOVW_G0_NC: UNHANDL("R_AARCH64_TLSGD_MOVW_G0_NC");
	case R_AARCH64_TLSLD_ADR_PREL21: UNHANDL("R_AARCH64_TLSLD_ADR_PREL21");
	case R_AARCH64_P32_TLSLD_ADR_PREL21: UNHANDL("R_AARCH64_P32_TLSLD_ADR_PREL21");
	case R_AARCH64_TLSLD_ADR_PAGE21: UNHANDL("R_AARCH64_TLSLD_ADR_PAGE21");
	case R_AARCH64_P32_TLSLD_ADR_PAGE21: UNHANDL("R_AARCH64_P32_TLSLD_ADR_PAGE21");
	case R_AARCH64_TLSLD_ADD_LO12_NC: UNHANDL("R_AARCH64_TLSLD_ADD_LO12_NC");
	case R_AARCH64_P32_TLSLD_ADD_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_ADD_LO12_NC");
	case R_AARCH64_TLSLD_MOVW_G1: UNHANDL("R_AARCH64_TLSLD_MOVW_G1");
	case R_AARCH64_TLSLD_MOVW_G0_NC: UNHANDL("R_AARCH64_TLSLD_MOVW_G0_NC");
	case R_AARCH64_TLSLD_LD_PREL19: UNHANDL("R_AARCH64_TLSLD_LD_PREL19");
	case R_AARCH64_P32_TLSLD_LD_PREL19: UNHANDL("R_AARCH64_P32_TLSLD_LD_PREL19");
	case R_AARCH64_TLSLD_MOVW_DTPREL_G2: UNHANDL("R_AARCH64_TLSLD_MOVW_DTPREL_G2");
	case R_AARCH64_TLSLD_MOVW_DTPREL_G1: UNHANDL("R_AARCH64_TLSLD_MOVW_DTPREL_G1");
	case R_AARCH64_P32_TLSLD_MOVW_DTPREL_G1: UNHANDL("R_AARCH64_P32_TLSLD_MOVW_DTPREL_G1");
	case R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC: UNHANDL("R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC");
	case R_AARCH64_TLSLD_MOVW_DTPREL_G0: UNHANDL("R_AARCH64_TLSLD_MOVW_DTPREL_G0");
	case R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0: UNHANDL("R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0");
	case R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC: UNHANDL("R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC");
	case R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0_NC: UNHANDL("R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0_NC");
	case R_AARCH64_TLSLD_ADD_DTPREL_HI12: UNHANDL("R_AARCH64_TLSLD_ADD_DTPREL_HI12");
	case R_AARCH64_P32_TLSLD_ADD_DTPREL_HI12: UNHANDL("R_AARCH64_P32_TLSLD_ADD_DTPREL_HI12");
	case R_AARCH64_TLSLD_ADD_DTPREL_LO12: UNHANDL("R_AARCH64_TLSLD_ADD_DTPREL_LO12");
	case R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12");
	case R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC");
	case R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12_NC");
	case R_AARCH64_TLSLD_LDST8_DTPREL_LO12: UNHANDL("R_AARCH64_TLSLD_LDST8_DTPREL_LO12");
	case R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12");
	case R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC");
	case R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12_NC");
	case R_AARCH64_TLSLD_LDST16_DTPREL_LO12: UNHANDL("R_AARCH64_TLSLD_LDST16_DTPREL_LO12");
	case R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12");
	case R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC");
	case R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12_NC");
	case R_AARCH64_TLSLD_LDST32_DTPREL_LO12: UNHANDL("R_AARCH64_TLSLD_LDST32_DTPREL_LO12");
	case R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12");
	case R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC");
	case R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12_NC");
	case R_AARCH64_TLSLD_LDST64_DTPREL_LO12: UNHANDL("R_AARCH64_TLSLD_LDST64_DTPREL_LO12");
	case R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12");
	case R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC");
	case R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12_NC");
	case R_AARCH64_TLSLD_LDST128_DTPREL_LO12: UNHANDL("R_AARCH64_TLSLD_LDST128_DTPREL_LO12");
	case R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12");
	case R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC");
	case R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLD_LDST128_DTPREL_LO12_NC");
	case R_AARCH64_TLSIE_MOVW_GOTTPREL_G1: UNHANDL("R_AARCH64_TLSIE_MOVW_GOTTPREL_G1");
	case R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC: UNHANDL("R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC");
	case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21: UNHANDL("R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21");
	case R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21: UNHANDL("R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21");
	case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: UNHANDL("R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC");
	case R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC");
	case R_AARCH64_TLSIE_LD_GOTTPREL_PREL19: UNHANDL("R_AARCH64_TLSIE_LD_GOTTPREL_PREL19");
	case R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19: UNHANDL("R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19");
	case R_AARCH64_TLSLE_MOVW_TPREL_G2: UNHANDL("R_AARCH64_TLSLE_MOVW_TPREL_G2");
	case R_AARCH64_TLSLE_MOVW_TPREL_G1: UNHANDL("R_AARCH64_TLSLE_MOVW_TPREL_G1");
	case R_AARCH64_P32_TLSLE_MOVW_TPREL_G1: UNHANDL("R_AARCH64_P32_TLSLE_MOVW_TPREL_G1");
	case R_AARCH64_TLSLE_MOVW_TPREL_G1_NC: UNHANDL("R_AARCH64_TLSLE_MOVW_TPREL_G1_NC");
	case R_AARCH64_TLSLE_MOVW_TPREL_G0: UNHANDL("R_AARCH64_TLSLE_MOVW_TPREL_G0");
	case R_AARCH64_P32_TLSLE_MOVW_TPREL_G0: UNHANDL("R_AARCH64_P32_TLSLE_MOVW_TPREL_G0");
	case R_AARCH64_TLSLE_MOVW_TPREL_G0_NC: UNHANDL("R_AARCH64_TLSLE_MOVW_TPREL_G0_NC");
	case R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC: UNHANDL("R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC");
	case R_AARCH64_TLSLE_ADD_TPREL_HI12: UNHANDL("R_AARCH64_TLSLE_ADD_TPREL_HI12");
	case R_AARCH64_P32_TLSLE_ADD_TPREL_HI12: UNHANDL("R_AARCH64_P32_TLSLE_ADD_TPREL_HI12");
	case R_AARCH64_TLSLE_ADD_TPREL_LO12: UNHANDL("R_AARCH64_TLSLE_ADD_TPREL_LO12");
	case R_AARCH64_P32_TLSLE_ADD_TPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLE_ADD_TPREL_LO12");
	case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLE_ADD_TPREL_LO12_NC");
	case R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC");
	case R_AARCH64_TLSLE_LDST8_TPREL_LO12: UNHANDL("R_AARCH64_TLSLE_LDST8_TPREL_LO12");
	case R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12");
	case R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC");
	case R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC");
	case R_AARCH64_TLSLE_LDST16_TPREL_LO12: UNHANDL("R_AARCH64_TLSLE_LDST16_TPREL_LO12");
	case R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12");
	case R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC");
	case R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC");
	case R_AARCH64_TLSLE_LDST32_TPREL_LO12: UNHANDL("R_AARCH64_TLSLE_LDST32_TPREL_LO12");
	case R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12");
	case R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC");
	case R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC");
	case R_AARCH64_TLSLE_LDST64_TPREL_LO12: UNHANDL("R_AARCH64_TLSLE_LDST64_TPREL_LO12");
	case R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12");
	case R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC");
	case R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC");
	case R_AARCH64_TLSLE_LDST128_TPREL_LO12: UNHANDL("R_AARCH64_TLSLE_LDST128_TPREL_LO12");
	case R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12: UNHANDL("R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12");
	case R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC: UNHANDL("R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC");
	case R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12_NC: UNHANDL("R_AARCH64_P32_TLSLE_LDST128_TPREL_LO12_NC");
	case R_AARCH64_TLSDESC_LD_PREL19: UNHANDL("R_AARCH64_TLSDESC_LD_PREL19");
	case R_AARCH64_P32_TLSDESC_LD_PREL19: UNHANDL("R_AARCH64_P32_TLSDESC_LD_PREL19");
	case R_AARCH64_TLSDESC_ADR_PREL21: UNHANDL("R_AARCH64_TLSDESC_ADR_PREL21");
	case R_AARCH64_P32_TLSDESC_ADR_PREL21: UNHANDL("R_AARCH64_P32_TLSDESC_ADR_PREL21");
	case R_AARCH64_TLSDESC_ADR_PAGE21: UNHANDL("R_AARCH64_TLSDESC_ADR_PAGE21");
	case R_AARCH64_P32_TLSDESC_ADR_PAGE21: UNHANDL("R_AARCH64_P32_TLSDESC_ADR_PAGE21");
	case R_AARCH64_TLSDESC_LD64_LO12: UNHANDL("R_AARCH64_TLSDESC_LD64_LO12");
	case R_AARCH64_P32_TLSDESC_LD32_LO12: UNHANDL("R_AARCH64_P32_TLSDESC_LD32_LO12");
	case R_AARCH64_TLSDESC_ADD_LO12: UNHANDL("R_AARCH64_TLSDESC_ADD_LO12");
	case R_AARCH64_P32_TLSDESC_ADD_LO12: UNHANDL("R_AARCH64_P32_TLSDESC_ADD_LO12");
	case R_AARCH64_TLSDESC_OFF_G1: UNHANDL("R_AARCH64_TLSDESC_OFF_G1");
	case R_AARCH64_TLSDESC_OFF_G0_NC: UNHANDL("R_AARCH64_TLSDESC_OFF_G0_NC");
	case R_AARCH64_TLSDESC_LDR: UNHANDL("R_AARCH64_TLSDESC_LDR");
	case R_AARCH64_TLSDESC_ADD: UNHANDL("R_AARCH64_TLSDESC_ADD");
	case R_AARCH64_TLSDESC_CALL: UNHANDL("R_AARCH64_TLSDESC_CALL");
	case R_AARCH64_P32_TLSDESC_CALL: UNHANDL("R_AARCH64_P32_TLSDESC_CALL");
	case R_AARCH64_COPY: UNHANDL("R_AARCH64_COPY");
	case R_AARCH64_P32_COPY: UNHANDL("R_AARCH64_P32_COPY");
	case R_AARCH64_GLOB_DAT: ADD(64, 0, "R_AARCH64_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_GLOB_DAT: ADD(32, 0, "R_AARCH64_P32_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_JUMP_SLOT: ADD(64, 0, "R_AARCH64_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_P32_JUMP_SLOT: ADD(32, 0, "R_AARCH64_P32_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_AARCH64_RELATIVE: ADD(64, 0, "R_AARCH64_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_AARCH64_P32_RELATIVE: ADD(32, 0, "R_AARCH64_P32_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_AARCH64_TLS_IMPDEF1: UNHANDL("R_AARCH64_TLS_IMPDEF1");
	case R_AARCH64_P32_TLS_IMPDEF1: UNHANDL("R_AARCH64_P32_TLS_IMPDEF1");
	case R_AARCH64_TLS_IMPDEF2: UNHANDL("R_AARCH64_TLS_IMPDEF2");
	case R_AARCH64_P32_TLS_IMPDEF2: UNHANDL("R_AARCH64_P32_TLS_IMPDEF2");
	case R_AARCH64_TLS_TPREL: UNHANDL("R_AARCH64_TLS_TPREL");
	case R_AARCH64_P32_TLS_TPREL: UNHANDL("R_AARCH64_P32_TLS_TPREL");
	case R_AARCH64_TLSDESC: UNHANDL("R_AARCH64_TLSDESC");
	case R_AARCH64_P32_TLSDESC: UNHANDL("R_AARCH64_P32_TLSDESC");
	case R_AARCH64_IRELATIVE: ADD(64, 0, "R_AARCH64_IRELATIVE", RZ_RELOC_BASE_BASE);
	case R_AARCH64_P32_IRELATIVE: ADD(32, 0, "R_AARCH64_P32_IRELATIVE", RZ_RELOC_BASE_BASE);
	case R_AARCH64_AUTH_ABS64: UNHANDL("R_AARCH64_AUTH_ABS64");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G0: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G0");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G0_NC: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G0_NC");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G1: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G1");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G1_NC: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G1_NC");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G2: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G2");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G2_NC: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G2_NC");
	case R_AARCH64_AUTH_MOVW_GOTOFF_G3: UNHANDL("R_AARCH64_AUTH_MOVW_GOTOFF_G3");
	case R_AARCH64_AUTH_GOT_LD_PREL19: UNHANDL("R_AARCH64_AUTH_GOT_LD_PREL19");
	case R_AARCH64_AUTH_LD64_GOTOFF_LO15: UNHANDL("R_AARCH64_AUTH_LD64_GOTOFF_LO15");
	case R_AARCH64_AUTH_ADR_GOT_PAGE: UNHANDL("R_AARCH64_AUTH_ADR_GOT_PAGE");
	case R_AARCH64_AUTH_LD64_GOT_LO12_NC: UNHANDL("R_AARCH64_AUTH_LD64_GOT_LO12_NC");
	case R_AARCH64_AUTH_LD64_GOTPAGE_LO15: UNHANDL("R_AARCH64_AUTH_LD64_GOTPAGE_LO15");
	case R_AARCH64_AUTH_GOT_ADD_LO12_NC: UNHANDL("R_AARCH64_AUTH_GOT_ADD_LO12_NC");
	case R_AARCH64_AUTH_GOT_ADR_PREL_LO21: UNHANDL("R_AARCH64_AUTH_GOT_ADR_PREL_LO21");
	case R_AARCH64_AUTH_TLSDESC_ADR_PAGE21: UNHANDL("R_AARCH64_AUTH_TLSDESC_ADR_PAGE21");
	case R_AARCH64_AUTH_TLSDESC_LD64_LO12: UNHANDL("R_AARCH64_AUTH_TLSDESC_LD64_LO12");
	case R_AARCH64_AUTH_TLSDESC_ADD_LO12: UNHANDL("R_AARCH64_AUTH_TLSDESC_ADD_LO12");
	// FIXME: Quite a few relocations missing here
	default: UNSUPP("AArch64");
	}
}

static RzBinReloc *reloc_convert_ppc(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_PPC_NONE:
		return reloc_convert_set(bin, rel, 0, "R_PPC_NONE");
	case R_PPC_GLOB_DAT: ADD(32, 0, "R_PPC_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_JMP_SLOT: ADD(32, 0, "R_PPC_JMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_COPY: ADD(32, 0, "R_PPC_COPY", RZ_RELOC_BASE_UNKNOWN); // copy symbol at runtime
	case R_PPC_REL24: ADD(24, -P, "R_PPC_REL24", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_REL14: ADD(16, -P, "R_PPC_REL14", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_REL32: ADD(32, -P, "R_PPC_REL32", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_RELATIVE: ADD(32, -P, "R_PPC_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_PPC_PLT32: ADD(32, -P, "R_PPC_PLT32", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_PPC_ADDR16: ADD(16, 0, "R_PPC_ADDR16", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_ADDR32: ADD(32, 0, "R_PPC_ADDR32", RZ_RELOC_BASE_SYMBOL);
	case R_PPC_ADDR24: UNHANDL("R_PPC_ADDR24");
	case R_PPC_ADDR16_LO: UNHANDL("R_PPC_ADDR16_LO");
	case R_PPC_ADDR16_HI: UNHANDL("R_PPC_ADDR16_HI");
	case R_PPC_ADDR16_HA: UNHANDL("R_PPC_ADDR16_HA");
	case R_PPC_ADDR14: UNHANDL("R_PPC_ADDR14");
	case R_PPC_ADDR14_BRTAKEN: UNHANDL("R_PPC_ADDR14_BRTAKEN");
	case R_PPC_ADDR14_BRNTAKEN: UNHANDL("R_PPC_ADDR14_BRNTAKEN");
	case R_PPC_REL14_BRTAKEN: UNHANDL("R_PPC_REL14_BRTAKEN");
	case R_PPC_REL14_BRNTAKEN: UNHANDL("R_PPC_REL14_BRNTAKEN");
	case R_PPC_GOT16: UNHANDL("R_PPC_GOT16");
	case R_PPC_GOT16_LO: UNHANDL("R_PPC_GOT16_LO");
	case R_PPC_GOT16_HI: UNHANDL("R_PPC_GOT16_HI");
	case R_PPC_GOT16_HA: UNHANDL("R_PPC_GOT16_HA");
	case R_PPC_PLTREL24: UNHANDL("R_PPC_PLTREL24");
	case R_PPC_LOCAL24PC: UNHANDL("R_PPC_LOCAL24PC");
	case R_PPC_UADDR32: UNHANDL("R_PPC_UADDR32");
	case R_PPC_UADDR16: UNHANDL("R_PPC_UADDR16");
	case R_PPC_PLTREL32: UNHANDL("R_PPC_PLTREL32");
	case R_PPC_PLT16_LO: UNHANDL("R_PPC_PLT16_LO");
	case R_PPC_PLT16_HI: UNHANDL("R_PPC_PLT16_HI");
	case R_PPC_PLT16_HA: UNHANDL("R_PPC_PLT16_HA");
	case R_PPC_SDAREL16: UNHANDL("R_PPC_SDAREL16");
	case R_PPC_SECTOFF: UNHANDL("R_PPC_SECTOFF");
	case R_PPC_SECTOFF_LO: UNHANDL("R_PPC_SECTOFF_LO");
	case R_PPC_SECTOFF_HI: UNHANDL("R_PPC_SECTOFF_HI");
	case R_PPC_SECTOFF_HA: UNHANDL("R_PPC_SECTOFF_HA");
	case R_PPC_TLS: UNHANDL("R_PPC_TLS");
	case R_PPC_DTPMOD32: UNHANDL("R_PPC_DTPMOD32");
	case R_PPC_TPREL16: UNHANDL("R_PPC_TPREL16");
	case R_PPC_TPREL16_LO: UNHANDL("R_PPC_TPREL16_LO");
	case R_PPC_TPREL16_HI: UNHANDL("R_PPC_TPREL16_HI");
	case R_PPC_TPREL16_HA: UNHANDL("R_PPC_TPREL16_HA");
	case R_PPC_TPREL32: UNHANDL("R_PPC_TPREL32");
	case R_PPC_DTPREL16: UNHANDL("R_PPC_DTPREL16");
	case R_PPC_DTPREL16_LO: UNHANDL("R_PPC_DTPREL16_LO");
	case R_PPC_DTPREL16_HI: UNHANDL("R_PPC_DTPREL16_HI");
	case R_PPC_DTPREL16_HA: UNHANDL("R_PPC_DTPREL16_HA");
	case R_PPC_DTPREL32: UNHANDL("R_PPC_DTPREL32");
	case R_PPC_GOT_TLSGD16: UNHANDL("R_PPC_GOT_TLSGD16");
	case R_PPC_GOT_TLSGD16_LO: UNHANDL("R_PPC_GOT_TLSGD16_LO");
	case R_PPC_GOT_TLSGD16_HI: UNHANDL("R_PPC_GOT_TLSGD16_HI");
	case R_PPC_GOT_TLSGD16_HA: UNHANDL("R_PPC_GOT_TLSGD16_HA");
	case R_PPC_GOT_TLSLD16: UNHANDL("R_PPC_GOT_TLSLD16");
	case R_PPC_GOT_TLSLD16_LO: UNHANDL("R_PPC_GOT_TLSLD16_LO");
	case R_PPC_GOT_TLSLD16_HI: UNHANDL("R_PPC_GOT_TLSLD16_HI");
	case R_PPC_GOT_TLSLD16_HA: UNHANDL("R_PPC_GOT_TLSLD16_HA");
	case R_PPC_GOT_TPREL16: UNHANDL("R_PPC_GOT_TPREL16");
	case R_PPC_GOT_TPREL16_LO: UNHANDL("R_PPC_GOT_TPREL16_LO");
	case R_PPC_GOT_TPREL16_HI: UNHANDL("R_PPC_GOT_TPREL16_HI");
	case R_PPC_GOT_TPREL16_HA: UNHANDL("R_PPC_GOT_TPREL16_HA");
	case R_PPC_GOT_DTPREL16: UNHANDL("R_PPC_GOT_DTPREL16");
	case R_PPC_GOT_DTPREL16_LO: UNHANDL("R_PPC_GOT_DTPREL16_LO");
	case R_PPC_GOT_DTPREL16_HI: UNHANDL("R_PPC_GOT_DTPREL16_HI");
	case R_PPC_GOT_DTPREL16_HA: UNHANDL("R_PPC_GOT_DTPREL16_HA");
	case R_PPC_TLSGD: UNHANDL("R_PPC_TLSGD");
	case R_PPC_TLSLD: UNHANDL("R_PPC_TLSLD");
	case R_PPC_EMB_NADDR32: UNHANDL("R_PPC_EMB_NADDR32");
	case R_PPC_EMB_NADDR16: UNHANDL("R_PPC_EMB_NADDR16");
	case R_PPC_EMB_NADDR16_LO: UNHANDL("R_PPC_EMB_NADDR16_LO");
	case R_PPC_EMB_NADDR16_HI: UNHANDL("R_PPC_EMB_NADDR16_HI");
	case R_PPC_EMB_NADDR16_HA: UNHANDL("R_PPC_EMB_NADDR16_HA");
	case R_PPC_EMB_SDAI16: UNHANDL("R_PPC_EMB_SDAI16");
	case R_PPC_EMB_SDA2I16: UNHANDL("R_PPC_EMB_SDA2I16");
	case R_PPC_EMB_SDA2REL: UNHANDL("R_PPC_EMB_SDA2REL");
	case R_PPC_EMB_SDA21: UNHANDL("R_PPC_EMB_SDA21");
	case R_PPC_EMB_MRKREF: UNHANDL("R_PPC_EMB_MRKREF");
	case R_PPC_EMB_RELSEC16: UNHANDL("R_PPC_EMB_RELSEC16");
	case R_PPC_EMB_RELST_LO: UNHANDL("R_PPC_EMB_RELST_LO");
	case R_PPC_EMB_RELST_HI: UNHANDL("R_PPC_EMB_RELST_HI");
	case R_PPC_EMB_RELST_HA: UNHANDL("R_PPC_EMB_RELST_HA");
	case R_PPC_EMB_BIT_FLD: UNHANDL("R_PPC_EMB_BIT_FLD");
	case R_PPC_EMB_RELSDA: UNHANDL("R_PPC_EMB_RELSDA");
	case R_PPC_DIAB_SDA21_LO: UNHANDL("R_PPC_DIAB_SDA21_LO");
	case R_PPC_DIAB_SDA21_HI: UNHANDL("R_PPC_DIAB_SDA21_HI");
	case R_PPC_DIAB_SDA21_HA: UNHANDL("R_PPC_DIAB_SDA21_HA");
	case R_PPC_DIAB_RELSDA_LO: UNHANDL("R_PPC_DIAB_RELSDA_LO");
	case R_PPC_DIAB_RELSDA_HI: UNHANDL("R_PPC_DIAB_RELSDA_HI");
	case R_PPC_DIAB_RELSDA_HA: UNHANDL("R_PPC_DIAB_RELSDA_HA");
	case R_PPC_IRELATIVE: UNHANDL("R_PPC_IRELATIVE");
	case R_PPC_REL16: UNHANDL("R_PPC_REL16");
	case R_PPC_REL16_LO: UNHANDL("R_PPC_REL16_LO");
	case R_PPC_REL16_HI: UNHANDL("R_PPC_REL16_HI");
	case R_PPC_REL16_HA: UNHANDL("R_PPC_REL16_HA");
	case R_PPC_TOC16: UNHANDL("R_PPC_TOC16");
	// FIXME: Quite a few relocations missing here.
	default: UNSUPP("PPC");
	}
}

static RzBinReloc *reloc_convert_ppc64(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_PPC64_NONE:
		return reloc_convert_set(bin, rel, 0, "R_PPC64_NONE");
	case R_PPC64_ADDR32: ADD(32, 0, "R_PPC64_ADDR32", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_ADDR24: ADD(24, 0, "R_PPC64_ADDR24", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_ADDR16: ADD(16, 0, "R_PPC64_ADDR16", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_ADDR16_LO: UNHANDL("R_PPC64_ADDR16_LO");
	case R_PPC64_ADDR16_HI: UNHANDL("R_PPC64_ADDR16_HI");
	case R_PPC64_ADDR16_HA: UNHANDL("R_PPC64_ADDR16_HA");
	case R_PPC64_ADDR14: UNHANDL("R_PPC64_ADDR14");
	case R_PPC64_ADDR14_BRTAKEN: UNHANDL("R_PPC64_ADDR14_BRTAKEN");
	case R_PPC64_ADDR14_BRNTAKEN: UNHANDL("R_PPC64_ADDR14_BRNTAKEN");
	case R_PPC64_REL24: ADD(24, -P, "R_PPC64_REL24", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_REL14: ADD(16, -P, "R_PPC64_REL14", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_REL14_BRTAKEN: UNHANDL("R_PPC64_REL14_BRTAKEN");
	case R_PPC64_REL14_BRNTAKEN: UNHANDL("R_PPC64_REL14_BRNTAKEN");
	case R_PPC64_GOT16: UNHANDL("R_PPC64_GOT16");
	case R_PPC64_GOT16_LO: UNHANDL("R_PPC64_GOT16_LO");
	case R_PPC64_GOT16_HI: UNHANDL("R_PPC64_GOT16_HI");
	case R_PPC64_GOT16_HA: UNHANDL("R_PPC64_GOT16_HA");
	case R_PPC64_COPY: ADD(64, 0, "R_PPC64_COPY", RZ_RELOC_BASE_UNKNOWN);
	case R_PPC64_GLOB_DAT: ADD(64, 0, "R_PPC64_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_JMP_SLOT: ADD(64, 0, "R_PPC64_JMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_RELATIVE: ADD(64, 0, "R_PPC64_RELATIVE", RZ_RELOC_BASE_BASE);
	case R_PPC64_UADDR32: UNHANDL("R_PPC64_UADDR32");
	case R_PPC64_UADDR16: UNHANDL("R_PPC64_UADDR16");
	case R_PPC64_REL32: ADD(32, -P, "R_PPC64_REL32", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_PLT32: ADD(32, -P, "R_PPC64_PLT32", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_PPC64_PLTREL32: UNHANDL("R_PPC64_PLTREL32");
	case R_PPC64_PLT16_LO: UNHANDL("R_PPC64_PLT16_LO");
	case R_PPC64_PLT16_HI: UNHANDL("R_PPC64_PLT16_HI");
	case R_PPC64_PLT16_HA: UNHANDL("R_PPC64_PLT16_HA");
	case R_PPC64_SECTOFF: UNHANDL("R_PPC64_SECTOFF");
	case R_PPC64_SECTOFF_LO: UNHANDL("R_PPC64_SECTOFF_LO");
	case R_PPC64_SECTOFF_HI: UNHANDL("R_PPC64_SECTOFF_HI");
	case R_PPC64_SECTOFF_HA: UNHANDL("R_PPC64_SECTOFF_HA");
	case R_PPC64_ADDR30: UNHANDL("R_PPC64_ADDR30");
	case R_PPC64_ADDR64: ADD(64, 0, "R_PPC64_ADDR64", RZ_RELOC_BASE_SYMBOL);
	case R_PPC64_ADDR16_HIGHER: UNHANDL("R_PPC64_ADDR16_HIGHER");
	case R_PPC64_ADDR16_HIGHERA: UNHANDL("R_PPC64_ADDR16_HIGHERA");
	case R_PPC64_ADDR16_HIGHEST: UNHANDL("R_PPC64_ADDR16_HIGHEST");
	case R_PPC64_ADDR16_HIGHESTA: UNHANDL("R_PPC64_ADDR16_HIGHESTA");
	case R_PPC64_UADDR64: UNHANDL("R_PPC64_UADDR64");
	case R_PPC64_REL64: UNHANDL("R_PPC64_REL64");
	case R_PPC64_PLT64: UNHANDL("R_PPC64_PLT64");
	case R_PPC64_PLTREL64: UNHANDL("R_PPC64_PLTREL64");
	case R_PPC64_TOC16: UNHANDL("R_PPC64_TOC16");
	case R_PPC64_TOC16_LO: UNHANDL("R_PPC64_TOC16_LO");
	case R_PPC64_TOC16_HI: UNHANDL("R_PPC64_TOC16_HI");
	case R_PPC64_TOC16_HA: UNHANDL("R_PPC64_TOC16_HA");
	case R_PPC64_TOC: UNHANDL("R_PPC64_TOC");
	case R_PPC64_PLTGOT16: UNHANDL("R_PPC64_PLTGOT16");
	case R_PPC64_PLTGOT16_LO: UNHANDL("R_PPC64_PLTGOT16_LO");
	case R_PPC64_PLTGOT16_HI: UNHANDL("R_PPC64_PLTGOT16_HI");
	case R_PPC64_PLTGOT16_HA: UNHANDL("R_PPC64_PLTGOT16_HA");
	case R_PPC64_ADDR16_DS: UNHANDL("R_PPC64_ADDR16_DS");
	case R_PPC64_ADDR16_LO_DS: UNHANDL("R_PPC64_ADDR16_LO_DS");
	case R_PPC64_GOT16_DS: UNHANDL("R_PPC64_GOT16_DS");
	case R_PPC64_GOT16_LO_DS: UNHANDL("R_PPC64_GOT16_LO_DS");
	case R_PPC64_PLT16_LO_DS: UNHANDL("R_PPC64_PLT16_LO_DS");
	case R_PPC64_SECTOFF_DS: UNHANDL("R_PPC64_SECTOFF_DS");
	case R_PPC64_SECTOFF_LO_DS: UNHANDL("R_PPC64_SECTOFF_LO_DS");
	case R_PPC64_TOC16_DS: UNHANDL("R_PPC64_TOC16_DS");
	case R_PPC64_TOC16_LO_DS: UNHANDL("R_PPC64_TOC16_LO_DS");
	case R_PPC64_PLTGOT16_DS: UNHANDL("R_PPC64_PLTGOT16_DS");
	case R_PPC64_PLTGOT16_LO_DS: UNHANDL("R_PPC64_PLTGOT16_LO_DS");
	case R_PPC64_TLS: UNHANDL("R_PPC64_TLS");
	case R_PPC64_DTPMOD64: UNHANDL("R_PPC64_DTPMOD64");
	case R_PPC64_TPREL16: UNHANDL("R_PPC64_TPREL16");
	case R_PPC64_TPREL16_LO: UNHANDL("R_PPC64_TPREL16_LO");
	case R_PPC64_TPREL16_HI: UNHANDL("R_PPC64_TPREL16_HI");
	case R_PPC64_TPREL16_HA: UNHANDL("R_PPC64_TPREL16_HA");
	case R_PPC64_TPREL64: UNHANDL("R_PPC64_TPREL64");
	case R_PPC64_DTPREL16: UNHANDL("R_PPC64_DTPREL16");
	case R_PPC64_DTPREL16_LO: UNHANDL("R_PPC64_DTPREL16_LO");
	case R_PPC64_DTPREL16_HI: UNHANDL("R_PPC64_DTPREL16_HI");
	case R_PPC64_DTPREL16_HA: UNHANDL("R_PPC64_DTPREL16_HA");
	case R_PPC64_DTPREL64: UNHANDL("R_PPC64_DTPREL64");
	case R_PPC64_GOT_TLSGD16: UNHANDL("R_PPC64_GOT_TLSGD16");
	case R_PPC64_GOT_TLSGD16_LO: UNHANDL("R_PPC64_GOT_TLSGD16_LO");
	case R_PPC64_GOT_TLSGD16_HI: UNHANDL("R_PPC64_GOT_TLSGD16_HI");
	case R_PPC64_GOT_TLSGD16_HA: UNHANDL("R_PPC64_GOT_TLSGD16_HA");
	case R_PPC64_GOT_TLSLD16: UNHANDL("R_PPC64_GOT_TLSLD16");
	case R_PPC64_GOT_TLSLD16_LO: UNHANDL("R_PPC64_GOT_TLSLD16_LO");
	case R_PPC64_GOT_TLSLD16_HI: UNHANDL("R_PPC64_GOT_TLSLD16_HI");
	case R_PPC64_GOT_TLSLD16_HA: UNHANDL("R_PPC64_GOT_TLSLD16_HA");
	case R_PPC64_GOT_TPREL16_DS: UNHANDL("R_PPC64_GOT_TPREL16_DS");
	case R_PPC64_GOT_TPREL16_LO_DS: UNHANDL("R_PPC64_GOT_TPREL16_LO_DS");
	case R_PPC64_GOT_TPREL16_HI: UNHANDL("R_PPC64_GOT_TPREL16_HI");
	case R_PPC64_GOT_TPREL16_HA: UNHANDL("R_PPC64_GOT_TPREL16_HA");
	case R_PPC64_GOT_DTPREL16_DS: UNHANDL("R_PPC64_GOT_DTPREL16_DS");
	case R_PPC64_GOT_DTPREL16_LO_DS: UNHANDL("R_PPC64_GOT_DTPREL16_LO_DS");
	case R_PPC64_GOT_DTPREL16_HI: UNHANDL("R_PPC64_GOT_DTPREL16_HI");
	case R_PPC64_GOT_DTPREL16_HA: UNHANDL("R_PPC64_GOT_DTPREL16_HA");
	case R_PPC64_TPREL16_DS: UNHANDL("R_PPC64_TPREL16_DS");
	case R_PPC64_TPREL16_LO_DS: UNHANDL("R_PPC64_TPREL16_LO_DS");
	case R_PPC64_TPREL16_HIGHER: UNHANDL("R_PPC64_TPREL16_HIGHER");
	case R_PPC64_TPREL16_HIGHERA: UNHANDL("R_PPC64_TPREL16_HIGHERA");
	case R_PPC64_TPREL16_HIGHEST: UNHANDL("R_PPC64_TPREL16_HIGHEST");
	case R_PPC64_TPREL16_HIGHESTA: UNHANDL("R_PPC64_TPREL16_HIGHESTA");
	case R_PPC64_DTPREL16_DS: UNHANDL("R_PPC64_DTPREL16_DS");
	case R_PPC64_DTPREL16_LO_DS: UNHANDL("R_PPC64_DTPREL16_LO_DS");
	case R_PPC64_DTPREL16_HIGHER: UNHANDL("R_PPC64_DTPREL16_HIGHER");
	case R_PPC64_DTPREL16_HIGHERA: UNHANDL("R_PPC64_DTPREL16_HIGHERA");
	case R_PPC64_DTPREL16_HIGHEST: UNHANDL("R_PPC64_DTPREL16_HIGHEST");
	case R_PPC64_DTPREL16_HIGHESTA: UNHANDL("R_PPC64_DTPREL16_HIGHESTA");
	case R_PPC64_TLSGD: UNHANDL("R_PPC64_TLSGD");
	case R_PPC64_TLSLD: UNHANDL("R_PPC64_TLSLD");
	case R_PPC64_TOCSAVE: UNHANDL("R_PPC64_TOCSAVE");
	case R_PPC64_ADDR16_HIGH: UNHANDL("R_PPC64_ADDR16_HIGH");
	case R_PPC64_ADDR16_HIGHA: UNHANDL("R_PPC64_ADDR16_HIGHA");
	case R_PPC64_TPREL16_HIGH: UNHANDL("R_PPC64_TPREL16_HIGH");
	case R_PPC64_TPREL16_HIGHA: UNHANDL("R_PPC64_TPREL16_HIGHA");
	case R_PPC64_DTPREL16_HIGH: UNHANDL("R_PPC64_DTPREL16_HIGH");
	case R_PPC64_DTPREL16_HIGHA: UNHANDL("R_PPC64_DTPREL16_HIGHA");
	case R_PPC64_JMP_IREL: UNHANDL("R_PPC64_JMP_IREL");
	case R_PPC64_IRELATIVE: ADD(64, 0, "R_PPC64_IRELATIVE", RZ_RELOC_BASE_UNKNOWN);
	case R_PPC64_REL16: UNHANDL("R_PPC64_REL16");
	case R_PPC64_REL16_LO: UNHANDL("R_PPC64_REL16_LO");
	case R_PPC64_REL16_HI: UNHANDL("R_PPC64_REL16_HI");
	case R_PPC64_REL16_HA: UNHANDL("R_PPC64_REL16_HA");
	default: UNSUPP("PPC64");
	}
}

// MIPS64 has subtypes for relocs but we do not support it.
#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
#define ELF64_MIPS_R_TYPE(i)  ((i) & 0xff)

static RzBinReloc *reloc_convert_mips(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	ut32 rel_type = rel->type;
	if (bin->ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
		rel_type = ELF64_MIPS_R_TYPE(rel_type);
	}

	switch (rel_type) {
	case R_MIPS_NONE:
		return reloc_convert_set(bin, rel, 0, "R_MIPS_NONE");
	case R_MIPS_16: ADD(16, 0, "R_MIPS_16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_32: ADD(32, 0, "R_MIPS_32", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_REL32: ADD(32, -P, "R_MIPS_REL32", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_26: ADD(32, -P, "R_MIPS_26", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_HI16: ADD(32, 0, "R_MIPS_HI16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_LO16: ADD(32, 0, "R_MIPS_LO16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_GPREL16: UNHANDL("R_MIPS_GPREL16");
	case R_MIPS_LITERAL: UNHANDL("R_MIPS_LITERAL");
	case R_MIPS_GOT16: ADD(16, -GOT, "R_MIPS_GOT16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_PC16: ADD(16, -P, "R_MIPS_PC16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_CALL16: ADD(16, 0, "R_MIPS_CALL16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_GPREL32: UNHANDL("R_MIPS_GPREL32");
	case R_MIPS_SHIFT5: UNHANDL("R_MIPS_SHIFT5");
	case R_MIPS_SHIFT6: UNHANDL("R_MIPS_SHIFT6");
	case R_MIPS_64: ADD(64, 0, "R_MIPS_64", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_GOT_DISP: UNHANDL("R_MIPS_GOT_DISP");
	case R_MIPS_GOT_PAGE: UNHANDL("R_MIPS_GOT_PAGE");
	case R_MIPS_GOT_OFST: UNHANDL("R_MIPS_GOT_OFST");
	case R_MIPS_GOT_HI16: ADD(32, -GOT, "R_MIPS_GOT_HI16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_GOT_LO16: ADD(32, -GOT, "R_MIPS_GOT_LO16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_SUB: UNHANDL("R_MIPS_SUB");
	case R_MIPS_INSERT_A: UNHANDL("R_MIPS_INSERT_A");
	case R_MIPS_INSERT_B: UNHANDL("R_MIPS_INSERT_B");
	case R_MIPS_DELETE: UNHANDL("R_MIPS_DELETE");
	case R_MIPS_HIGHER: UNHANDL("R_MIPS_HIGHER");
	case R_MIPS_HIGHEST: UNHANDL("R_MIPS_HIGHEST");
	case R_MIPS_CALL_HI16: ADD(32, 0, "R_MIPS_CALL_HI16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_CALL_LO16: ADD(32, 0, "R_MIPS_CALL_LO16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_SCN_DISP: UNHANDL("R_MIPS_SCN_DISP");
	case R_MIPS_REL16: ADD(16, -P, "R_MIPS_REL16", RZ_RELOC_BASE_SYMBOL);
	case R_MIPS_ADD_IMMEDIATE: UNHANDL("R_MIPS_ADD_IMMEDIATE");
	case R_MIPS_PJUMP: UNHANDL("R_MIPS_PJUMP");
	case R_MIPS_RELGOT: UNHANDL("R_MIPS_RELGOT");
	case R_MIPS_JALR: UNHANDL("R_MIPS_JALR");
	case R_MIPS_TLS_DTPMOD32: UNHANDL("R_MIPS_TLS_DTPMOD32");
	case R_MIPS_TLS_DTPREL32: UNHANDL("R_MIPS_TLS_DTPREL32");
	case R_MIPS_TLS_DTPMOD64: UNHANDL("R_MIPS_TLS_DTPMOD64");
	case R_MIPS_TLS_DTPREL64: UNHANDL("R_MIPS_TLS_DTPREL64");
	case R_MIPS_TLS_GD: UNHANDL("R_MIPS_TLS_GD");
	case R_MIPS_TLS_LDM: UNHANDL("R_MIPS_TLS_LDM");
	case R_MIPS_TLS_DTPREL_HI16: UNHANDL("R_MIPS_TLS_DTPREL_HI16");
	case R_MIPS_TLS_DTPREL_LO16: UNHANDL("R_MIPS_TLS_DTPREL_LO16");
	case R_MIPS_TLS_GOTTPREL: UNHANDL("R_MIPS_TLS_GOTTPREL");
	case R_MIPS_TLS_TPREL32: UNHANDL("R_MIPS_TLS_TPREL32");
	case R_MIPS_TLS_TPREL64: UNHANDL("R_MIPS_TLS_TPREL64");
	case R_MIPS_TLS_TPREL_HI16: UNHANDL("R_MIPS_TLS_TPREL_HI16");
	case R_MIPS_TLS_TPREL_LO16: UNHANDL("R_MIPS_TLS_TPREL_LO16");
	case R_MIPS_GLOB_DAT: UNHANDL("R_MIPS_GLOB_DAT");
	case R_MIPS_COPY: ADD(32, 0, "R_MIPS_COPY", RZ_RELOC_BASE_UNKNOWN);
	case R_MIPS_JUMP_SLOT: ADD(32, 0, "R_MIPS_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_MICROMIPS_26_S1: UNHANDL("R_MICROMIPS_26_S1");
	case R_MICROMIPS_HI16: UNHANDL("R_MICROMIPS_HI16");
	case R_MICROMIPS_LO16: UNHANDL("R_MICROMIPS_LO16");
	case R_MICROMIPS_GPREL16: UNHANDL("R_MICROMIPS_GPREL16");
	case R_MICROMIPS_LITERAL: UNHANDL("R_MICROMIPS_LITERAL");
	case R_MICROMIPS_GOT16: UNHANDL("R_MICROMIPS_GOT16");
	case R_MICROMIPS_PC7_S1: UNHANDL("R_MICROMIPS_PC7_S1");
	case R_MICROMIPS_PC10_S1: UNHANDL("R_MICROMIPS_PC10_S1");
	case R_MICROMIPS_PC16_S1: UNHANDL("R_MICROMIPS_PC16_S1");
	case R_MICROMIPS_CALL16: UNHANDL("R_MICROMIPS_CALL16");
	case R_MICROMIPS_GOT_DISP: UNHANDL("R_MICROMIPS_GOT_DISP");
	case R_MICROMIPS_GOT_PAGE: UNHANDL("R_MICROMIPS_GOT_PAGE");
	case R_MICROMIPS_GOT_OFST: UNHANDL("R_MICROMIPS_GOT_OFST");
	case R_MICROMIPS_GOT_HI16: UNHANDL("R_MICROMIPS_GOT_HI16");
	case R_MICROMIPS_GOT_LO16: UNHANDL("R_MICROMIPS_GOT_LO16");
	case R_MICROMIPS_SUB: UNHANDL("R_MICROMIPS_SUB");
	case R_MICROMIPS_HIGHER: UNHANDL("R_MICROMIPS_HIGHER");
	case R_MICROMIPS_HIGHEST: UNHANDL("R_MICROMIPS_HIGHEST");
	case R_MICROMIPS_CALL_HI16: UNHANDL("R_MICROMIPS_CALL_HI16");
	case R_MICROMIPS_CALL_LO16: UNHANDL("R_MICROMIPS_CALL_LO16");
	case R_MICROMIPS_SCN_DISP: UNHANDL("R_MICROMIPS_SCN_DISP");
	case R_MICROMIPS_JALR: UNHANDL("R_MICROMIPS_JALR");
	case R_MICROMIPS_HI0_LO16: UNHANDL("R_MICROMIPS_HI0_LO16");
	case R_MICROMIPS_TLS_GD: UNHANDL("R_MICROMIPS_TLS_GD");
	case R_MICROMIPS_TLS_LDM: UNHANDL("R_MICROMIPS_TLS_LDM");
	case R_MICROMIPS_TLS_DTPREL_HI16: UNHANDL("R_MICROMIPS_TLS_DTPREL_HI16");
	case R_MICROMIPS_TLS_DTPREL_LO16: UNHANDL("R_MICROMIPS_TLS_DTPREL_LO16");
	case R_MICROMIPS_TLS_GOTTPREL: UNHANDL("R_MICROMIPS_TLS_GOTTPREL");
	case R_MICROMIPS_TLS_TPREL_HI16: UNHANDL("R_MICROMIPS_TLS_TPREL_HI16");
	case R_MICROMIPS_TLS_TPREL_LO16: UNHANDL("R_MICROMIPS_TLS_TPREL_LO16");
	case R_MICROMIPS_GPREL7_S2: UNHANDL("R_MICROMIPS_GPREL7_S2");
	case R_MICROMIPS_PC23_S2: UNHANDL("R_MICROMIPS_PC23_S2");
	case R_MIPS_PC32: UNHANDL("R_MIPS_PC32");
	case R_MIPS_EH: UNHANDL("R_MIPS_EH");
	case R_MIPS_GNU_REL16_S2: UNHANDL("R_MIPS_GNU_REL16_S2");
	case R_MIPS_GNU_VTINHERIT: UNHANDL("R_MIPS_GNU_VTINHERIT");
	case R_MIPS_GNU_VTENTRY: UNHANDL("R_MIPS_GNU_VTENTRY");
	default: UNSUPP_RELOC("MIPS", rel_type);
	}
}

static RzBinReloc *reloc_convert_nanomips(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	switch (rel->type) {
	case R_NANOMIPS_NONE:
		return reloc_convert_set(bin, rel, 0, "R_NANOMIPS_NONE");
	case R_NANOMIPS_32: ADD(32, 0, "R_NANOMIPS_32", RZ_RELOC_BASE_SYMBOL);
	case R_NANOMIPS_64: ADD(64, 0, "R_NANOMIPS_64", RZ_RELOC_BASE_SYMBOL);
	case R_NANOMIPS_NEG: UNHANDL("R_NANOMIPS_NEG");
	case R_NANOMIPS_ASHIFTR_1: UNHANDL("R_NANOMIPS_ASHIFTR_1");
	case R_NANOMIPS_UNSIGNED_8: UNHANDL("R_NANOMIPS_UNSIGNED_8");
	case R_NANOMIPS_SIGNED_8: UNHANDL("R_NANOMIPS_SIGNED_8");
	case R_NANOMIPS_UNSIGNED_16: UNHANDL("R_NANOMIPS_UNSIGNED_16");
	case R_NANOMIPS_SIGNED_16: UNHANDL("R_NANOMIPS_SIGNED_16");
	case R_NANOMIPS_RELATIVE: UNHANDL("R_NANOMIPS_RELATIVE");
	case R_NANOMIPS_GLOBAL: UNHANDL("R_NANOMIPS_GLOBAL");
	case R_NANOMIPS_JUMP_SLOT: ADD(64, 0, "R_NANOMIPS_JUMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_NANOMIPS_IRELATIVE: UNHANDL("R_NANOMIPS_IRELATIVE");
	case R_NANOMIPS_PC25_S1: UNHANDL("R_NANOMIPS_PC25_S1");
	case R_NANOMIPS_PC21_S1: UNHANDL("R_NANOMIPS_PC21_S1");
	case R_NANOMIPS_PC14_S1: UNHANDL("R_NANOMIPS_PC14_S1");
	case R_NANOMIPS_PC11_S1: UNHANDL("R_NANOMIPS_PC11_S1");
	case R_NANOMIPS_PC10_S1: UNHANDL("R_NANOMIPS_PC10_S1");
	case R_NANOMIPS_PC7_S1: UNHANDL("R_NANOMIPS_PC7_S1");
	case R_NANOMIPS_PC4_S1: UNHANDL("R_NANOMIPS_PC4_S1");
	case R_NANOMIPS_GPREL19_S2: UNHANDL("R_NANOMIPS_GPREL19_S2");
	case R_NANOMIPS_GPREL18_S3: UNHANDL("R_NANOMIPS_GPREL18_S3");
	case R_NANOMIPS_GPREL18: UNHANDL("R_NANOMIPS_GPREL18");
	case R_NANOMIPS_GPREL17_S1: UNHANDL("R_NANOMIPS_GPREL17_S1");
	case R_NANOMIPS_GPREL16_S2: UNHANDL("R_NANOMIPS_GPREL16_S2");
	case R_NANOMIPS_GPREL7_S2: UNHANDL("R_NANOMIPS_GPREL7_S2");
	case R_NANOMIPS_GPREL_HI20: UNHANDL("R_NANOMIPS_GPREL_HI20");
	case R_NANOMIPS_PC_HI20: UNHANDL("R_NANOMIPS_PC_HI20");
	case R_NANOMIPS_HI20: UNHANDL("R_NANOMIPS_HI20");
	case R_NANOMIPS_LO12: UNHANDL("R_NANOMIPS_LO12");
	case R_NANOMIPS_GPREL_I32: UNHANDL("R_NANOMIPS_GPREL_I32");
	case R_NANOMIPS_PC_I32: UNHANDL("R_NANOMIPS_PC_I32");
	case R_NANOMIPS_I32: UNHANDL("R_NANOMIPS_I32");
	case R_NANOMIPS_GOT_DISP: UNHANDL("R_NANOMIPS_GOT_DISP");
	case R_NANOMIPS_GOTPC_I32: UNHANDL("R_NANOMIPS_GOTPC_I32");
	case R_NANOMIPS_GOTPC_HI20: UNHANDL("R_NANOMIPS_GOTPC_HI20");
	case R_NANOMIPS_GOT_LO12: UNHANDL("R_NANOMIPS_GOT_LO12");
	case R_NANOMIPS_GOT_CALL: UNHANDL("R_NANOMIPS_GOT_CALL");
	case R_NANOMIPS_GOT_PAGE: UNHANDL("R_NANOMIPS_GOT_PAGE");
	case R_NANOMIPS_GOT_OFST: UNHANDL("R_NANOMIPS_GOT_OFST");
	case R_NANOMIPS_LO4_S2: UNHANDL("R_NANOMIPS_LO4_S2");
	case R_NANOMIPS_HI32: UNHANDL("R_NANOMIPS_HI32");
	case R_NANOMIPS_GPREL_LO12: UNHANDL("R_NANOMIPS_GPREL_LO12");
	case R_NANOMIPS_COPY: ADD(64, 0, "R_NANOMIPS_COPY", RZ_RELOC_BASE_UNKNOWN);
	case R_NANOMIPS_ALIGN: UNHANDL("R_NANOMIPS_ALIGN");
	case R_NANOMIPS_FILL: UNHANDL("R_NANOMIPS_FILL");
	case R_NANOMIPS_MAX: UNHANDL("R_NANOMIPS_MAX");
	case R_NANOMIPS_INSN32: UNHANDL("R_NANOMIPS_INSN32");
	case R_NANOMIPS_FIXED: UNHANDL("R_NANOMIPS_FIXED");
	case R_NANOMIPS_NORELAX: UNHANDL("R_NANOMIPS_NORELAX");
	case R_NANOMIPS_RELAX: UNHANDL("R_NANOMIPS_RELAX");
	case R_NANOMIPS_SAVERESTORE: UNHANDL("R_NANOMIPS_SAVERESTORE");
	case R_NANOMIPS_INSN16: UNHANDL("R_NANOMIPS_INSN16");
	case R_NANOMIPS_JALR32: UNHANDL("R_NANOMIPS_JALR32");
	case R_NANOMIPS_JALR16: UNHANDL("R_NANOMIPS_JALR16");
	case R_NANOMIPS_JUMPTABLE_LOAD: UNHANDL("R_NANOMIPS_JUMPTABLE_LOAD");
	case R_NANOMIPS_TLS_DTPMOD: UNHANDL("R_NANOMIPS_TLS_DTPMOD");
	case R_NANOMIPS_TLS_DTPREL: UNHANDL("R_NANOMIPS_TLS_DTPREL");
	case R_NANOMIPS_TLS_TPREL: UNHANDL("R_NANOMIPS_TLS_TPREL");
	case R_NANOMIPS_TLS_GD: UNHANDL("R_NANOMIPS_TLS_GD");
	case R_NANOMIPS_TLS_GD_I32: UNHANDL("R_NANOMIPS_TLS_GD_I32");
	case R_NANOMIPS_TLS_LD: UNHANDL("R_NANOMIPS_TLS_LD");
	case R_NANOMIPS_TLS_LD_I32: UNHANDL("R_NANOMIPS_TLS_LD_I32");
	case R_NANOMIPS_TLS_DTPREL12: UNHANDL("R_NANOMIPS_TLS_DTPREL12");
	case R_NANOMIPS_TLS_DTPREL16: UNHANDL("R_NANOMIPS_TLS_DTPREL16");
	case R_NANOMIPS_TLS_DTPREL_I32: UNHANDL("R_NANOMIPS_TLS_DTPREL_I32");
	case R_NANOMIPS_TLS_GOTTPREL: UNHANDL("R_NANOMIPS_TLS_GOTTPREL");
	case R_NANOMIPS_TLS_GOTTPREL_PC32: UNHANDL("R_NANOMIPS_TLS_GOTTPREL_PC32");
	case R_NANOMIPS_TLS_TPREL12: UNHANDL("R_NANOMIPS_TLS_TPREL12");
	case R_NANOMIPS_TLS_TPREL16: UNHANDL("R_NANOMIPS_TLS_TPREL16");
	case R_NANOMIPS_TLS_TPREL_I32: UNHANDL("R_NANOMIPS_TLS_TPREL_I32");
	default: UNSUPP("nanoMIPS");
	}
}

static RzBinReloc *reloc_convert_rx(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_RX_NONE:
		return reloc_convert_set(bin, rel, 0, "R_RX_NONE");
	case R_RX_DIR24S_PCREL: ADD(24, -P, "RX_DIR24S_PCREL", RZ_RELOC_BASE_UNKNOWN);
	case R_RX_DIR32: SET(32, "RX_DIR32");

	// FIXME: Quite a few relocations missing here.
	default: UNSUPP("RX");
	}
}

static RzBinReloc *reloc_convert_alpha(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_ALPHA_NONE:
		return reloc_convert_set(bin, rel, 0, "R_ALPHA_NONE");
	case R_ALPHA_REFLONG: SET(32, "R_ALPHA_REFLONG");
	case R_ALPHA_REFQUAD: SET(64, "R_ALPHA_REFQUAD");
	case R_ALPHA_SREL16: ADD(16, -P, "R_ALPHA_SREL16", RZ_RELOC_BASE_SYMBOL);
	case R_ALPHA_SREL32: ADD(32, -P, "R_ALPHA_SREL32", RZ_RELOC_BASE_SYMBOL);
	case R_ALPHA_SREL64: ADD(64, -P, "R_ALPHA_SREL64", RZ_RELOC_BASE_SYMBOL);
	case R_ALPHA_COPY: ADD(32, 0, "R_ALPHA_COPY", RZ_RELOC_BASE_UNKNOWN); // copy symbol at runtime
	case R_ALPHA_GLOB_DAT: ADD(32, 0, "R_ALPHA_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_ALPHA_JMP_SLOT: ADD(32, 0, "R_ALPHA_JMP_SLOT", RZ_RELOC_BASE_SYMBOL);

	// FIXME: Quite a few relocations missing here.
	default: UNSUPP("ALPHA");
	}
}

static RzBinReloc *reloc_convert_parisc(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_PARISC_NONE:
		return reloc_convert_set(bin, rel, 0, "R_PARISC_NONE");
	case R_PARISC_DIR32: ADD(32, 0, "R_PARISC_DIR32", RZ_RELOC_BASE_UNKNOWN);
	case R_PARISC_DIR64: ADD(64, 0, "R_PARISC_DIR64", RZ_RELOC_BASE_UNKNOWN);
	case R_PARISC_COPY: ADD(64, 0, "R_PARISC_COPY", RZ_RELOC_BASE_UNKNOWN); // copy symbol at runtime
	case R_PARISC_IPLT: ADD(64, -P, "R_PARISC_IPLT", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_PARISC_EPLT: ADD(64, -P, "R_PARISC_EPLT", RZ_RELOC_BASE_PLT_SYMBOL);

	// FIXME: Quite a few relocatons missing here.
	default: UNSUPP("PARISC");
	}
}
static RzBinReloc *reloc_convert_hexagon(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	case R_HEX_NONE:
		return reloc_convert_set(bin, rel, 0, "R_HEX_NONE");
	case R_HEX_B22_PCREL: ADD(32, -P, "R_HEX_B22_PCREL", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B15_PCREL: ADD(32, -P, "R_HEX_B15_PCREL", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B7_PCREL: ADD(32, -P, "R_HEX_B7_PCREL", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_LO16: ADD(32, 0, "R_HEX_LO16", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_HI16: ADD(32, 0, "R_HEX_HI16", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_32: ADD(32, 0, "R_HEX_32", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_16: ADD(16, 0, "R_HEX_16", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_8: ADD(8, 0, "R_HEX_8", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_HL16: ADD(64, 0, "R_HEX_HL16", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B13_PCREL: ADD(32, -P, "R_HEX_B13_PCREL", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B9_PCREL: ADD(32, -P, "R_HEX_B9_PCREL", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B32_PCREL_X: ADD(32, -P, "R_HEX_B32_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_32_6_X: ADD(32, 0, "R_HEX_32_6_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B22_PCREL_X: ADD(32, -P, "R_HEX_B22_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B15_PCREL_X: ADD(32, -P, "R_HEX_B15_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B13_PCREL_X: ADD(32, -P, "R_HEX_B13_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B9_PCREL_X: ADD(32, -P, "R_HEX_B9_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_B7_PCREL_X: ADD(32, -P, "R_HEX_B7_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_16_X: ADD(32, 0, "R_HEX_16_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_12_X: ADD(32, 0, "R_HEX_12_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_11_X: ADD(32, 0, "R_HEX_11_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_10_X: ADD(32, 0, "R_HEX_10_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_9_X: ADD(32, 0, "R_HEX_9_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_8_X: ADD(32, 0, "R_HEX_8_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_7_X: ADD(32, 0, "R_HEX_7_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_6_X: ADD(32, 0, "R_HEX_6_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_32_PCREL: ADD(32, -P, "R_HEX_32_PCREL", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GLOB_DAT: ADD(32, 0, "R_HEX_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_JMP_SLOT: ADD(32, 0, "R_HEX_JMP_SLOT", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GOTREL_LO16: ADD(32, -GOT, "R_HEX_GOTREL_LO16", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GOTREL_HI16: ADD(32, -GOT, "R_HEX_GOTREL_HI16", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GOTREL_32: ADD(32, -GOT, "R_HEX_GOTREL_32", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_6_PCREL_X: ADD(32, -P, "R_HEX_6_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GOTREL_32_6_X: ADD(32, -GOT, "R_HEX_GOTREL_32_6_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GOTREL_16_X: ADD(32, -GOT, "R_HEX_GOTREL_16_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GOTREL_11_X: ADD(32, -GOT, "R_HEX_GOTREL_11_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GD_PLT_B22_PCREL_X: ADD(32, -P, "R_HEX_GD_PLT_B22_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_GD_PLT_B32_PCREL_X: ADD(32, -P, "R_HEX_GD_PLT_B32_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_LD_PLT_B22_PCREL_X: ADD(32, -P, "R_HEX_LD_PLT_B22_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_LD_PLT_B32_PCREL_X: ADD(32, -P, "R_HEX_LD_PLT_B32_PCREL_X", RZ_RELOC_BASE_SYMBOL);
	case R_HEX_COPY: SET(32, "R_HEX_COPY");
	case R_HEX_RELATIVE: UNHANDL("R_HEX_RELATIVE"); // Preview not supported, patching is implemented
	case R_HEX_PLT_B22_PCREL: UNHANDL("R_HEX_PLT_B22_PCREL"); // Preview not supported, patching is implemented
	case R_HEX_GOT_LO16: UNHANDL("R_HEX_GOT_LO16");
	case R_HEX_GOT_HI16: UNHANDL("R_HEX_GOT_HI16");
	case R_HEX_GOT_32: UNHANDL("R_HEX_GOT_32");
	case R_HEX_GOT_16: UNHANDL("R_HEX_GOT_16");
	case R_HEX_DTPMOD_32: UNHANDL("R_HEX_DTPMOD_32");
	case R_HEX_GD_PLT_B22_PCREL: UNHANDL("R_HEX_GD_PLT_B22_PCREL"); // Preview not supported, patching is implemented
	case R_HEX_GD_GOT_LO16: UNHANDL("R_HEX_GD_GOT_LO16");
	case R_HEX_GD_GOT_HI16: UNHANDL("R_HEX_GD_GOT_HI16");
	case R_HEX_GD_GOT_32: UNHANDL("R_HEX_GD_GOT_32");
	case R_HEX_GD_GOT_16: UNHANDL("R_HEX_GD_GOT_16");
	case R_HEX_IE_LO16: UNHANDL("R_HEX_IE_LO16");
	case R_HEX_IE_HI16: UNHANDL("R_HEX_IE_HI16");
	case R_HEX_IE_32: UNHANDL("R_HEX_IE_32");
	case R_HEX_IE_GOT_LO16: UNHANDL("R_HEX_IE_GOT_LO16");
	case R_HEX_IE_GOT_HI16: UNHANDL("R_HEX_IE_GOT_HI16");
	case R_HEX_IE_GOT_32: UNHANDL("R_HEX_IE_GOT_32");
	case R_HEX_IE_GOT_16: UNHANDL("R_HEX_IE_GOT_16");
	case R_HEX_TPREL_LO16: UNHANDL("R_HEX_TPREL_LO16");
	case R_HEX_TPREL_HI16: UNHANDL("R_HEX_TPREL_HI16");
	case R_HEX_TPREL_32: UNHANDL("R_HEX_TPREL_32");
	case R_HEX_TPREL_16: UNHANDL("R_HEX_TPREL_16");
	case R_HEX_GOT_32_6_X: UNHANDL("R_HEX_GOT_32_6_X");
	case R_HEX_GOT_16_X: UNHANDL("R_HEX_GOT_16_X");
	case R_HEX_GOT_11_X: UNHANDL("R_HEX_GOT_11_X");
	case R_HEX_GD_GOT_32_6_X: UNHANDL("R_HEX_GD_GOT_32_6_X");
	case R_HEX_GD_GOT_16_X: UNHANDL("R_HEX_GD_GOT_16_X");
	case R_HEX_GD_GOT_11_X: UNHANDL("R_HEX_GD_GOT_11_X");
	case R_HEX_IE_32_6_X: UNHANDL("R_HEX_IE_32_6_X");
	case R_HEX_IE_16_X: UNHANDL("R_HEX_IE_16_X");
	case R_HEX_IE_GOT_32_6_X: UNHANDL("R_HEX_IE_GOT_32_6_X");
	case R_HEX_IE_GOT_16_X: UNHANDL("R_HEX_IE_GOT_16_X");
	case R_HEX_IE_GOT_11_X: UNHANDL("R_HEX_IE_GOT_11_X");
	case R_HEX_TPREL_32_6_X: UNHANDL("R_HEX_TPREL_32_6_X");
	case R_HEX_TPREL_16_X: UNHANDL("R_HEX_TPREL_16_X");
	case R_HEX_TPREL_11_X: UNHANDL("R_HEX_TPREL_11_X");
	case R_HEX_LD_PLT_B22_PCREL: UNHANDL("R_HEX_LD_PLT_B22_PCREL"); // Preview not supported, patching is implemented
	case R_HEX_LD_GOT_LO16: UNHANDL("R_HEX_LD_GOT_LO16");
	case R_HEX_LD_GOT_HI16: UNHANDL("R_HEX_LD_GOT_HI16");
	case R_HEX_LD_GOT_32: UNHANDL("R_HEX_LD_GOT_32");
	case R_HEX_LD_GOT_16: UNHANDL("R_HEX_LD_GOT_16");
	case R_HEX_LD_GOT_32_6_X: UNHANDL("R_HEX_LD_GOT_32_6_X");
	case R_HEX_LD_GOT_16_X: UNHANDL("R_HEX_LD_GOT_16_X");
	case R_HEX_LD_GOT_11_X: UNHANDL("R_HEX_LD_GOT_11_X");
	case R_HEX_27_REG: UNHANDL("R_HEX_27_REG");
	case R_HEX_23_REG: UNHANDL("R_HEX_23_REG");
	case R_HEX_DTPREL_32_6_X: UNHANDL("R_HEX_DTPREL_32_6_X"); // Preview not supported, patching is implemented
	case R_HEX_DTPREL_16_X: UNHANDL("R_HEX_DTPREL_16_X"); // Preview not supported, patching is implemented
	case R_HEX_DTPREL_11_X: UNHANDL("R_HEX_DTPREL_11_X"); // Preview not supported, patching is implemented
	case R_HEX_DTPREL_LO16: UNHANDL("R_HEX_DTPREL_LO16");
	case R_HEX_DTPREL_HI16: UNHANDL("R_HEX_DTPREL_HI16");
	case R_HEX_DTPREL_32: UNHANDL("R_HEX_DTPREL_32");
	case R_HEX_DTPREL_16: UNHANDL("R_HEX_DTPREL_16");
	case R_HEX_GPREL16_0: UNHANDL("R_HEX_GPREL16_0");
	case R_HEX_GPREL16_1: UNHANDL("R_HEX_GPREL16_1");
	case R_HEX_GPREL16_2: UNHANDL("R_HEX_GPREL16_2");
	case R_HEX_GPREL16_3: UNHANDL("R_HEX_GPREL16_3");
	default: UNSUPP("Hexagon");
	}
}

static RzBinReloc *reloc_convert_sparc(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	ut64 P = rel->vaddr;

	switch (rel->type) {
	default: UNSUPP("Sparc");
	case R_SPARC_NONE:
		return reloc_convert_set(bin, rel, 0, "R_SPARC_NONE");

	case R_SPARC_GOTDATA_OP:
		UNHANDL("R_SPARC_GOTDATA_OP");
	case R_SPARC_JMP_SLOT:
		// The patching depends on runtime values.
		// But the relocation just points to an entry in the PLT.
		// Because it would write the symbol address into this PLT entry,
		// converting it to a "set value" relocation seems close enough.
		SET(32, "R_SPARC_JMP_SLOT");
	case R_SPARC_COPY:
		// The patching depends on runtime values (like the library the value is
		// is copied from).
		// The relocation just points to an offset where the copy should be stored.
		// Because it would write the copied data to the offset the relocation gives,
		// converting it to a "set value" relocation seems close enough.
		SET(32, "R_SPARC_COPY");
	case R_SPARC_8:
		ADD(8, 0, "R_SPARC_8", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_16:
		ADD(16, 0, "R_SPARC_16", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_32:
		ADD(32, 0, "R_SPARC_32", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_DISP8:
		ADD(8, -P, "R_SPARC_DISP8", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_DISP16:
		ADD(16, -P, "R_SPARC_DISP16", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_DISP32:
		ADD(32, -P, "R_SPARC_DISP32", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_WDISP30:
		// ((S + A - P) >> 2);
		UNHANDL("R_SPARC_WDISP30");
	case R_SPARC_WDISP22:
		// ((S + A - P) >> 2);
		UNHANDL("R_SPARC_WDISP22");
	case R_SPARC_HI22:
		// ((S + A) >> 10);
		UNHANDL("R_SPARC_HI22");
	case R_SPARC_22:
		ADD(32, 0, "R_SPARC_22", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_13:
		ADD(32, 0, "R_SPARC_13", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_LO10:
		// ((S + A) & 0x3ff);
		UNHANDL("R_SPARC_LO10");
	case R_SPARC_GOT10:
		// (G & 0x3ff);
		UNHANDL("R_SPARC_GOT10");
	case R_SPARC_GOT13:
		// (G);
		UNHANDL("R_SPARC_GOT13");
	case R_SPARC_GOT22:
		// (G >> 10);
		UNHANDL("R_SPARC_GOT22");
	case R_SPARC_PC10:
		// ((S + A - P) & 0x3ff);
		UNHANDL("R_SPARC_PC10");
	case R_SPARC_PC22:
		// ((S + A - P) >> 10);
		UNHANDL("R_SPARC_PC22");
	case R_SPARC_WPLT30:
		// ((L + A - P) >> 2);
		UNHANDL("R_SPARC_WPLT30");
	case R_SPARC_GLOB_DAT:
		ADD(32, 0, "R_SPARC_GLOB_DAT", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_RELATIVE:
		// (B + A);
		UNHANDL("R_SPARC_RELATIVE");
	case R_SPARC_UA32:
		ADD(32, 0, "R_SPARC_UA32", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_PLT32:
		ADD(32, 0, "R_SPARC_PLT32", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_SPARC_HIPLT22:
		// ((L + A) >> 10);
		UNHANDL("R_SPARC_HIPLT22");
	case R_SPARC_LOPLT10:
		// ((L + A) & 0x3ff);
		UNHANDL("R_SPARC_LOPLT10");
	case R_SPARC_PCPLT32:
		ADD(32, -P, "R_SPARC_PCPLT32", RZ_RELOC_BASE_PLT_SYMBOL);
	case R_SPARC_PCPLT22:
		// ((L + A - P) >> 10);
		UNHANDL("R_SPARC_PCPLT22");
	case R_SPARC_PCPLT10:
		// ((L + A - P) & 0x3ff);
		UNHANDL("R_SPARC_PCPLT10");
	case R_SPARC_10:
		ADD(32, 0, "R_SPARC_10", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_11:
		ADD(32, 0, "R_SPARC_11", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_64:
		ADD(64, 0, "R_SPARC_64", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_OLO10:
		// (((S + A) & 0x3ff) + O);
		UNHANDL("R_SPARC_OLO10");
	case R_SPARC_HH22:
		// ((S + A) >> 42);
		UNHANDL("R_SPARC_HH22");
	case R_SPARC_HM10:
		// (((S + A) >> 32) & 0x3ff);
		UNHANDL("R_SPARC_HM10");
	case R_SPARC_LM22:
		// ((S + A) >> 10);
		UNHANDL("R_SPARC_LM22");
	case R_SPARC_PC_HH22:
		// ((S + A - P) >> 42);
		UNHANDL("R_SPARC_PC_HH22");
	case R_SPARC_PC_HM10:
		// (((S + A - P) >> 32) & 0x3ff);
		UNHANDL("R_SPARC_PC_HM10");
	case R_SPARC_PC_LM22:
		// ((S + A - P) >> 10);
		UNHANDL("R_SPARC_PC_LM22");
	case R_SPARC_WDISP16:
		// ((S + A - P) >> 2);
		UNHANDL("R_SPARC_WDISP16");
	case R_SPARC_WDISP19:
		// ((S + A - P) >> 2);
		UNHANDL("R_SPARC_WDISP19");
	case R_SPARC_7:
		ADD(32, 0, "R_SPARC_7", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_5:
		ADD(32, 0, "R_SPARC_5", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_6:
		ADD(32, 0, "R_SPARC_6", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_DISP64:
		ADD(64, -P, "R_SPARC_DISP64", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_PLT64:
		// (L + A);
		UNHANDL("R_SPARC_PLT64");
	case R_SPARC_HIX22:
		// (((S + A) ^ 0xffffffffffffffff) >> 10);
		UNHANDL("R_SPARC_HIX22");
	case R_SPARC_LOX10:
		// (((S + A) & 0x3ff) | 0x1c00);
		UNHANDL("R_SPARC_LOX10");
	case R_SPARC_H44:
		// ((S + A) >> 22);
		UNHANDL("R_SPARC_H44");
	case R_SPARC_M44:
		// (((S + A) >> 12) & 0x3ff);
		UNHANDL("R_SPARC_M44");
	case R_SPARC_L44:
		// ((S + A) & 0xfff);
		UNHANDL("R_SPARC_L44");
	case R_SPARC_REGISTER:
		ADD(32, 0, "R_SPARC_REGISTER", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_UA64:
		ADD(32, 0, "R_SPARC_UA64", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_UA16:
		ADD(32, 0, "R_SPARC_UA16", RZ_RELOC_BASE_SYMBOL);
	case R_SPARC_H34:
		// ((S + A) >> 12);
		UNHANDL("R_SPARC_H34");
	case R_SPARC_SIZE64:
		// (Z + A);
		UNHANDL("R_SPARC_SIZE64");
	case R_SPARC_GOTDATA_HIX22:
		// (((S + A - GOT) >> 10) ^ ((S + A - GOT) >> 31));
		UNHANDL("R_SPARC_GOTDATA_HIX22");
	case R_SPARC_GOTDATA_LOX10:
		// (((S + A - GOT) & 0x3ff) | (((S + A - GOT) >> 31) & 0x1c00));
		UNHANDL("R_SPARC_GOTDATA_LOX10");
	case R_SPARC_GOTDATA_OP_HIX22:
		// ((G >> 10) ^ (G >> 31));
		UNHANDL("R_SPARC_GOTDATA_OP_HIX22");
	case R_SPARC_GOTDATA_OP_LOX10:
		// ((G & 0x3ff) | ((G >> 31) & 0x1c00));
		UNHANDL("R_SPARC_GOTDATA_OP_LOX10");
	case R_SPARC_SIZE32:
		// (Z + A);
		UNHANDL("R_SPARC_SIZE32");
	case R_SPARC_WDISP10:
		// ((S + A - P) >> 2);
		UNHANDL("R_SPARC_WDISP10");
	}
}

static RzBinReloc *reloc_convert_avr(ELFOBJ *bin, RzBinElfReloc *rel, ut64 GOT) {
	switch (rel->type) {
	case R_AVR_NONE:
		return reloc_convert_set(bin, rel, 0, "R_AVR_NONE");
	case R_AVR_32: SET(32, "R_AVR_32");
	case R_AVR_7_PCREL: SET(16, "R_AVR_7_PCREL");
	case R_AVR_13_PCREL: SET(16, "R_AVR_13_PCREL");
	case R_AVR_16: SET(16, "R_AVR_16");
	case R_AVR_16_PM: SET(16, "R_AVR_16_PM");
	case R_AVR_LO8_LDI: SET(16, "R_AVR_LO8_LDI");
	case R_AVR_HI8_LDI: SET(16, "R_AVR_HI8_LDI");
	case R_AVR_HH8_LDI: SET(16, "R_AVR_HH8_LDI");
	case R_AVR_LO8_LDI_NEG: SET(16, "R_AVR_LO8_LDI_NEG");
	case R_AVR_HI8_LDI_NEG: SET(16, "R_AVR_HI8_LDI_NEG");
	case R_AVR_HH8_LDI_NEG: SET(16, "R_AVR_HH8_LDI_NEG");
	case R_AVR_LO8_LDI_PM: SET(16, "R_AVR_LO8_LDI_PM");
	case R_AVR_HI8_LDI_PM: SET(16, "R_AVR_HI8_LDI_PM");
	case R_AVR_HH8_LDI_PM: SET(16, "R_AVR_HH8_LDI_PM");
	case R_AVR_LO8_LDI_PM_NEG: SET(16, "R_AVR_LO8_LDI_PM_NEG");
	case R_AVR_HI8_LDI_PM_NEG: SET(16, "R_AVR_HI8_LDI_PM_NEG");
	case R_AVR_HH8_LDI_PM_NEG: SET(16, "R_AVR_HH8_LDI_PM_NEG");
	case R_AVR_CALL: SET(32, "R_AVR_CALL");
	case R_AVR_LDI:
		return reloc_convert_set(bin, rel, 0, "R_AVR_LDI");
	case R_AVR_6: SET(16, "R_AVR_6");
	case R_AVR_6_ADIW: SET(16, "R_AVR_6_ADIW");
	case R_AVR_MS8_LDI: SET(16, "R_AVR_MS8_LDI");
	case R_AVR_MS8_LDI_NEG: SET(16, "R_AVR_MS8_LDI_NEG");
	case R_AVR_LO8_LDI_GS: SET(16, "R_AVR_LO8_LDI_GS");
	case R_AVR_HI8_LDI_GS: SET(16, "R_AVR_HI8_LDI_GS");
	case R_AVR_8: SET(8, "R_AVR_8");
	case R_AVR_8_LO8: SET(8, "R_AVR_8_LO8");
	case R_AVR_8_HI8: SET(8, "R_AVR_8_HI8");
	case R_AVR_8_HLO8: SET(8, "R_AVR_8_HLO8");
	case R_AVR_DIFF8: SET(8, "R_AVR_DIFF8");
	case R_AVR_DIFF16: SET(16, "R_AVR_DIFF16");
	case R_AVR_DIFF32: SET(32, "R_AVR_DIFF32");
	case R_AVR_LDS_STS_16: SET(16, "R_AVR_LDS_STS_16");
	case R_AVR_PORT6: SET(16, "R_AVR_PORT6");
	case R_AVR_PORT5: SET(16, "R_AVR_PORT5");
	case R_AVR_32_PCREL: SET(32, "R_AVR_32_PCREL");
	default: UNSUPP("AVR");
	}
}

#undef UNSUPP
#undef UNHANDL
#undef SET
#undef SET
#undef ADD
#undef VADDR
#undef IFCN

#define ARCH_MISSING(NAME) \
	RZ_LOG_WARN("Relocation conversion for " NAME " is not implemented.\n"); \
	return NULL

RZ_OWN RzBinReloc *Elf_(rz_bin_elf_convert_relocation)(RZ_NONNULL ELFOBJ *bin, RZ_NONNULL RzBinElfReloc *rel, ut64 GOT) {
	rz_return_val_if_fail(bin && rel, NULL);
	ut16 e_machine = bin->ehdr.e_machine;

	switch (e_machine) {
	case EM_386:
		return reloc_convert_intel_80386(bin, rel, GOT);
	case EM_X86_64:
		return reloc_convert_amd64(bin, rel, GOT);
	case EM_ARM:
		return reloc_convert_arm(bin, rel, GOT);
	case EM_RISCV:
		return reloc_convert_riscv(bin, rel, GOT);
	case EM_AARCH64:
		return reloc_convert_aarch64(bin, rel, GOT);
	case EM_PPC:
		return reloc_convert_ppc(bin, rel, GOT);
	case EM_PPC64:
		return reloc_convert_ppc64(bin, rel, GOT);
	case EM_RX:
		return reloc_convert_rx(bin, rel, GOT);
	case EM_ALPHA:
		return reloc_convert_alpha(bin, rel, GOT);
	case EM_QDSP6:
		return reloc_convert_hexagon(bin, rel, GOT);
	case EM_SPARC:
	case EM_SPARC32PLUS:
	case EM_SPARCV9:
		return reloc_convert_sparc(bin, rel, GOT);
	case EM_MIPS_X:
		/* fall-thru */
	case EM_MIPS_RS3_LE:
		/* fall-thru */
	case EM_MIPS:
		return reloc_convert_mips(bin, rel, GOT);
	case EM_IMG1: // nanomips
		return reloc_convert_nanomips(bin, rel, GOT);
	case EM_AVR:
		return reloc_convert_avr(bin, rel, GOT);
	case EM_M32: ARCH_MISSING("EM_M32");
	case EM_68K: ARCH_MISSING("EM_68K");
	case EM_88K: ARCH_MISSING("EM_88K");
	case EM_IAMCU: ARCH_MISSING("EM_IAMCU");
	case EM_860: ARCH_MISSING("EM_860");
	case EM_S370: ARCH_MISSING("EM_S370");
	case EM_PARISC:
		return reloc_convert_parisc(bin, rel, GOT);
	case EM_VPP500: ARCH_MISSING("EM_VPP500");
	case EM_960: ARCH_MISSING("EM_960");
	case EM_S390: ARCH_MISSING("EM_S390");
	case EM_SPU: ARCH_MISSING("EM_SPU");
	case EM_V800: ARCH_MISSING("EM_V800");
	case EM_FR20: ARCH_MISSING("EM_FR20");
	case EM_RH32: ARCH_MISSING("EM_RH32");
	case EM_RCE: ARCH_MISSING("EM_RCE");
	case EM_FAKE_ALPHA: ARCH_MISSING("EM_FAKE_ALPHA");
	case EM_SH: ARCH_MISSING("EM_SH");
	case EM_TRICORE: ARCH_MISSING("EM_TRICORE");
	case EM_ARC: ARCH_MISSING("EM_ARC");
	case EM_H8_300: ARCH_MISSING("EM_H8_300");
	case EM_H8_300H: ARCH_MISSING("EM_H8_300H");
	case EM_H8S: ARCH_MISSING("EM_H8S");
	case EM_H8_500: ARCH_MISSING("EM_H8_500");
	case EM_IA_64: ARCH_MISSING("EM_IA_64");
	case EM_COLDFIRE: ARCH_MISSING("EM_COLDFIRE");
	case EM_68HC12: ARCH_MISSING("EM_68HC12");
	case EM_MMA: ARCH_MISSING("EM_MMA");
	case EM_PCP: ARCH_MISSING("EM_PCP");
	case EM_NCPU: ARCH_MISSING("EM_NCPU");
	case EM_NDR1: ARCH_MISSING("EM_NDR1");
	case EM_STARCORE: ARCH_MISSING("EM_STARCORE");
	case EM_ME16: ARCH_MISSING("EM_ME16");
	case EM_ST100: ARCH_MISSING("EM_ST100");
	case EM_TINYJ: ARCH_MISSING("EM_TINYJ");
	case EM_PDSP: ARCH_MISSING("EM_PDSP");
	case EM_PDP10: ARCH_MISSING("EM_PDP10");
	case EM_PDP11: ARCH_MISSING("EM_PDP11");
	case EM_FX66: ARCH_MISSING("EM_FX66");
	case EM_ST9PLUS: ARCH_MISSING("EM_ST9PLUS");
	case EM_ST7: ARCH_MISSING("EM_ST7");
	case EM_68HC16: ARCH_MISSING("EM_68HC16");
	case EM_68HC11: ARCH_MISSING("EM_68HC11");
	case EM_68HC08: ARCH_MISSING("EM_68HC08");
	case EM_68HC05: ARCH_MISSING("EM_68HC05");
	case EM_SVX: ARCH_MISSING("EM_SVX");
	case EM_ST19: ARCH_MISSING("EM_ST19");
	case EM_VAX: ARCH_MISSING("EM_VAX");
	case EM_CRIS: ARCH_MISSING("EM_CRIS");
	case EM_JAVELIN: ARCH_MISSING("EM_JAVELIN");
	case EM_FIREPATH: ARCH_MISSING("EM_FIREPATH");
	case EM_ZSP: ARCH_MISSING("EM_ZSP");
	case EM_MMIX: ARCH_MISSING("EM_MMIX");
	case EM_HUANY: ARCH_MISSING("EM_HUANY");
	case EM_PRISM: ARCH_MISSING("EM_PRISM");
	case EM_FR30: ARCH_MISSING("EM_FR30");
	case EM_D10V: ARCH_MISSING("EM_D10V");
	case EM_D30V: ARCH_MISSING("EM_D30V");
	case EM_V850: ARCH_MISSING("EM_V850");
	case EM_M32R: ARCH_MISSING("EM_M32R");
	case EM_MN10300: ARCH_MISSING("EM_MN10300");
	case EM_MN10200: ARCH_MISSING("EM_MN10200");
	case EM_PJ: ARCH_MISSING("EM_PJ");
	case EM_OR1K: ARCH_MISSING("EM_OR1K");
	case EM_ARC_COMPACT: ARCH_MISSING("EM_ARC_COMPACT");
	case EM_XTENSA: ARCH_MISSING("EM_XTENSA");
	case EM_VIDEOCORE: ARCH_MISSING("EM_VIDEOCORE");
	case EM_TMM_GPP: ARCH_MISSING("EM_TMM_GPP");
	case EM_NS32K: ARCH_MISSING("EM_NS32K");
	case EM_TPC: ARCH_MISSING("EM_TPC");
	case EM_SNP1K: ARCH_MISSING("EM_SNP1K");
	case EM_ST200: ARCH_MISSING("EM_ST200");
	case EM_IP2K: ARCH_MISSING("EM_IP2K");
	case EM_MAX: ARCH_MISSING("EM_MAX");
	case EM_CR: ARCH_MISSING("EM_CR");
	case EM_F2MC16: ARCH_MISSING("EM_F2MC16");
	case EM_MSP430: ARCH_MISSING("EM_MSP430");
	case EM_BLACKFIN: ARCH_MISSING("EM_BLACKFIN");
	case EM_SE_C33: ARCH_MISSING("EM_SE_C33");
	case EM_SEP: ARCH_MISSING("EM_SEP");
	case EM_ARCA: ARCH_MISSING("EM_ARCA");
	case EM_UNICORE: ARCH_MISSING("EM_UNICORE");
	case EM_EXCESS: ARCH_MISSING("EM_EXCESS");
	case EM_DXP: ARCH_MISSING("EM_DXP");
	case EM_ALTERA_NIOS2: ARCH_MISSING("EM_ALTERA_NIOS2");
	case EM_CRX: ARCH_MISSING("EM_CRX");
	case EM_XGATE: ARCH_MISSING("EM_XGATE");
	case EM_C166: ARCH_MISSING("EM_C166");
	case EM_M16C: ARCH_MISSING("EM_M16C");
	case EM_DSPIC30F: ARCH_MISSING("EM_DSPIC30F");
	case EM_CE: ARCH_MISSING("EM_CE");
	case EM_M32C: ARCH_MISSING("EM_M32C");
	case EM_TSK3000: ARCH_MISSING("EM_TSK3000");
	case EM_RS08: ARCH_MISSING("EM_RS08");
	case EM_SHARC: ARCH_MISSING("EM_SHARC");
	case EM_ECOG2: ARCH_MISSING("EM_ECOG2");
	case EM_SCORE7: ARCH_MISSING("EM_SCORE7");
	case EM_DSP24: ARCH_MISSING("EM_DSP24");
	case EM_VIDEOCORE3: ARCH_MISSING("EM_VIDEOCORE3");
	case EM_LATTICEMICO32: ARCH_MISSING("EM_LATTICEMICO32");
	case EM_SE_C17: ARCH_MISSING("EM_SE_C17");
	case EM_TI_C6000: ARCH_MISSING("EM_TI_C6000");
	case EM_TI_C2000: ARCH_MISSING("EM_TI_C2000");
	case EM_TI_C5500: ARCH_MISSING("EM_TI_C5500");
	case EM_TI_ARP32: ARCH_MISSING("EM_TI_ARP32");
	case EM_TI_PRU: ARCH_MISSING("EM_TI_PRU");
	case EM_MMDSP_PLUS: ARCH_MISSING("EM_MMDSP_PLUS");
	case EM_CYPRESS_M8C: ARCH_MISSING("EM_CYPRESS_M8C");
	case EM_R32C: ARCH_MISSING("EM_R32C");
	case EM_TRIMEDIA: ARCH_MISSING("EM_TRIMEDIA");
	case EM_8051: ARCH_MISSING("EM_8051");
	case EM_STXP7X: ARCH_MISSING("EM_STXP7X");
	case EM_NDS32: ARCH_MISSING("EM_NDS32");
	case EM_ECOG1X: ARCH_MISSING("EM_ECOG1X");
	case EM_MAXQ30: ARCH_MISSING("EM_MAXQ30");
	case EM_XIMO16: ARCH_MISSING("EM_XIMO16");
	case EM_MANIK: ARCH_MISSING("EM_MANIK");
	case EM_CRAYNV2: ARCH_MISSING("EM_CRAYNV2");
	case EM_METAG: ARCH_MISSING("EM_METAG");
	case EM_MCST_ELBRUS: ARCH_MISSING("EM_MCST_ELBRUS");
	case EM_ECOG16: ARCH_MISSING("EM_ECOG16");
	case EM_CR16: ARCH_MISSING("EM_CR16");
	case EM_ETPU: ARCH_MISSING("EM_ETPU");
	case EM_SLE9X: ARCH_MISSING("EM_SLE9X");
	case EM_L10M: ARCH_MISSING("EM_L10M");
	case EM_K10M: ARCH_MISSING("EM_K10M");
	case EM_AVR32: ARCH_MISSING("EM_AVR32");
	case EM_STM8: ARCH_MISSING("EM_STM8");
	case EM_TILE64: ARCH_MISSING("EM_TILE64");
	case EM_TILEPRO: ARCH_MISSING("EM_TILEPRO");
	case EM_MICROBLAZE: ARCH_MISSING("EM_MICROBLAZE");
	case EM_CUDA: ARCH_MISSING("EM_CUDA");
	case EM_TILEGX: ARCH_MISSING("EM_TILEGX");
	case EM_CLOUDSHIELD: ARCH_MISSING("EM_CLOUDSHIELD");
	case EM_COREA_1ST: ARCH_MISSING("EM_COREA_1ST");
	case EM_COREA_2ND: ARCH_MISSING("EM_COREA_2ND");
	case EM_ARCV2: ARCH_MISSING("EM_ARCV2");
	case EM_OPEN8: ARCH_MISSING("EM_OPEN8");
	case EM_RL78: ARCH_MISSING("EM_RL78");
	case EM_VIDEOCORE5: ARCH_MISSING("EM_VIDEOCORE5");
	case EM_78KOR: ARCH_MISSING("EM_78KOR");
	case EM_56800EX: ARCH_MISSING("EM_56800EX");
	case EM_BA1: ARCH_MISSING("EM_BA1");
	case EM_BA2: ARCH_MISSING("EM_BA2");
	case EM_XCORE: ARCH_MISSING("EM_XCORE");
	case EM_MCHP_PIC: ARCH_MISSING("EM_MCHP_PIC");
	case EM_KM32: ARCH_MISSING("EM_KM32");
	case EM_KMX32: ARCH_MISSING("EM_KMX32");
	case EM_EMX16: ARCH_MISSING("EM_EMX16");
	case EM_EMX8: ARCH_MISSING("EM_EMX8");
	case EM_KVARC: ARCH_MISSING("EM_KVARC");
	case EM_CDP: ARCH_MISSING("EM_CDP");
	case EM_COGE: ARCH_MISSING("EM_COGE");
	case EM_COOL: ARCH_MISSING("EM_COOL");
	case EM_NORC: ARCH_MISSING("EM_NORC");
	case EM_CSR_KALIMBA: ARCH_MISSING("EM_CSR_KALIMBA");
	case EM_Z80: ARCH_MISSING("EM_Z80");
	case EM_VISIUM: ARCH_MISSING("EM_VISIUM");
	case EM_FT32: ARCH_MISSING("EM_FT32");
	case EM_MOXIE: ARCH_MISSING("EM_MOXIE");
	case EM_AMDGPU: ARCH_MISSING("EM_AMDGPU");
	case EM_LANAI_OLD: ARCH_MISSING("EM_LANAI_OLD");
	case EM_CEVA: ARCH_MISSING("EM_CEVA");
	case EM_CEVA_X2: ARCH_MISSING("EM_CEVA_X2");
	case EM_BPF: ARCH_MISSING("EM_BPF");
	case EM_GRAPHCORE_IPU: ARCH_MISSING("EM_GRAPHCORE_IPU");
	case EM_NFP: ARCH_MISSING("EM_NFP");
	case EM_VE: ARCH_MISSING("EM_VE");
	case EM_CSKY: ARCH_MISSING("EM_CSKY");
	case EM_ARC_COMPACT3_64: ARCH_MISSING("EM_ARC_COMPACT3_64");
	case EM_MCS6502: ARCH_MISSING("EM_MCS6502");
	case EM_ARC_COMPACT3: ARCH_MISSING("EM_ARC_COMPACT3");
	case EM_KVX: ARCH_MISSING("EM_KVX");
	case EM_65816: ARCH_MISSING("EM_65816");
	case EM_LOONGARCH: ARCH_MISSING("EM_LOONGARCH");
	case EM_KF32: ARCH_MISSING("EM_KF32");
	case EM_U16_U8CORE: ARCH_MISSING("EM_U16_U8CORE");
	case EM_TACHYUM: ARCH_MISSING("EM_TACHYUM");
	case EM_56800EF: ARCH_MISSING("EM_56800EF");
	case EM_AVR_OLD: ARCH_MISSING("EM_AVR_OLD");
	case EM_MSP430_OLD: ARCH_MISSING("EM_MSP430_OLD");
	case EM_MT: ARCH_MISSING("EM_MT");
	case EM_CYGNUS_FR30: ARCH_MISSING("EM_CYGNUS_FR30");
	case EM_WEBASSEMBLY: ARCH_MISSING("EM_WEBASSEMBLY");
	case EM_S12Z: ARCH_MISSING("EM_S12Z");
	case EM_DLX: ARCH_MISSING("EM_DLX");
	case EM_CYGNUS_FRV: ARCH_MISSING("EM_CYGNUS_FRV");
	case EM_XC16X: ARCH_MISSING("EM_XC16X");
	case EM_CYGNUS_D10V: ARCH_MISSING("EM_CYGNUS_D10V");
	case EM_CYGNUS_D30V: ARCH_MISSING("EM_CYGNUS_D30V");
	case EM_IP2K_OLD: ARCH_MISSING("EM_IP2K_OLD");
	case EM_CYGNUS_POWERPC: ARCH_MISSING("EM_CYGNUS_POWERPC");
	case EM_CYGNUS_M32R: ARCH_MISSING("EM_CYGNUS_M32R");
	case EM_CYGNUS_V850: ARCH_MISSING("EM_CYGNUS_V850");
	case EM_S390_OLD: ARCH_MISSING("EM_S390_OLD");
	case EM_XTENSA_OLD: ARCH_MISSING("EM_XTENSA_OLD");
	case EM_XSTORMY16: ARCH_MISSING("EM_XSTORMY16");
	case EM_CYGNUS_MN10300: ARCH_MISSING("EM_CYGNUS_MN10300");
	case EM_CYGNUS_MN10200: ARCH_MISSING("EM_CYGNUS_MN10200");
	case EM_M32C_OLD: ARCH_MISSING("EM_M32C_OLD");
	case EM_IQ2000: ARCH_MISSING("EM_IQ2000");
	case EM_NIOS32: ARCH_MISSING("EM_NIOS32");
	case EM_CYGNUS_MEP: ARCH_MISSING("EM_CYGNUS_MEP");
	case EM_MOXIE_OLD: ARCH_MISSING("EM_MOXIE_OLD");
	case EM_MICROBLAZE_OLD: ARCH_MISSING("EM_MICROBLAZE_OLD");
	case EM_ADAPTEVA_EPIPHANY: ARCH_MISSING("EM_ADAPTEVA_EPIPHANY");
	case EM_V810: ARCH_MISSING("EM_V810");
	default:
		RZ_LOG_INFO("Relocation conversion for machine %d is not implemented.\n", (int)e_machine);
		return NULL;
	}
}

#undef ARCH_MISSING
