diff options
author | peter <peter@FreeBSD.org> | 2004-05-16 20:00:28 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2004-05-16 20:00:28 +0000 |
commit | ea4215c5218f4d79c33e806304e35cc951ea3dc7 (patch) | |
tree | 9c824fecb4de303fa016d7216c651ec04ecaec13 /sys/kern/link_elf.c | |
parent | 1eee96e5b10a90bb98c51684bf6fa7c4b4d1c57f (diff) | |
download | FreeBSD-src-ea4215c5218f4d79c33e806304e35cc951ea3dc7.zip FreeBSD-src-ea4215c5218f4d79c33e806304e35cc951ea3dc7.tar.gz |
Make a small revision to the api between the elf linker core and the
elf_reloc() backends for two reasons. First, to support the possibility
of there being two elf linkers in the kernel (eg: amd64), and second, to
pass the relocbase explicitly (for relocating .o format kld files).
Diffstat (limited to 'sys/kern/link_elf.c')
-rw-r--r-- | sys/kern/link_elf.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index f05cab1..a7b7a02 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -118,6 +118,7 @@ static int link_elf_each_function_name(linker_file_t, int (*)(const char *, void *), void *); static void link_elf_reloc_local(linker_file_t); +static Elf_Addr elf_lookup(linker_file_t lf, Elf_Word symidx, int deps); static kobj_method_t link_elf_methods[] = { KOBJMETHOD(linker_lookup_symbol, link_elf_lookup_symbol), @@ -928,7 +929,8 @@ relocate_file(elf_file_t ef) if (rel) { rellim = (const Elf_Rel *)((const char *)ef->rel + ef->relsize); while (rel < rellim) { - if (elf_reloc(&ef->lf, rel, ELF_RELOC_REL)) { + if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL, + elf_lookup)) { symname = symbol_name(ef, rel->r_info); printf("link_elf: symbol %s undefined\n", symname); return ENOENT; @@ -942,7 +944,8 @@ relocate_file(elf_file_t ef) if (rela) { relalim = (const Elf_Rela *)((const char *)ef->rela + ef->relasize); while (rela < relalim) { - if (elf_reloc(&ef->lf, rela, ELF_RELOC_RELA)) { + if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA, + elf_lookup)) { symname = symbol_name(ef, rela->r_info); printf("link_elf: symbol %s undefined\n", symname); return ENOENT; @@ -956,7 +959,8 @@ relocate_file(elf_file_t ef) if (rel) { rellim = (const Elf_Rel *)((const char *)ef->pltrel + ef->pltrelsize); while (rel < rellim) { - if (elf_reloc(&ef->lf, rel, ELF_RELOC_REL)) { + if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL, + elf_lookup)) { symname = symbol_name(ef, rel->r_info); printf("link_elf: symbol %s undefined\n", symname); return ENOENT; @@ -970,7 +974,8 @@ relocate_file(elf_file_t ef) if (rela) { relalim = (const Elf_Rela *)((const char *)ef->pltrela + ef->pltrelasize); while (rela < relalim) { - if (elf_reloc(&ef->lf, rela, ELF_RELOC_RELA)) { + if (elf_reloc(&ef->lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA, + elf_lookup)) { symname = symbol_name(ef, rela->r_info); printf("link_elf: symbol %s undefined\n", symname); return ENOENT; @@ -1244,7 +1249,7 @@ elf_get_symname(linker_file_t lf, Elf_Word symidx) * This is not only more efficient, it's also more correct. It's not always * the case that the symbol can be found through the hash table. */ -Elf_Addr +static Elf_Addr elf_lookup(linker_file_t lf, Elf_Word symidx, int deps) { elf_file_t ef = (elf_file_t)lf; @@ -1297,7 +1302,8 @@ link_elf_reloc_local(linker_file_t lf) if ((rel = ef->rel) != NULL) { rellim = (const Elf_Rel *)((const char *)ef->rel + ef->relsize); while (rel < rellim) { - elf_reloc_local(lf, rel, ELF_RELOC_REL); + elf_reloc_local(lf, (Elf_Addr)ef->address, rel, ELF_RELOC_REL, + elf_lookup); rel++; } } @@ -1306,7 +1312,8 @@ link_elf_reloc_local(linker_file_t lf) if ((rela = ef->rela) != NULL) { relalim = (const Elf_Rela *)((const char *)ef->rela + ef->relasize); while (rela < relalim) { - elf_reloc_local(lf, rela, ELF_RELOC_RELA); + elf_reloc_local(lf, (Elf_Addr)ef->address, rela, ELF_RELOC_RELA, + elf_lookup); rela++; } } |