Date: Mon, 17 May 2004 21:56:36 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 52965 for review Message-ID: <200405180456.i4I4ua24084614@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=52965 Change 52965 by peter@peter_hammer on 2004/05/17 21:56:07 Fix last(?) outstanding bug. Even global bind symbols might have a local definition (!). Use that in preference, if it exists. While here.. eliminate padding; remove 'align' field from progtab; convert some silent failures on programming errors to panics. Affected files ... .. //depot/projects/hammer/sys/kern/link_elf_obj.c#37 edit Differences ... ==== //depot/projects/hammer/sys/kern/link_elf_obj.c#37 (text+ko) ==== @@ -61,7 +61,6 @@ typedef struct { void *addr; Elf_Off size; - int align; int flags; int sec; /* Original section */ char *name; @@ -83,7 +82,6 @@ typedef struct elf_file { struct linker_file lf; /* Common fields */ - char pad0[80]; caddr_t address; /* Relocation address */ vm_object_t object; /* VM object to hold file pages */ Elf_Shdr *e_shdr; @@ -104,7 +102,6 @@ caddr_t shstrtab; /* Section name string table */ long shstrcnt; /* number of bytes in string table */ - char pad2[80]; } *elf_file_t; @@ -503,7 +500,6 @@ bzero(ef->progtab[pb].addr, shdr[i].sh_size); } ef->progtab[pb].size = shdr[i].sh_size; - ef->progtab[pb].align = shdr[i].sh_addralign; ef->progtab[pb].sec = i; if (ef->shstrtab && shdr[i].sh_name != 0) ef->progtab[pb].name = @@ -673,7 +669,7 @@ for (i = 0; i < ef->nrel; i++) { rel = ef->reltab[i].rel; if (rel == NULL) - continue; + panic("lost a reltab!"); rellim = rel + ef->reltab[i].nrel; base = findbase(ef, ef->reltab[i].sec); for ( ; rel < rellim; rel++) { @@ -698,7 +694,7 @@ for (i = 0; i < ef->nrela; i++) { rela = ef->relatab[i].rela; if (rela == NULL) - continue; + panic("lost a relatab!"); relalim = rela + ef->relatab[i].nrela; base = findbase(ef, ef->relatab[i].sec); for ( ; rela < relalim; rela++) { @@ -872,12 +868,8 @@ sym = ef->ddbsymtab + symidx; - /* Theoretically we can avoid a lookup for some locals */ - switch (ELF_ST_BIND(sym->st_info)) { - case STB_LOCAL: - /* Local, but undefined? huh? */ - if (sym->st_shndx == SHN_UNDEF) - return (0); + /* Quick answer if there is a definition included. */ + if (sym->st_shndx != SHN_UNDEF) { ret = 0; /* Relative to section number */ for (i = 0; i < ef->nprogtab; i++) { @@ -887,7 +879,14 @@ } } return ret + sym->st_value; + } + /* If we get here, then it is undefined and needs a lookup. */ + switch (ELF_ST_BIND(sym->st_info)) { + case STB_LOCAL: + /* Local, but undefined? huh? */ + return (0); + case STB_GLOBAL: /* Relative to Data or Function name */ symbol = ef->ddbstrtab + sym->st_name; @@ -925,7 +924,7 @@ for (i = 0; i < ef->nrel; i++) { rel = ef->reltab[i].rel; if (rel == NULL) - continue; + panic("lost a reltab!"); rellim = rel + ef->reltab[i].nrel; base = findbase(ef, ef->reltab[i].sec); for ( ; rel < rellim; rel++) { @@ -945,7 +944,7 @@ for (i = 0; i < ef->nrela; i++) { rela = ef->relatab[i].rela; if (rela == NULL) - continue; + panic("lost a relatab!"); relalim = rela + ef->relatab[i].nrela; base = findbase(ef, ef->relatab[i].sec); for ( ; rela < relalim; rela++) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405180456.i4I4ua24084614>