Add two hooks to signal module load and module unload to MD code.

The primary reason for this is to allow MD code to process machine
specific attributes, segments or sections in the ELF file and
update machine specific state accordingly. An immediate use of this
is in the ia64 port where unwind information is updated to allow
debugging and tracing in/across modules. Note that this commit
does not add the functionality to the ia64 port. See revision 1.9
of ia64/ia64/elf_machdep.c.

Validated on: alpha, i386, ia64
This commit is contained in:
Marcel Moolenaar 2002-10-19 19:16:03 +00:00
parent c143d6c24a
commit 1aeb23cdfa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105469
9 changed files with 106 additions and 0 deletions

View File

@ -172,3 +172,17 @@ elf_reloc(linker_file_t lf, const void *data, int type)
}
return(0);
}
int
elf_cpu_load_file(linker_file_t lf __unused)
{
return (0);
}
int
elf_cpu_unload_file(linker_file_t lf __unused)
{
return (0);
}

View File

@ -169,3 +169,17 @@ elf_reloc(linker_file_t lf, const void *data, int type)
}
return(0);
}
int
elf_cpu_load_file(linker_file_t lf __unused)
{
return (0);
}
int
elf_cpu_unload_file(linker_file_t lf __unused)
{
return (0);
}

View File

@ -169,3 +169,17 @@ elf_reloc(linker_file_t lf, const void *data, int type)
}
return(0);
}
int
elf_cpu_load_file(linker_file_t lf __unused)
{
return (0);
}
int
elf_cpu_unload_file(linker_file_t lf __unused)
{
return (0);
}

View File

@ -46,6 +46,7 @@
#include <machine/elf.h>
#include <machine/md_var.h>
#include <machine/unwind.h>
struct sysentvec elf64_freebsd_sysvec = {
SYS_MAXSYSCALL,
@ -215,3 +216,17 @@ elf_reloc(linker_file_t lf, const void *data, int type)
return (0);
}
int
elf_cpu_load_file(linker_file_t lf __unused)
{
return (0);
}
int
elf_cpu_unload_file(linker_file_t lf __unused)
{
return (0);
}

View File

@ -222,6 +222,12 @@ link_elf_link_common_finish(linker_file_t lf)
elf_file_t ef = (elf_file_t)lf;
char *newfilename;
#endif
int error;
/* Notify MD code that a module is being loaded. */
error = elf_cpu_load_file(lf);
if (error)
return (error);
#ifdef DDB
GDB_STATE(RT_ADD);
@ -838,6 +844,9 @@ link_elf_unload_file(linker_file_t file)
}
#endif
/* Notify MD code that a module is being unloaded. */
elf_cpu_unload_file(file);
if (ef->preloaded) {
link_elf_unload_preload(file);
return;

View File

@ -222,6 +222,12 @@ link_elf_link_common_finish(linker_file_t lf)
elf_file_t ef = (elf_file_t)lf;
char *newfilename;
#endif
int error;
/* Notify MD code that a module is being loaded. */
error = elf_cpu_load_file(lf);
if (error)
return (error);
#ifdef DDB
GDB_STATE(RT_ADD);
@ -838,6 +844,9 @@ link_elf_unload_file(linker_file_t file)
}
#endif
/* Notify MD code that a module is being unloaded. */
elf_cpu_unload_file(file);
if (ef->preloaded) {
link_elf_unload_preload(file);
return;

View File

@ -163,3 +163,17 @@ elf_reloc(linker_file_t lf, const void *data, int type)
}
return(0);
}
int
elf_cpu_load_file(linker_file_t lf __unused)
{
return (0);
}
int
elf_cpu_unload_file(linker_file_t lf __unused)
{
return (0);
}

View File

@ -312,3 +312,17 @@ elf_reloc(linker_file_t lf, const void *data, int type)
return (0);
}
int
elf_cpu_load_file(linker_file_t lf __unused)
{
return (0);
}
int
elf_cpu_unload_file(linker_file_t lf __unused)
{
return (0);
}

View File

@ -233,6 +233,9 @@ Elf_Addr elf_lookup(linker_file_t, Elf_Word, int);
const Elf_Sym *elf_get_sym(linker_file_t _lf, Elf_Word _symidx);
const char *elf_get_symname(linker_file_t _lf, Elf_Word _symidx);
int elf_cpu_load_file(linker_file_t);
int elf_cpu_unload_file(linker_file_t);
/* values for type */
#define ELF_RELOC_REL 1
#define ELF_RELOC_RELA 2