mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 00:56:49 +07:00
3a611c3cfb
Fengguang Wu's build bot detected that if moduleloader.h is included in a C file (used by ftrace and kprobes to access module_alloc() when available), that it can fail to build if CONFIG_MODULES and CONFIG_MODULES_USE_ELF_REL is not defined. This is because there's a printk() that dereferences struct module to print the name of the module. But as struct module does not exist when CONFIG_MODULES is not defined we get this error: include/linux/moduleloader.h: In function 'apply_relocate': >> include/linux/moduleloader.h:48:63: error: dereferencing pointer to >> incomplete type printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name); ^ Reported-by: kbuild test robot <fengguang.wu@intel.com> Based-on-the-true-story-by: Steven Rostedt <rostedt@goodmis.org> Confirms-rustys-story-ends-the-same-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
86 lines
2.5 KiB
C
86 lines
2.5 KiB
C
#ifndef _LINUX_MODULELOADER_H
|
|
#define _LINUX_MODULELOADER_H
|
|
/* The stuff needed for archs to support modules. */
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/elf.h>
|
|
|
|
/* These may be implemented by architectures that need to hook into the
|
|
* module loader code. Architectures that don't need to do anything special
|
|
* can just rely on the 'weak' default hooks defined in kernel/module.c.
|
|
* Note, however, that at least one of apply_relocate or apply_relocate_add
|
|
* must be implemented by each architecture.
|
|
*/
|
|
|
|
/* Adjust arch-specific sections. Return 0 on success. */
|
|
int module_frob_arch_sections(Elf_Ehdr *hdr,
|
|
Elf_Shdr *sechdrs,
|
|
char *secstrings,
|
|
struct module *mod);
|
|
|
|
/* Additional bytes needed by arch in front of individual sections */
|
|
unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
|
|
|
|
/* Allocator used for allocating struct module, core sections and init
|
|
sections. Returns NULL on failure. */
|
|
void *module_alloc(unsigned long size);
|
|
|
|
/* Free memory returned from module_alloc. */
|
|
void module_free(struct module *mod, void *module_region);
|
|
|
|
/*
|
|
* Apply the given relocation to the (simplified) ELF. Return -error
|
|
* or 0.
|
|
*/
|
|
#ifdef CONFIG_MODULES_USE_ELF_REL
|
|
int apply_relocate(Elf_Shdr *sechdrs,
|
|
const char *strtab,
|
|
unsigned int symindex,
|
|
unsigned int relsec,
|
|
struct module *mod);
|
|
#else
|
|
static inline int apply_relocate(Elf_Shdr *sechdrs,
|
|
const char *strtab,
|
|
unsigned int symindex,
|
|
unsigned int relsec,
|
|
struct module *me)
|
|
{
|
|
printk(KERN_ERR "module %s: REL relocation unsupported\n",
|
|
module_name(me));
|
|
return -ENOEXEC;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* Apply the given add relocation to the (simplified) ELF. Return
|
|
* -error or 0
|
|
*/
|
|
#ifdef CONFIG_MODULES_USE_ELF_RELA
|
|
int apply_relocate_add(Elf_Shdr *sechdrs,
|
|
const char *strtab,
|
|
unsigned int symindex,
|
|
unsigned int relsec,
|
|
struct module *mod);
|
|
#else
|
|
static inline int apply_relocate_add(Elf_Shdr *sechdrs,
|
|
const char *strtab,
|
|
unsigned int symindex,
|
|
unsigned int relsec,
|
|
struct module *me)
|
|
{
|
|
printk(KERN_ERR "module %s: REL relocation unsupported\n",
|
|
module_name(me));
|
|
return -ENOEXEC;
|
|
}
|
|
#endif
|
|
|
|
/* Any final processing of module before access. Return -error or 0. */
|
|
int module_finalize(const Elf_Ehdr *hdr,
|
|
const Elf_Shdr *sechdrs,
|
|
struct module *mod);
|
|
|
|
/* Any cleanup needed when module leaves. */
|
|
void module_arch_cleanup(struct module *mod);
|
|
|
|
#endif
|