diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-04-17 13:23:15 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2003-04-17 13:23:15 +0000 |
commit | 898aaa5a8d44b95d264525b4a3e6c3a5f8d4f5b7 (patch) | |
tree | 4b08a2160687d88084eb1267343a3ee70f9479bd /sys/lib | |
parent | 4fb08e4f8fd43d061c1168847593d409cb099647 (diff) |
replaced by loadfile now
Diffstat (limited to 'sys/lib')
-rw-r--r-- | sys/lib/libsa/exec.new.c | 130 | ||||
-rw-r--r-- | sys/lib/libsa/exec_aout.c | 121 | ||||
-rw-r--r-- | sys/lib/libsa/exec_ecoff.c | 83 | ||||
-rw-r--r-- | sys/lib/libsa/exec_elf.c | 287 |
4 files changed, 0 insertions, 621 deletions
diff --git a/sys/lib/libsa/exec.new.c b/sys/lib/libsa/exec.new.c deleted file mode 100644 index 22d03a59b46..00000000000 --- a/sys/lib/libsa/exec.new.c +++ /dev/null @@ -1,130 +0,0 @@ -/* $OpenBSD: exec.new.c,v 1.5 2000/05/30 21:59:30 mickey Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include <sys/param.h> -#include <sys/reboot.h> -#ifndef INSECURE -#include <sys/stat.h> -#endif -#include "libsa.h" -#include <lib/libsa/exec.h> - -extern int debug; - -void -exec(path, loadaddr, howto) - char *path; - void *loadaddr; - int howto; -{ - int fd; - struct stat sb; - const struct x_sw *sw; - struct x_param param; - union x_header hdr; - register u_char *pa; - register int save_err; - - if ((fd = open(path, 0)) < 0 || fstat(fd, &sb)) - return; - - if (sb.st_mode & 2) - printf("non-secure file, check permissions!\n"); - - if (read(fd, (char *)&hdr, sizeof(hdr)) != sizeof(hdr)) - return; - - errno = 0; /* XXX */ - /* probe obj format */ - for (sw = execsw; sw->probe; sw++) - if (sw->probe(fd, &hdr)) - break; - - bzero (¶m, sizeof(param)); - param.xp_execsw = sw; - param.xp_hdr = &hdr; - - if (!sw->probe || sw->load(fd, ¶m)) { - errno = errno? errno : EFTYPE; - goto err; - } -#ifdef EXEC_DEBUG - if (debug) - printf("ep=%x, end=%x\n.text=%x,%u,%u\n.data=%x,%u,%u\n" - ".bss=%x,%u,%u\n.sym=%x,%u,%u\n.str=%x,%u,%u\n", - param.xp_entry, param.xp_end, - param.text.addr, param.text.size, param.text.foff, - param.data.addr, param.data.size, param.data.foff, - param.bss.addr, param.bss.size, param.bss.foff, - param.sym.addr, param.sym.size, param.sym.foff, - param.str.addr, param.str.size, param.str.foff); -#endif - param.xp_end = (u_int)pa = loadaddr; - - printf("%u", param.text.size); - /* .text */ - if (lseek(fd, param.text.foff, SEEK_SET) < 0 || - read(fd, pa+param.text.addr, param.text.size) != param.text.size) - goto err; - - /* .data */ - if (param.data.size) { - printf("+%u", param.data.size); - if (lseek(fd, param.data.foff, SEEK_SET) <= 0 || - read(fd,pa+param.data.addr,param.data.size) != param.data.size) - goto err; - } - - /* .bss */ - printf("+%u", param.bss.size); - bzero (pa + param.bss.addr, param.bss.size); - - param.xp_end = (int)pa + param.bss.addr + param.bss.size; - if (sw->ldsym && sw->ldsym(fd, ¶m)) { - errno = errno? errno : EFTYPE; - goto err; - } - - /* ldsym will adjust the xp_end */ - printf("=0x%x start=0x%x\n", param.xp_end, param.xp_entry); - - /* call the joker */ - machdep_exec(¶m, howto, loadaddr); - - /* exec failed */ - errno = ENOEXEC; - return; -err: - save_err = errno? errno: EIO; - close(fd); - errno = save_err; -} diff --git a/sys/lib/libsa/exec_aout.c b/sys/lib/libsa/exec_aout.c deleted file mode 100644 index b5fa341ab47..00000000000 --- a/sys/lib/libsa/exec_aout.c +++ /dev/null @@ -1,121 +0,0 @@ -/* $OpenBSD: exec_aout.c,v 1.2 2000/05/30 21:59:30 mickey Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "libsa.h" -#include <machine/exec.h> -#include <lib/libsa/exec.h> - -int -aout_probe(fd, hdr) - int fd; - union x_header *hdr; -{ - return !N_BADMAG(hdr->x_aout); -} - - -int -aout_load(fd, xp) - int fd; - register struct x_param *xp; -{ - register struct exec *x = &xp->xp_hdr->x_aout; - -#ifdef EXEC_DEBUG - printf("\nstruct exec {%x, %x, %x, %x, %x, %x, %x, %x}\n", - x->a_midmag, x->a_text, x->a_data, x->a_bss, x->a_syms, - x->a_entry, x->a_trsize, x->a_drsize); -#endif - xp->xp_entry = x->a_entry; - - xp->text.foff = N_GETMAGIC(*x) == ZMAGIC? 0: sizeof(*x); - xp->data.foff = xp->text.foff + x->a_text; - xp->bss.foff = 0; - if (x->a_syms) { - xp->sym.foff = xp->data.foff + x->a_data; - xp->str.foff = xp->sym.foff + x->a_syms; - } - - xp->text.addr = 0; - xp->data.addr = xp->text.addr + x->a_text; - if (N_GETMAGIC(*x) == NMAGIC) - xp->data.addr += N_PAGSIZ(x)- (xp->data.addr & (N_PAGSIZ(x)-1)); - xp->bss.addr = xp->data.addr + x->a_data; - xp->sym.addr = xp->bss.addr + x->a_bss; - xp->str.addr = xp->sym.addr + x->a_syms; - - xp->text.size = x->a_text; - xp->data.size = x->a_data; - xp->bss.size = x->a_bss; - xp->sym.size = x->a_syms; - xp->str.size = 0; /* will be hacked later in aout_ldsym() */ - - return 0; -} - -int -aout_ldsym(fd, xp) - int fd; - register struct x_param *xp; -{ - char *pa; - u_int i; - - /* Symbols */ - if (xp->sym.size) { - pa = (char *)xp->xp_end; - - *(u_int *)pa = xp->sym.size; - pa += sizeof(u_int); - printf("+[%u", xp->sym.size); - if (read(fd, pa, xp->sym.size) != (ssize_t)xp->sym.size) - return -1; - pa += xp->sym.size; - - if (read(fd, pa, sizeof(u_int)) != sizeof(u_int)) - return -1; - - if ((i = *(u_int *)pa)) { - pa += sizeof(u_int); - i -= sizeof(u_int); - if (read(fd, pa, i) != i) - return -1; - pa += i; - } - - /* and that many bytes of string table */ - printf("+%d]", i); - xp->xp_end = (u_long)pa; - } - - return 0; -} diff --git a/sys/lib/libsa/exec_ecoff.c b/sys/lib/libsa/exec_ecoff.c deleted file mode 100644 index 87b6a938b94..00000000000 --- a/sys/lib/libsa/exec_ecoff.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $OpenBSD: exec_ecoff.c,v 1.2 1998/07/14 16:51:26 mickey Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "libsa.h" -#include <lib/libsa/exec.h> - -int -ecoff_probe(fd, hdr) - int fd; - union x_header *hdr; -{ - return !ECOFF_BADMAG(&(hdr->x_ecoff)); -} - - -int -ecoff_load(fd, xp) - int fd; - register struct x_param *xp; -{ - register struct ecoff_exechdr *x = &xp->xp_hdr->x_ecoff; - -#ifdef EXEC_DEBUG - printf("\nstruct ecoff_exechdr { f.{%x, %x, %x, %lx, %x, %x, %x}\n" - "\ta.{%x, %lx, %lx, %lx, %lx, %lx, %lx, %lx} }\n", - x->f.f_magic, x->f.f_nscns, x->f.f_timdat, x->f.f_symptr, - x->f.f_nsyms, x->f.f_opthdr, x->f.f_flags, - x->a.magic, x->a.tsize, x->a.dsize, x->a.bsize, - x->a.entry, x->a.text_start, x->a.data_start, x->a.bss_start); -#endif - xp->xp_entry = x->a.entry; - - xp->text.size = x->a.tsize; - xp->data.size = x->a.dsize; - xp->bss.size = x->a.bsize; - xp->sym.size = x->f.f_nsyms * sizeof (struct ecoff_extsym); - xp->str.size = 0; - - xp->text.foff = ECOFF_TXTOFF(x); - xp->data.foff = xp->text.foff + x->a.tsize; - xp->bss.foff = 0; - if (x->f.f_symptr) { - xp->sym.foff = xp->data.foff + x->a.dsize; - xp->str.foff = xp->sym.foff + xp->sym.size; - } - - xp->text.addr = x->a.text_start; - xp->data.addr = x->a.data_start; - xp->bss.addr = x->a.bss_start; - xp->sym.addr = x->f.f_symptr; - xp->str.addr = xp->sym.addr + xp->sym.size; - - return 0; -} diff --git a/sys/lib/libsa/exec_elf.c b/sys/lib/libsa/exec_elf.c deleted file mode 100644 index 5b4bf9291ee..00000000000 --- a/sys/lib/libsa/exec_elf.c +++ /dev/null @@ -1,287 +0,0 @@ -/* $OpenBSD: exec_elf.c,v 1.6 2002/07/09 01:45:47 mickey Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Michael Shalayeff. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "libsa.h" -#include <lib/libsa/exec.h> -#include <sys/exec_elf.h> -#include <ddb/db_aout.h> - -int -elf_probe(fd, hdr) - int fd; - union x_header *hdr; -{ - return IS_ELF(hdr->x_elf); -} - -int -elf_load(fd, xp) - int fd; - struct x_param *xp; -{ - register Elf32_Ehdr *ehdr = (Elf32_Ehdr *)xp->xp_hdr; - register Elf32_Phdr *ph; - Elf32_Phdr phdr[8]; /* XXX hope this is enough */ - size_t phsize; - register u_int pa; - -#ifdef EXEC_DEBUG - if (debug) - printf("id=%x.%c%c%c.%x.%x, type=%x, mach=%x, ver=%x, size=%d\n" - "\tep=%x, flgs=%x, ph=%x[%dx%d], sh=%x[%dx%d], str=%x\n", - ehdr->e_ident[0], ehdr->e_ident[1], ehdr->e_ident[2], - ehdr->e_ident[3], ehdr->e_ident[4], ehdr->e_ident[5], - ehdr->e_type, ehdr->e_machine, ehdr->e_version, - ehdr->e_ehsize, ehdr->e_entry, ehdr->e_flags, - ehdr->e_phoff, ehdr->e_phnum, ehdr->e_phentsize, - ehdr->e_shoff, ehdr->e_shnum, ehdr->e_shentsize, - ehdr->e_shstrndx); -#endif - - xp->xp_entry = ehdr->e_entry; - - if (lseek(fd, ehdr->e_phoff, SEEK_SET) <= 0) { -#ifdef EXEC_DEBUG - if (debug) - printf("lseek failed (%d)\n", errno); -#endif - return -1; - } - - phsize = ehdr->e_phnum * ehdr->e_phentsize; - if (phsize > sizeof(phdr) || read(fd, phdr, phsize) != phsize) { -#ifdef EXEC_DEBUG - if (debug) - printf("phdr read failed (%d)\n", errno); -#endif - return -1; - } - - pa = 0; - for (ph = phdr; ph < &phdr[ehdr->e_phnum]; ph++) { -#ifdef EXEC_DEBUG - if (debug) - printf("ph%d: type=%x, off=%d, va=%x, fs=%d, ms=%d, " - "flags=%x\n", (ph - phdr), ph->p_type, - ph->p_offset, ph->p_vaddr, ph->p_filesz, - ph->p_memsz, ph->p_flags); -#endif - if (ph->p_filesz && ph->p_flags & PF_X) { - pa = ph->p_vaddr; - xp->text.addr = ph->p_vaddr; - xp->text.size = ph->p_filesz; - xp->text.foff = ph->p_offset; - } else if (ph->p_filesz && ph->p_flags & PF_W) { - xp->data.addr = ph->p_vaddr; - xp->data.size = ph->p_filesz; - xp->data.foff = ph->p_offset; - if (ph->p_filesz < ph->p_memsz) { - xp->bss.addr = ph->p_vaddr + ph->p_filesz; - xp->bss.size = ph->p_memsz - ph->p_filesz; - xp->bss.foff = 0; - } - } else if (!ph->p_filesz) { - xp->bss.addr = ph->p_vaddr; - xp->bss.size = ph->p_memsz; - xp->bss.foff = 0; - } - } - - return 0; -} - -int -elf_ldsym(fd, xp) - int fd; - struct x_param *xp; -{ - register Elf32_Ehdr *ehdr = (Elf32_Ehdr *)xp->xp_hdr; - Elf32_Sym elfsym; - Elf32_Shdr shdr[32]; /* XXX hope this is enough */ - register Elf32_Shdr *sh; - register struct nlist *nl; - register u_int ss, shsize; - - if (lseek(fd, ehdr->e_shoff, SEEK_SET) <= 0) { -#ifdef DEBUG - printf("ehdr lseek: %s\n", strerror(errno)); -#endif - return -1; - } - - /* calc symbols location, scanning section headers */ - shsize = ehdr->e_shnum * ehdr->e_shentsize; - sh = shdr; - - if (shsize > sizeof(shdr) || read(fd, shdr, shsize) != shsize) { -#ifdef DEBUG - printf("shdr read: %s\n", strerror(errno)); -#endif - return -1; - } - - for (sh = shdr; sh < &shdr[ehdr->e_shnum]; sh++) { -#ifdef EXEC_DEBUG - if (debug) - printf ("sh%d: type=%x, flags=%x, addr=%x, " - "foff=%x, sz=%x, link=%x, info=%x, " - "allign=%x, esz=%x\n", sh - shdr, - sh->sh_type, sh->sh_flags, sh->sh_addr, - sh->sh_offset, sh->sh_size, sh->sh_link, - sh->sh_info, sh->sh_addralign, sh->sh_entsize); -#endif - if (sh->sh_type == SHT_SYMTAB) { - xp->sym.addr = xp->bss.addr + xp->bss.size; - xp->sym.foff = sh->sh_offset; - xp->sym.size = sh->sh_size; - if (sh->sh_link && sh->sh_link < ehdr->e_shnum && - shdr[sh->sh_link].sh_type == SHT_STRTAB) { - xp->str.foff = shdr[sh->sh_link].sh_offset; - xp->str.size = shdr[sh->sh_link].sh_size; - } - } - } - - if (!xp->sym.size || !xp->str.size) - return 0; - - if (lseek(fd, xp->sym.foff, SEEK_SET) <= 0) { -#ifdef DEBUG - printf("syms lseek: %s\n", strerror(errno)); -#endif - return -1; - } - - nl = (struct nlist *)((long *)xp->xp_end + 1); - for (ss = xp->sym.size; ss >= sizeof(elfsym); - ss -= sizeof(elfsym), nl++) { - - if (read(fd, &elfsym, sizeof(elfsym)) != sizeof(elfsym)) { -#ifdef DEBUG - printf ("read elfsym: %s\n", strerror(errno)); -#endif - return -1; - } - nl->n_un.n_strx = (long)elfsym.st_name + sizeof(int); - nl->n_value = elfsym.st_value; - nl->n_desc = 0; - nl->n_other = 0; - switch (ELF32_ST_TYPE(elfsym.st_info)) { - case STT_FILE: - nl->n_type = N_FN; - break; - case STT_FUNC: - nl->n_type = N_TEXT; - break; - case STT_OBJECT: - nl->n_type = N_DATA; - break; - case STT_NOTYPE: - if (elfsym.st_shndx == SHN_UNDEF) { - nl->n_type = N_UNDF; - break; - } else if (elfsym.st_shndx == SHN_ABS) { - nl->n_type = N_ABS; - break; - } else if (shdr[elfsym.st_shndx - 1].sh_type == - SHT_NULL) { - /* XXX this is probably bogus */ - nl->n_type = N_ABS; - break; - } else if (shdr[elfsym.st_shndx - 1].sh_type == - SHT_PROGBITS) { - /* XXX this is probably bogus */ - nl->n_type = N_BSS; - break; - } -#ifdef EXEC_DEBUG - else - printf ("sec[%d]=0x%x,val=0x%lx\n", - elfsym.st_shndx, - shdr[elfsym.st_shndx - 1].sh_type, - nl->n_value); -#endif - case STT_LOPROC: - case STT_HIPROC: - case STT_SECTION: - nl--; - continue; - - default: -#ifdef DEBUG - printf ("elf_ldsym: unknown type %d\n", - ELF32_ST_TYPE(elfsym.st_info)); -#endif - nl--; - continue; - } - switch (ELF32_ST_BIND(elfsym.st_info)) { - case STB_WEAK: - case STB_GLOBAL: - nl->n_type |= N_EXT; - break; - case STB_LOCAL: - break; - default: -#ifdef DEBUG - printf ("elf_ldsym: unknown bind %d\n", - ELF32_ST_BIND(elfsym.st_info)); -#endif - break; - } - } - - printf (" [%d", (char *)nl - (char *)xp->xp_end); - *(long *)xp->xp_end = (char *)nl - (char *)xp->xp_end - sizeof(long); - - if (lseek(fd, xp->str.foff, SEEK_SET) <= 0) { -#ifdef DEBUG - printf("strings lseek: %s\n", strerror(errno)); -#endif - return -1; - } - - *((int *)nl)++ = xp->str.size + sizeof(int); - if (read(fd, nl, xp->str.size) != xp->str.size) { -#ifdef DEBUG - printf ("read strings: %s\n", strerror(errno)); -#endif - return -1; - } - - printf ("+%d]", xp->str.size); - - xp->xp_end = ((u_int)nl + xp->str.size + 3) & ~3; - - return 0; -} - |