summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2002-10-19 19:16:03 +0000
committermarcel <marcel@FreeBSD.org>2002-10-19 19:16:03 +0000
commitd35d608c0774a40070b89879d9410bdf473177d7 (patch)
treea5d88a56e3884938d35135eb41dd619975aba723
parentc5e66cd2c6877a700af9fbf50ea239377f827424 (diff)
downloadFreeBSD-src-d35d608c0774a40070b89879d9410bdf473177d7.zip
FreeBSD-src-d35d608c0774a40070b89879d9410bdf473177d7.tar.gz
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
-rw-r--r--sys/alpha/alpha/elf_machdep.c14
-rw-r--r--sys/amd64/amd64/elf_machdep.c14
-rw-r--r--sys/i386/i386/elf_machdep.c14
-rw-r--r--sys/ia64/ia64/elf_machdep.c15
-rw-r--r--sys/kern/link_elf.c9
-rw-r--r--sys/kern/link_elf_obj.c9
-rw-r--r--sys/powerpc/powerpc/elf_machdep.c14
-rw-r--r--sys/sparc64/sparc64/elf_machdep.c14
-rw-r--r--sys/sys/linker.h3
9 files changed, 106 insertions, 0 deletions
diff --git a/sys/alpha/alpha/elf_machdep.c b/sys/alpha/alpha/elf_machdep.c
index ddeae1b..285a174 100644
--- a/sys/alpha/alpha/elf_machdep.c
+++ b/sys/alpha/alpha/elf_machdep.c
@@ -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);
+}
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index 619b077..71520de 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -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);
+}
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c
index 619b077..71520de 100644
--- a/sys/i386/i386/elf_machdep.c
+++ b/sys/i386/i386/elf_machdep.c
@@ -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);
+}
diff --git a/sys/ia64/ia64/elf_machdep.c b/sys/ia64/ia64/elf_machdep.c
index 5b2bc2e..ea8695f 100644
--- a/sys/ia64/ia64/elf_machdep.c
+++ b/sys/ia64/ia64/elf_machdep.c
@@ -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);
+}
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index bbbaa2c..75c95cd 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -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;
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index bbbaa2c..75c95cd 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -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;
diff --git a/sys/powerpc/powerpc/elf_machdep.c b/sys/powerpc/powerpc/elf_machdep.c
index c1627b1..e00c9d3 100644
--- a/sys/powerpc/powerpc/elf_machdep.c
+++ b/sys/powerpc/powerpc/elf_machdep.c
@@ -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);
+}
diff --git a/sys/sparc64/sparc64/elf_machdep.c b/sys/sparc64/sparc64/elf_machdep.c
index 4889bc9..e4860c8 100644
--- a/sys/sparc64/sparc64/elf_machdep.c
+++ b/sys/sparc64/sparc64/elf_machdep.c
@@ -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);
+}
diff --git a/sys/sys/linker.h b/sys/sys/linker.h
index d15a387..5e0a760 100644
--- a/sys/sys/linker.h
+++ b/sys/sys/linker.h
@@ -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
OpenPOWER on IntegriCloud