diff options
author | bp <bp@FreeBSD.org> | 2000-02-25 05:10:44 +0000 |
---|---|---|
committer | bp <bp@FreeBSD.org> | 2000-02-25 05:10:44 +0000 |
commit | 6ed9854c48d942a383d971d5953ceaee312d00c3 (patch) | |
tree | 41c84e1ae19c4f17c1c8e554b86dcfab8af0c831 /sys/boot/common/load_elf.c | |
parent | 8e4001f110a1d606772d3c9b1a007a59957470e1 (diff) | |
download | FreeBSD-src-6ed9854c48d942a383d971d5953ceaee312d00c3.zip FreeBSD-src-6ed9854c48d942a383d971d5953ceaee312d00c3.tar.gz |
Fix the loader to handle module dependencies properly. More fixes
will be provided after modmetadata appears in the kernel.
Reviewed by: msmith
Approved by: jkh
Diffstat (limited to 'sys/boot/common/load_elf.c')
-rw-r--r-- | sys/boot/common/load_elf.c | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c index 024fece..8fbcf19 100644 --- a/sys/boot/common/load_elf.c +++ b/sys/boot/common/load_elf.c @@ -212,10 +212,7 @@ elf_loadimage(struct loaded_module *mp, int fd, vm_offset_t off, vm_offset_t ssym, esym; Elf_Dyn *dp; int ndp; - int deplen; - char *depdata; char *s; - int len; char *strtab; size_t strsz; int symstrindex; @@ -450,7 +447,6 @@ nosyms: goto out; strtab = NULL; strsz = 0; - deplen = 0; for (i = 0; i < ndp; i++) { if (dp[i].d_tag == NULL) break; @@ -468,44 +464,17 @@ nosyms: if (strtab == NULL || strsz == 0) goto out; - deplen = 0; for (i = 0; i < ndp; i++) { if (dp[i].d_tag == NULL) break; - switch (dp[i].d_tag) { - case DT_NEEDED: /* count size for dependency list */ - j = dp[i].d_un.d_ptr; - if (j < 1 || j > (strsz - 2)) - continue; /* bad symbol name index */ - deplen += strlenout((vm_offset_t)&strtab[j]) + 1; - break; - default: - break; - } - } - - if (deplen > 0) { - depdata = malloc(deplen); - if (depdata == NULL) - goto out; - s = depdata; - for (i = 0; i < ndp; i++) { - if (dp[i].d_tag == NULL) - break; - switch (dp[i].d_tag) { - case DT_NEEDED: /* dependency list */ - j = dp[i].d_un.d_ptr; - len = strlenout((vm_offset_t)&strtab[j]) + 1; - archsw.arch_copyout((vm_offset_t)&strtab[j], s, len); - s += len; - break; - default: - break; - } - } - if ((s - depdata) > 0) - mod_addmetadata(mp, MODINFOMD_DEPLIST, s - depdata, depdata); - free(depdata); + if (dp[i].d_tag != DT_NEEDED) + continue; + j = dp[i].d_un.d_ptr; + if (j < 1 || j > (strsz - 2)) + continue; /* bad symbol name index */ + s = strdupout((vm_offset_t)&strtab[j]); + mod_addmetadata(mp, MODINFOMD_DEPLIST, strlen(s) + 1, s); + free(s); } out: |