From owner-p4-projects@FreeBSD.ORG Thu Apr 1 19:12:20 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A28F716A4D0; Thu, 1 Apr 2004 19:12:20 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 77C3F16A4CE for ; Thu, 1 Apr 2004 19:12:20 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5827A43D54 for ; Thu, 1 Apr 2004 19:12:20 -0800 (PST) (envelope-from peter@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i323CKGe037057 for ; Thu, 1 Apr 2004 19:12:20 -0800 (PST) (envelope-from peter@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i323CJXR037048 for perforce@freebsd.org; Thu, 1 Apr 2004 19:12:19 -0800 (PST) (envelope-from peter@freebsd.org) Date: Thu, 1 Apr 2004 19:12:19 -0800 (PST) Message-Id: <200404020312.i323CJXR037048@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter@freebsd.org using -f From: Peter Wemm To: Perforce Change Reviews Subject: PERFORCE change 50161 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Apr 2004 03:12:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=50161 Change 50161 by peter@peter_hammer on 2004/04/01 19:12:15 checkpoint. beginnings of actually implementing real elf object linkage. oops. ld -shared made things easy for us and a bunch of relocation modes are missing. Affected files ... .. //depot/projects/hammer/sys/kern/link_elf_obj.c#20 edit Differences ... ==== //depot/projects/hammer/sys/kern/link_elf_obj.c#20 (text+ko) ==== @@ -881,7 +881,7 @@ elf_file_t ef = (elf_file_t)lf; const Elf_Sym *sym; const char *symbol; - int error; + Elf_addr ret; printf("elf_obj_lookup: symidx %ld (< %ld?)\n", symidx, ef->ddbsymcnt); @@ -892,36 +892,35 @@ sym = ef->ddbsymtab + symidx; printf("sym: %p (base %p)\n", sym, ef->ddbsymtab); - /* - * Don't do a full lookup when the symbol is local. It may even - * fail because it may not be found through the hash table. - */ - if (ELF_ST_BIND(sym->st_info) == STB_LOCAL) { - /* Force lookup failure when we have an insanity. */ - if (sym->st_shndx == SHN_UNDEF) - return (0); - return ((Elf_Addr)ef->address + sym->st_value); +#if 0 + /* Theoretically we can avoid a lookup for some locals */ + switch (ELF64_ST_BIND(sym->st_info)) { + case STB_LOCAL: + case STB_GLOBAL: + case STB_WEAK: } - - /* - * XXX we can avoid doing a hash table based lookup for global - * symbols as well. This however is not always valid, so we'll - * just do it the hard way for now. Performance tweaks can - * always be added. - */ - - symbol = ef->ddbstrtab + sym->st_name; +#endif + switch (ELF64_ST_TYPE(sym->st_info)) { + case STT_OBJECT: + case STT_FUNC: + /* Relative to Data or Function name */ + symbol = ef->ddbstrtab + sym->st_name; printf("strtab %p, st_name %d\n", ef->ddbstrtab, sym->st_name); printf("symbol = %p (%s)\n", symbol, symbol); - /* Force a lookup failure if the symbol name is bogus. */ - if (*symbol == 0) - return (0); + /* Force a lookup failure if the symbol name is bogus. */ + if (*symbol == 0) + return (0); printf("calling linker_file_lookup_symbol, deps %d\n", deps); - error = ((Elf_Addr)linker_file_lookup_symbol(lf, symbol, deps)); -printf("linker_file_lookup_symbol returns %d\n", error); - return error; + ret = ((Elf_Addr)linker_file_lookup_symbol(lf, symbol, deps)); +printf("linker_file_lookup_symbol returns %p\n", ret); + return ret; + + case STT_SECTION: + /* Relative to section number */ + XXX + } } static void