From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30730 invoked by alias); 16 Dec 2008 16:27:57 -0000 Received: (qmail 30720 invoked by uid 22791); 16 Dec 2008 16:27:55 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_22 X-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_22 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 16 Dec 2008 16:27:14 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 25DA110ACD; Tue, 16 Dec 2008 16:27:12 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id 0B57D10A53; Tue, 16 Dec 2008 16:27:12 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1LCclJ-0003IM-1K; Tue, 16 Dec 2008 11:27:09 -0500 Date: Tue, 16 Dec 2008 16:27:00 -0000 From: Daniel Jacobowitz To: Catherine Moore , prelink@sourceware.org, rdsandiford@googlemail.com Subject: Re: [patch] Add support for new mips relocs Message-ID: <20081216162709.GA7138@caradoc.them.org> References: <4936D3D3.6030306@codesourcery.com> <87r64pcapp.fsf@firetop.home> <20081203200226.GA28907@caradoc.them.org> <87myfdc946.fsf@firetop.home> <20081203202906.GA30422@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20081203202906.GA30422@caradoc.them.org> User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes Mailing-List: contact prelink-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: prelink-owner@sourceware.org X-SW-Source: 2008-q4/txt/msg00006.txt.bz2 On Wed, Dec 03, 2008 at 03:29:06PM -0500, Daniel Jacobowitz wrote: > There's only one use in all of prelink that I can find: in the C++ > vtable optimizer. I don't fully understand that code, but it seems > quite possible the patch will pessimize some binaries that would > previously have had fewer conflicts. Not sure what to do about > that... adjust the check at cxx.c:334 to handle STO_MIPS_PLT > if EM_MIPS? I tried, but I'm having trouble checking. The patched prelink can eliminate vtable conflicts on non-PIC MIPS executables, but not on PIC MIPS executables. The unpatched prelink can't handle this filesystem at all, probably because its ld.so uses the non-PLT relocation class in trace output. I can't find a filesystem image around here that has prelink support but not non-PIC support to test. The above is worth restating: prelink without the patch Catherine posted does not work with current CVS glibc. I'd recommend Catherine's patch plus the attached, for safety purposes. This may lose the ability to remove C++ conflicts from MIPS PIC executables. I've spent all morning trying to come up with a way to have our cake and eat it too, and so far the adage is holding true; I can't do it. The cxx.c code is written to make assumptions based on relocation class, but that doesn't work here. It wants to find "PLT-like" relocations, but whether R_MIPS_REL32 is PLT-like depends on what symbols are found during the lookup process. Richard, do you have any ideas? If not, is this good enough? If so, Jakub, are the patches OK? -- Daniel Jacobowitz CodeSourcery 2008-12-16 Daniel Jacobowitz * src/dso.c (adjust_symbol_p): Do not adjust MIPS PLT entries. * src/cxx.c (create_cache, check_pltref): Do not treat MIPS lazy binding stubs as PLT entries. Index: mips/src/dso.c =================================================================== --- mips.orig/src/dso.c 2008-12-16 09:51:21.000000000 -0500 +++ mips/src/dso.c 2008-12-16 09:35:11.000000000 -0500 @@ -1045,7 +1045,8 @@ adjust_symbol_p (DSO *dso, GElf_Sym *sym address. */ if (dso->ehdr.e_machine == EM_MIPS && sym->st_shndx == SHN_UNDEF - && sym->st_value != 0) + && sym->st_value != 0 + && (sym->st_other & STO_MIPS_PLT) == 0) return 1; return (sym->st_shndx > SHN_UNDEF Index: mips/src/cxx.c =================================================================== --- mips.orig/src/cxx.c 2008-12-16 09:43:52.000000000 -0500 +++ mips/src/cxx.c 2008-12-16 09:48:43.000000000 -0500 @@ -137,6 +137,12 @@ create_cache (DSO *dso, int plt) { if (sym.st_shndx != SHN_UNDEF || sym.st_value == 0) continue; + /* On MIPS, undefined symbols with a value (but without + STO_MIPS_PLT) are lazy binding stubs. They do not + participate in symbol resolution. */ + if (dso->ehdr.e_machine == EM_MIPS + && !(sym.st_other & STO_MIPS_PLT)) + continue; } else if (sym.st_shndx == SHN_UNDEF) continue; @@ -527,7 +533,9 @@ check_pltref: mid++; gelfx_getsym (info->dso->elf, binsymtab, ndx, &sym); assert (sym.st_value == info->conflict_rela[i].r_addend); - if (sym.st_shndx == SHN_UNDEF && sym.st_value) + if (sym.st_shndx == SHN_UNDEF && sym.st_value + && (info->dso->ehdr.e_machine != EM_MIPS + || (sym.st_other & STO_MIPS_PLT))) { struct prelink_symbol *s; size_t maxidx, l;