162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASM_MODULE_H 362306a36Sopenharmony_ci#define _ASM_MODULE_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/list.h> 662306a36Sopenharmony_ci#include <linux/elf.h> 762306a36Sopenharmony_ci#include <asm/extable.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct mod_arch_specific { 1062306a36Sopenharmony_ci /* Data Bus Error exception tables */ 1162306a36Sopenharmony_ci struct list_head dbe_list; 1262306a36Sopenharmony_ci const struct exception_table_entry *dbe_start; 1362306a36Sopenharmony_ci const struct exception_table_entry *dbe_end; 1462306a36Sopenharmony_ci struct mips_hi16 *r_mips_hi16_list; 1562306a36Sopenharmony_ci}; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_citypedef uint8_t Elf64_Byte; /* Type for a 8-bit quantity. */ 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_citypedef struct { 2062306a36Sopenharmony_ci Elf64_Addr r_offset; /* Address of relocation. */ 2162306a36Sopenharmony_ci Elf64_Word r_sym; /* Symbol index. */ 2262306a36Sopenharmony_ci Elf64_Byte r_ssym; /* Special symbol. */ 2362306a36Sopenharmony_ci Elf64_Byte r_type3; /* Third relocation. */ 2462306a36Sopenharmony_ci Elf64_Byte r_type2; /* Second relocation. */ 2562306a36Sopenharmony_ci Elf64_Byte r_type; /* First relocation. */ 2662306a36Sopenharmony_ci} Elf64_Mips_Rel; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_citypedef struct { 2962306a36Sopenharmony_ci Elf64_Addr r_offset; /* Address of relocation. */ 3062306a36Sopenharmony_ci Elf64_Word r_sym; /* Symbol index. */ 3162306a36Sopenharmony_ci Elf64_Byte r_ssym; /* Special symbol. */ 3262306a36Sopenharmony_ci Elf64_Byte r_type3; /* Third relocation. */ 3362306a36Sopenharmony_ci Elf64_Byte r_type2; /* Second relocation. */ 3462306a36Sopenharmony_ci Elf64_Byte r_type; /* First relocation. */ 3562306a36Sopenharmony_ci Elf64_Sxword r_addend; /* Addend. */ 3662306a36Sopenharmony_ci} Elf64_Mips_Rela; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#ifdef CONFIG_32BIT 3962306a36Sopenharmony_ci#define Elf_Shdr Elf32_Shdr 4062306a36Sopenharmony_ci#define Elf_Sym Elf32_Sym 4162306a36Sopenharmony_ci#define Elf_Ehdr Elf32_Ehdr 4262306a36Sopenharmony_ci#define Elf_Addr Elf32_Addr 4362306a36Sopenharmony_ci#define Elf_Rel Elf32_Rel 4462306a36Sopenharmony_ci#define Elf_Rela Elf32_Rela 4562306a36Sopenharmony_ci#define ELF_R_TYPE(X) ELF32_R_TYPE(X) 4662306a36Sopenharmony_ci#define ELF_R_SYM(X) ELF32_R_SYM(X) 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define Elf_Mips_Rel Elf32_Rel 4962306a36Sopenharmony_ci#define Elf_Mips_Rela Elf32_Rela 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define ELF_MIPS_R_SYM(rel) ELF32_R_SYM((rel).r_info) 5262306a36Sopenharmony_ci#define ELF_MIPS_R_TYPE(rel) ELF32_R_TYPE((rel).r_info) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#endif 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#ifdef CONFIG_64BIT 5762306a36Sopenharmony_ci#define Elf_Shdr Elf64_Shdr 5862306a36Sopenharmony_ci#define Elf_Sym Elf64_Sym 5962306a36Sopenharmony_ci#define Elf_Ehdr Elf64_Ehdr 6062306a36Sopenharmony_ci#define Elf_Addr Elf64_Addr 6162306a36Sopenharmony_ci#define Elf_Rel Elf64_Rel 6262306a36Sopenharmony_ci#define Elf_Rela Elf64_Rela 6362306a36Sopenharmony_ci#define ELF_R_TYPE(X) ELF64_R_TYPE(X) 6462306a36Sopenharmony_ci#define ELF_R_SYM(X) ELF64_R_SYM(X) 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#define Elf_Mips_Rel Elf64_Mips_Rel 6762306a36Sopenharmony_ci#define Elf_Mips_Rela Elf64_Mips_Rela 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#define ELF_MIPS_R_SYM(rel) ((rel).r_sym) 7062306a36Sopenharmony_ci#define ELF_MIPS_R_TYPE(rel) ((rel).r_type) 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci#endif 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci#ifdef CONFIG_MODULES 7562306a36Sopenharmony_ci/* Given an address, look for it in the exception tables. */ 7662306a36Sopenharmony_ciconst struct exception_table_entry*search_module_dbetables(unsigned long addr); 7762306a36Sopenharmony_ci#else 7862306a36Sopenharmony_ci/* Given an address, look for it in the exception tables. */ 7962306a36Sopenharmony_cistatic inline const struct exception_table_entry * 8062306a36Sopenharmony_cisearch_module_dbetables(unsigned long addr) 8162306a36Sopenharmony_ci{ 8262306a36Sopenharmony_ci return NULL; 8362306a36Sopenharmony_ci} 8462306a36Sopenharmony_ci#endif 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci#endif /* _ASM_MODULE_H */ 87