diff options
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/ld/ld.c | 22 | ||||
-rw-r--r-- | gnu/usr.bin/ld/lib.c | 4 | ||||
-rw-r--r-- | gnu/usr.bin/ld/rtld/rtld.c | 55 | ||||
-rw-r--r-- | gnu/usr.bin/ld/warnings.c | 6 |
4 files changed, 69 insertions, 18 deletions
diff --git a/gnu/usr.bin/ld/ld.c b/gnu/usr.bin/ld/ld.c index 567b536..a11cd22 100644 --- a/gnu/usr.bin/ld/ld.c +++ b/gnu/usr.bin/ld/ld.c @@ -32,7 +32,7 @@ static char sccsid[] = "@(#)ld.c 6.10 (Berkeley) 5/22/91"; Set, indirect, and warning symbol features added by Randy Smith. */ /* - * $Id: ld.c,v 1.15 1993/12/04 00:52:56 jkh Exp $ + * $Id: ld.c,v 1.16 1993/12/11 11:58:24 jkh Exp $ */ /* Define how to initialize system-dependent header fields. */ @@ -1587,6 +1587,12 @@ digest_pass1() /* Keep count and remember symbol */ sp->setv_count++; set_vectors[setv_fill_count++] = (long)p; + if (building_shared_object) { + struct relocation_info reloc; + RELOC_ADDRESS(&reloc) = + setv_fill_count * sizeof(long); + alloc_rrs_segment_reloc(NULL, &reloc); + } } else if ((type & N_EXT) && type != (N_UNDF | N_EXT) && (type & N_TYPE) != N_FN @@ -1711,6 +1717,16 @@ digest_pass2() set_vectors[1+i+length_word_index]; set_vectors[1+i+length_word_index] = p->n_value; + if (building_shared_object) { + struct relocation_info reloc; + RELOC_ADDRESS(&reloc) = + (1 + i + length_word_index) * + sizeof(long) + + set_sect_start; + RELOC_TYPE(&reloc) = + (sp->defined & N_TYPE); + claim_rrs_segment_reloc(NULL, &reloc); + } } /* @@ -2285,8 +2301,8 @@ write_data () */ if (set_vector_count) { - swap_longs(set_vectors, 2 * set_symbol_count + set_vector_count); - mywrite (set_vectors, 2 * set_symbol_count + set_vector_count, + swap_longs(set_vectors, set_symbol_count + 2*set_vector_count); + mywrite (set_vectors, set_symbol_count + 2*set_vector_count, sizeof (unsigned long), outdesc); } diff --git a/gnu/usr.bin/ld/lib.c b/gnu/usr.bin/ld/lib.c index 46e5d46..eaa0f55 100644 --- a/gnu/usr.bin/ld/lib.c +++ b/gnu/usr.bin/ld/lib.c @@ -1,5 +1,5 @@ /* - * $Id: lib.c,v 1.6 1993/12/04 00:52:59 jkh Exp $ - library routines + * $Id: lib.c,v 1.7 1993/12/11 11:58:27 jkh Exp $ - library routines */ #include <sys/param.h> @@ -670,7 +670,7 @@ read_shared_object (desc, entry) else entry->subfiles = subentry; prev = subentry; - file_open(entry); + desc = file_open(entry); if ((offset = (off_t)lobj.lo_next) == 0) break; } diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c index fd48fb7..422646f 100644 --- a/gnu/usr.bin/ld/rtld/rtld.c +++ b/gnu/usr.bin/ld/rtld/rtld.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: rtld.c,v 1.10 1993/12/11 20:08:39 jkh Exp $ + * $Id: rtld.c,v 1.11 1993/12/11 21:06:00 jkh Exp $ */ #include <machine/vmparam.h> @@ -141,6 +141,7 @@ static void check_text_reloc __P(( struct relocation_info *, caddr_t)); static void reloc_maps __P((void)); static void reloc_copy __P((void)); +static void init_maps __P((void)); static char *rtfindlib __P((char *, int, int, int *)); void binder_entry __P((void)); long binder __P((jmpslot_t *)); @@ -216,6 +217,7 @@ struct link_dynamic *dp; /* Relocate all loaded objects according to their RRS segments */ reloc_maps(); reloc_copy(); + init_maps(); /* Fill in some field in main's __DYNAMIC structure */ crtp->crt_dp->ld_entry = &ld_entry; @@ -295,7 +297,7 @@ struct crt_ldso *crtp; printf("\t%s => %s (%#x)\n", name, path, lmp->lm_addr); } - _exit(0); + exit(0); } /* @@ -438,15 +440,18 @@ reloc_maps() check_text_reloc(r, lmp, addr); if (RELOC_EXTERN_P(r)) { - struct link_map *src_map; - struct nzlist *np; + struct link_map *src_map = NULL; + struct nzlist *p, *np; long relocation = md_get_addend(r, addr); if (RELOC_LAZY_P(r)) continue; - sym = LM_STRINGS(lmp) + - LM_SYMBOL(lmp,RELOC_SYMBOL(r))->nz_strx; + p = LM_SYMBOL(lmp,RELOC_SYMBOL(r)); + if (p->nz_type == (N_SETV + N_EXT)) + src_map = lmp; + + sym = LM_STRINGS(lmp) + p->nz_strx; np = lookup(sym, &src_map, 0/*XXX-jumpslots!*/); if (np == NULL) @@ -481,7 +486,9 @@ src_map->lm_addr, np->nz_value, sym, addr, relocation, np->nz_size); continue; } #if DEBUG -xprintf("RELOCATE(%s) external: %s at %#x, reloc = %#x\n", lmp->lm_name, sym, addr, relocation); +if (sym[2]=='_'&&(sym[3]=='C'||sym[3]=='D')&&sym[4]=='T') +xprintf("RELOCATE(%s) external: %s at %#x, reloc = %#x in %s\n", +lmp->lm_name, sym, addr, relocation, src_map?src_map->lm_name:"(NUL)"); #endif md_relocate(r, relocation, addr, 0); @@ -564,23 +571,43 @@ caddr_t addr; lmp->lm_rwt = 1; } +static void +init_maps() +{ + struct link_map *lmp, *src_map; + struct nzlist *np; + void (*func)(); + + for (lmp = link_map_head; lmp; lmp = lmp->lm_next) { + src_map = lmp; + np = lookup("___init", &src_map, 1); +#if DEBUG +if (np) +xprintf("Calling __init in %s at %#x\n", src_map->lm_name, np->nz_value+src_map->lm_addr); +#endif + if (np) { + func = (void (*)())(src_map->lm_addr + np->nz_value); + (*func)(); + } + } +} + /* * Lookup NAME in the link maps. The link map producing a definition - * is returned in SRC_MAP. If STRONG is set, the symbol returned must + * is returned in SRC_MAP. If SRC_MAP is not NULL on entry the search is + * confined to that map. If STRONG is set, the symbol returned must * have a proper type (used by binder()). */ static struct nzlist * lookup(name, src_map, strong) char *name; -struct link_map **src_map; +struct link_map **src_map; /* IN/OUT */ int strong; { long common_size = 0; struct link_map *lmp; struct rt_symbol *rtsp; - *src_map = NULL; - if ((rtsp = lookup_rts(name)) != NULL) return rtsp->rt_sp; @@ -594,6 +621,9 @@ int strong; char *cp; struct nzlist *np; + if (*src_map && lmp != *src_map) + continue; + /* * Compute bucket in which the symbol might be found. */ @@ -672,7 +702,7 @@ long binder(jsp) jmpslot_t *jsp; { - struct link_map *lmp, *src_map; + struct link_map *lmp, *src_map = NULL; long addr; char *sym; struct nzlist *np; @@ -1004,3 +1034,4 @@ char *fmt; (void)write(1, buf, strlen(buf)); va_end(ap); } + diff --git a/gnu/usr.bin/ld/warnings.c b/gnu/usr.bin/ld/warnings.c index 1e47cfd..66628de 100644 --- a/gnu/usr.bin/ld/warnings.c +++ b/gnu/usr.bin/ld/warnings.c @@ -1,5 +1,5 @@ /* - * $Id: warnings.c,v 1.2 1993/11/09 04:19:06 paul Exp $ + * $Id: warnings.c,v 1.3 1993/12/11 11:58:30 jkh Exp $ */ #include <sys/param.h> @@ -64,6 +64,10 @@ get_file_name (entry) { char *result, *supfile; + if (entry == NULL) { + return (xmalloc("NULL")); + } + if (entry->superfile) { supfile = get_file_name (entry->superfile); result = (char *) xmalloc (strlen(supfile) |