summaryrefslogtreecommitdiffstats
path: root/sys/alpha
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2003-01-21 02:42:44 +0000
committerjake <jake@FreeBSD.org>2003-01-21 02:42:44 +0000
commitc1e42cc8bb6beb27c070748587d19f1d63fc956a (patch)
treea6736a5694dc3395d090d1d257e111c315fd88a0 /sys/alpha
parent013247cd19dd036ba508021e0edaba94b2a75960 (diff)
downloadFreeBSD-src-c1e42cc8bb6beb27c070748587d19f1d63fc956a.zip
FreeBSD-src-c1e42cc8bb6beb27c070748587d19f1d63fc956a.tar.gz
Resolve relative relocations in klds before trying to parse the module's
metadata. This fixes module dependency resolution by the kernel linker on sparc64, where the relocations for the metadata are different than on other architectures; the relative offset is in the addend of an Elf_Rela record instead of the original value of the location being patched. Also fix printf formats in debug code. Submitted by: Hartmut Brandt <brandt@fokus.gmd.de> PR: 46732 Tested on: alpha (obrien), i386, sparc64
Diffstat (limited to 'sys/alpha')
-rw-r--r--sys/alpha/alpha/elf_machdep.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/sys/alpha/alpha/elf_machdep.c b/sys/alpha/alpha/elf_machdep.c
index 285a174..1b3c6f2 100644
--- a/sys/alpha/alpha/elf_machdep.c
+++ b/sys/alpha/alpha/elf_machdep.c
@@ -89,8 +89,8 @@ SYSINIT(elf64, SI_SUB_EXEC, SI_ORDER_ANY,
&freebsd_brand_info);
/* Process one elf relocation with addend. */
-int
-elf_reloc(linker_file_t lf, const void *data, int type)
+static int
+elf_reloc_internal(linker_file_t lf, const void *data, int type, int local)
{
Elf_Addr relocbase = (Elf_Addr) lf->address;
Elf_Addr *where;
@@ -119,6 +119,15 @@ elf_reloc(linker_file_t lf, const void *data, int type)
panic("elf_reloc: unknown relocation mode %d\n", type);
}
+ if (local) {
+ if (rtype == R_ALPHA_RELATIVE) {
+ addr = relocbase + addend;
+ if (*where != addr)
+ *where = addr;
+ }
+ return (0);
+ }
+
switch (rtype) {
case R_ALPHA_NONE:
@@ -152,9 +161,6 @@ elf_reloc(linker_file_t lf, const void *data, int type)
break;
case R_ALPHA_RELATIVE:
- addr = relocbase + addend;
- if (*where != addr)
- *where = addr;
break;
case R_ALPHA_COPY:
@@ -174,6 +180,20 @@ elf_reloc(linker_file_t lf, const void *data, int type)
}
int
+elf_reloc(linker_file_t lf, const void *data, int type)
+{
+
+ return (elf_reloc_internal(lf, data, type, 0));
+}
+
+int
+elf_reloc_local(linker_file_t lf, const void *data, int type)
+{
+
+ return (elf_reloc_internal(lf, data, type, 1));
+}
+
+int
elf_cpu_load_file(linker_file_t lf __unused)
{
OpenPOWER on IntegriCloud