map_object(name, sodp, smp) char		*name;
map_object(sodp, smp)
map_object(name, sodp, smp)	char		*name;	struct sod	*sodp;	struct so_map	*smp;{	struct _dynamic	*dp;	char		*path, *ipath;	int		fd;	caddr_t		addr;	struct exec	hdr;	int		usehints = 0;	struct so_map	*p;	if (sodp->sod_library) {		usehints = 1;again:		if (smp == NULL || no_intern_search ||		    LD_PATHS(smp->som_dynamic) == 0) {			ipath = NULL;		} else {			ipath =  LM_PATHS(smp);			add_search_path(ipath);		}		path = rtfindlib(name, sodp->sod_major,				 sodp->sod_minor, &usehints, ipath);		if (ipath)			remove_search_path(ipath);		if (path == NULL) {			errno = ENOENT;			return NULL;		}	} else {		if (careful && *name != '/') {			errno = EACCES;			return NULL;		}		path = name;	}	/* Check if already loaded */	for (p = link_map_head; p; p = p->som_next)		if (p->som_path && strcmp(p->som_path, path) == 0)			break;	if (p != NULL)		return p;	if ((fd = open(path, O_RDONLY, 0)) == -1) {		if (usehints) {			usehints = 0;			goto again;		}		return NULL;	}	if (read(fd, &hdr, sizeof(hdr)) != sizeof(hdr)) {		(void)close(fd);		/*errno = x;*/		return NULL;	}	if (N_BADMAG(hdr)) {		(void)close(fd);		errno = EFTYPE;		return NULL;	}	if ((addr = mmap(0, hdr.a_text + hdr.a_data + hdr.a_bss,	         PROT_READ|PROT_EXEC,	         MAP_COPY, fd, 0)) == (caddr_t)-1) {		(void)close(fd);		return NULL;	}	if (mprotect(addr + hdr.a_text, hdr.a_data,	    PROT_READ|PROT_WRITE|PROT_EXEC) != 0) {		(void)close(fd);		return NULL;	}	if (mmap(addr + hdr.a_text + hdr.a_data, hdr.a_bss,		 PROT_READ|PROT_WRITE|PROT_EXEC,		 MAP_ANON|MAP_COPY|MAP_FIXED,		 anon_fd, 0) == (caddr_t)-1) {		(void)close(fd);		return NULL;	}	(void)close(fd);	/* Assume _DYNAMIC is the first data item */	dp = (struct _dynamic *)(addr+hdr.a_text);	/* Fixup __DYNAMIC structure */	(long)dp->d_un.d_sdt += (long)addr;	return alloc_link_map(path, sodp, smp, addr, dp);}