From owner-svn-src-all@FreeBSD.ORG Fri Oct 10 05:10:11 2008 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B5B9106568C; Fri, 10 Oct 2008 05:10:11 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3BD0E8FC19; Fri, 10 Oct 2008 05:10:11 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id m9A5AA3g083466; Fri, 10 Oct 2008 05:10:10 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id m9A5AAnM083465; Fri, 10 Oct 2008 05:10:10 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200810100510.m9A5AAnM083465@svn.freebsd.org> From: Warner Losh Date: Fri, 10 Oct 2008 05:10:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r183739 - head/libexec/rtld-elf/mips X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Oct 2008 05:10:11 -0000 Author: imp Date: Fri Oct 10 05:10:10 2008 New Revision: 183739 URL: http://svn.freebsd.org/changeset/base/183739 Log: MFp4: Fix a bug in the mips relocation code that prevents shared images from working. From p4 filelog of the upstream file in p4 //depot/projects/mips2-jnpr/src/libexec/rtld-elf/mips/reloc.c ... #6 change 140737 edit on 2008/04/27 by gonzo@gonzo_jeeves (text+ko) o Looks like handler for R_MIPS_REL32 brought by CS 137942 is broken for tradmips. Code from NetBSD's libexec/ld.elf_so/arch/mips/mips_reloc.c works just fine. ... #3 change 137942 edit on 2008/03/17 by rrs@rrs-mips2-jnpr (text+ko) Any relocation symbol lookup if its 0. It looks like this is the way the compiler indicates you need to look in another shared library. When we hit these as we relocate a object we will do the symbol lookups and setup the relocation table with the right value. Submitted by: rrs@, gonzo@ Modified: head/libexec/rtld-elf/mips/reloc.c Modified: head/libexec/rtld-elf/mips/reloc.c ============================================================================== --- head/libexec/rtld-elf/mips/reloc.c Fri Oct 10 04:23:40 2008 (r183738) +++ head/libexec/rtld-elf/mips/reloc.c Fri Oct 10 05:10:10 2008 (r183739) @@ -258,31 +258,23 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry case R_TYPE(REL32): /* 32-bit PC-relative reference */ def = obj->symtab + symnum; - tmp = load_ptr(where); - if (tmp == 0) { - def = find_symdef(symnum, obj, &defobj, false, NULL); - if (def == NULL) { - dbg("Warning5, cant find symbole %d:%s", (int)symnum, - obj->strtab + obj->symtab[symnum].st_name); - } else { - tmp = def->st_value + (Elf_Addr)defobj->relocbase; - dbg("Correctiong symnum:%d:%s to addr:%x", (int)symnum, - obj->strtab + obj->symtab[symnum].st_name, - (u_int32_t)tmp - ); - } + if (symnum >= obj->gotsym) { + tmp = load_ptr(where); + tmp += got[obj->local_gotno + symnum - obj->gotsym]; + store_ptr(where, tmp); + break; } else { - tmp += (Elf_Addr)obj->relocbase; - } - store_ptr(where, tmp); - if (tmp == (Elf_Addr)obj->relocbase) { - dbg("rel sym %p falls on relocbase symidx:%x symbol:%s", rel, - (uint32_t)ELF_R_SYM(rel->r_info), - obj->strtab + obj->symtab[symnum].st_name - ); + tmp = load_ptr(where); + + if (def->st_info == + ELF_ST_INFO(STB_LOCAL, STT_SECTION) + ) + tmp += (Elf_Addr)def->st_value; + + tmp += (Elf_Addr)obj->relocbase; + store_ptr(where, tmp); } break; - default: dbg("sym = %lu, type = %lu, offset = %p, " "contents = %p, symbol = %s",