From patchwork Tue Oct 14 21:15:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 399557 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 04ECB14008E for ; Wed, 15 Oct 2014 08:15:35 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=Xft7ObaJNDJQ9wg4 +GIr+0tMHb5mKK+5W0fKlVt4XpEVaDyZZsGSRgwjXPGeV3LRLfqVRbNIDbNZLf57 aYxGXgEAfabuE2jsit0PuP5G7Z+iOfy4qcB1vHufP6qFlKn6RlnlXljOrUkF99jp me9rFLhyfzcmQCIVlXctJyrnPlg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=II463orcL7kqdCccTGFUPt PYv60=; b=HRRgFHCsxzuwvfEXdPPrGX11GWUkzAqNd7CbSCR3vefcxxFJYk9PAe f+dqZ7fv4AdcbGliZKs3BFzkzySKZy+Iusp+Z4ugU99+hh+PX5QZ7gDJaPtWtTEc p2Y4Fvv7v87QXE8AdWwoMfY1LuOpz+bAFtKShVkVKIqhsuMp3uSSc= Received: (qmail 4244 invoked by alias); 14 Oct 2014 21:15:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4234 invoked by uid 89); 14 Oct 2014 21:15:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Tue, 14 Oct 2014 22:15:17 +0100 From: "Maciej W. Rozycki" To: CC: "Joseph S. Myers" Subject: [PATCH][BZ #17485] MIPS: ld: libpthread.so: invalid string offset 2765592330 >= 5154 for section `.dynstr' Message-ID: User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Hi, This change: commit 58eb0862c3471b931bf3412d6d02bac447d5a653 Author: Roland McGrath Date: Fri Jun 27 09:58:51 2014 -0700 MIPS: Consolidate NPTL/non versions of vfork regressed MIPS builds of librt.so. Depending on how BFD linker's internals work out, which generally depends on multilib options, either an empty entry is left in the dynamic symbol table or a build failure is triggered like this: .../mips-linux-gnu/bin/ld: .../nptl/libpthread.so: invalid string offset 2765592330 >= 5154 for section `.dynstr' .../nptl/libpthread.so: could not read symbols: File format not recognized collect2: error: ld returned 1 exit status This is a bug in GNU LD and also GAS, but I think we have a bug too, in the MIPS version of pt-vfork.S, that triggers this obscure corner case. Before the change it assembled to have a symbol table like this: Symbol table '.symtab' contains 20 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 SECTION LOCAL DEFAULT 3 3: 00000000 0 SECTION LOCAL DEFAULT 4 4: 00000001 0 NOTYPE LOCAL DEFAULT ABS LOCALSZ 5: 00000018 0 NOTYPE LOCAL DEFAULT ABS FRAMESZ 6: 00000014 0 NOTYPE LOCAL DEFAULT ABS GPOFF 7: 00000000 0 SECTION LOCAL DEFAULT 11 8: 00000000 0 SECTION LOCAL DEFAULT 13 9: 00000000 0 SECTION LOCAL DEFAULT 9 10: 00000000 0 SECTION LOCAL DEFAULT 14 11: 00000000 0 SECTION LOCAL DEFAULT 16 12: 00000000 0 SECTION LOCAL DEFAULT 5 13: 00000000 0 SECTION LOCAL DEFAULT 6 14: 00000000 0 SECTION LOCAL DEFAULT 7 15: 00000000 0 SECTION LOCAL DEFAULT 18 16: 00000000 112 FUNC GLOBAL DEFAULT 1 __vfork 17: 00000000 0 OBJECT GLOBAL DEFAULT UND _gp_disp 18: 00000000 0 NOTYPE GLOBAL DEFAULT UND __syscall_error 19: 00000000 112 FUNC WEAK DEFAULT 1 vfork With the change in place the symbol table is like this instead: Symbol table '.symtab' contains 21 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 SECTION LOCAL DEFAULT 3 3: 00000000 0 SECTION LOCAL DEFAULT 4 4: 00000001 0 NOTYPE LOCAL DEFAULT ABS LOCALSZ 5: 00000018 0 NOTYPE LOCAL DEFAULT ABS FRAMESZ 6: 00000014 0 NOTYPE LOCAL DEFAULT ABS GPOFF 7: 00000000 0 SECTION LOCAL DEFAULT 11 8: 00000000 0 SECTION LOCAL DEFAULT 13 9: 00000000 0 SECTION LOCAL DEFAULT 9 10: 00000000 0 SECTION LOCAL DEFAULT 14 11: 00000000 0 SECTION LOCAL DEFAULT 16 12: 00000000 0 SECTION LOCAL DEFAULT 5 13: 00000000 0 SECTION LOCAL DEFAULT 6 14: 00000000 0 SECTION LOCAL DEFAULT 7 15: 00000000 0 SECTION LOCAL DEFAULT 18 16: 00000000 140 FUNC GLOBAL DEFAULT 1 __vfork 17: 00000000 0 OBJECT GLOBAL DEFAULT UND _gp_disp 18: 00000000 0 NOTYPE GLOBAL DEFAULT UND __syscall_error 19: 00000000 140 FUNC WEAK DEFAULT 1 vfork 20: 00000000 0 NOTYPE GLOBAL DEFAULT UND vfork@GLIBC_2.0 -- notice the undefined versioned entry for `vfork@GLIBC_2.0'. This is what confuses LD and also shouldn't have been produced by GAS in the first place. There's no further reference to that symbol, i.e. no relocation anywhere across this object file, which is why LD removes it from libpthread.so's dynsym table, however it doesn't realise early enough it shouldn't be propagating the reference to the dynsym table in the first place and as a result it leaves an uninitialised slot that may or may not be empty. The ultimate reason for this symbol's creation is a: .symver __libc_vfork, vfork@GLIBC_2.0 directive however without any `__libc_vfork' definition or reference. This is what the GAS manual has to say about this case: " For ELF targets, the `.symver' directive can be used like this: .symver NAME, NAME2@NODENAME " If the symbol NAME is not defined within the file being assembled, all references to NAME will be changed to NAME2@NODENAME. If no reference to NAME is made, NAME2@NODENAME will be removed from the symbol table." so the symbol is supposed not to be emitted. It appears though that this bug has been present in GNU binutils since forever and our other targets define `__libc_vfork', possibly just as an alias to `__vfork', so I think we should simply do the same for MIPS. The symbol does not make it to the dynsym table so such a change will not affect our ABI. The change below does exactly that, fixing the build problem. The symbol table now looks like: Symbol table '.symtab' contains 24 entries: Num: Value Size Type Bind Vis Ndx Name 0: 00000000 0 NOTYPE LOCAL DEFAULT UND 1: 00000000 0 SECTION LOCAL DEFAULT 1 2: 00000000 0 SECTION LOCAL DEFAULT 3 3: 00000000 0 SECTION LOCAL DEFAULT 4 4: 00000001 0 NOTYPE LOCAL DEFAULT ABS LOCALSZ 5: 00000018 0 NOTYPE LOCAL DEFAULT ABS FRAMESZ 6: 00000014 0 NOTYPE LOCAL DEFAULT ABS GPOFF 7: 00000000 0 SECTION LOCAL DEFAULT 11 8: 00000000 0 SECTION LOCAL DEFAULT 13 9: 00000000 0 SECTION LOCAL DEFAULT 9 10: 00000000 0 SECTION LOCAL DEFAULT 14 11: 00000000 0 SECTION LOCAL DEFAULT 16 12: 00000000 0 SECTION LOCAL DEFAULT 5 13: 00000000 0 SECTION LOCAL DEFAULT 6 14: 00000000 0 SECTION LOCAL DEFAULT 7 15: 00000000 0 SECTION LOCAL DEFAULT 18 16: 00000000 140 FUNC GLOBAL DEFAULT 1 __vfork 17: 00000000 0 OBJECT GLOBAL DEFAULT UND _gp_disp 18: 00000000 0 NOTYPE GLOBAL DEFAULT UND __syscall_error 19: 00000000 140 FUNC WEAK DEFAULT 1 vfork 20: 00000000 140 FUNC GLOBAL DEFAULT 1 __libc_vfork 21: 00000000 140 FUNC GLOBAL DEFAULT 1 __vfork_compat 22: 00000000 140 FUNC GLOBAL DEFAULT 1 vfork@GLIBC_2.0 23: 00000000 140 FUNC GLOBAL DEFAULT 1 __vfork@GLIBC_2.2 OK for trunk and 2.20 branch? 2014-10-14 Maciej W. Rozycki [BZ #17485] * sysdeps/unix/sysv/linux/mips/vfork.S (__libc_vfork): Define. Maciej glibc-mips-libc-vfork.diff Index: glibc-fsf-trunk-quilt/sysdeps/unix/sysv/linux/mips/vfork.S =================================================================== --- glibc-fsf-trunk-quilt.orig/sysdeps/unix/sysv/linux/mips/vfork.S 2014-10-13 02:18:43.000000000 +0100 +++ glibc-fsf-trunk-quilt/sysdeps/unix/sysv/linux/mips/vfork.S 2014-10-13 02:45:37.941787468 +0100 @@ -108,3 +108,4 @@ NESTED(__vfork,FRAMESZ,sp) libc_hidden_def(__vfork) weak_alias (__vfork, vfork) +strong_alias (__vfork, __libc_vfork)