From patchwork Tue Jun 2 18:04:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Fotengauer-Malinovskiy X-Patchwork-Id: 479661 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 389C7140081 for ; Wed, 3 Jun 2015 04:04:39 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=yF4bD7L5; dkim-atps=neutral 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:subject:message-id:mime-version :content-type; q=dns; s=default; b=qhsJnN2U5EvMUrRi6zH95JOgftFT5 WwwAB3LjQwvakAyYTUVIPHON7fy8JGFgMpfiM87DNNbRUfu+TmHCO47RlI/Criu7 7lTJhn57WkCSoanO7F+8duoro9+EOlZ++TqfCq2Tx4bOXTU1zRS102vRBrrpBoxo edWB+u1u1n7zTM= 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:subject:message-id:mime-version :content-type; s=default; bh=QbDOTmA+A8tgcdbfxSflTDVl1Nw=; b=yF4 bD7L51zGGaNlawwX0XBSJ1gGCGdLAP/y7qIVBhiDtqoXttGWnZu+smCYVPGi29tH c1XZFfE2V0ksBwOAc5kztkhf/rIpSgH+EspHnMNDdCIJdbmzAqQ4ok8hNA5K1mV/ OzwBT0gIoKFc3SUp1bdHK28Wzh38ZlIyWHHUpekA= Received: (qmail 122342 invoked by alias); 2 Jun 2015 18:04:20 -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 122259 invoked by uid 89); 2 Jun 2015 18:04:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: pegasus3.altlinux.org Date: Tue, 2 Jun 2015 21:04:06 +0300 From: Gleb Fotengauer-Malinovskiy To: libc-alpha@sourceware.org Subject: [PATCH] [BZ #18479]: nptl: restore .interp section in libpthread.so Message-ID: <20150602180401.GA28489@glebfm.cloud.tilaa.com> MIME-Version: 1.0 Content-Disposition: inline In commit 02657da2cf4457804ed938ee08b8316249126444, .interp section was removed from libpthread.so. This led to an error: $ /lib64/libpthread.so.0 Native POSIX Threads Library by Ulrich Drepper et al Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Forced unwind support included. Segmentation fault (gdb) bt #0 0x00000000000055a6 in _exit@plt () Since NOT_IN_* macros were removed and new IS_IN* stuff is enforced, a slightly different workaround has to be added to avoid inclusion of symbol-hacks into interp.os file. Unfortunately, there is no way to add a regression test for the bug because .interp specifies the path to dynamic linker of the target system. Tested on x86_64, x86, and armhf. [BZ #18479] * sysdeps/generic/symbol-hacks.h: Skip if NO_SYMBOL_HACKS is defined. * sysdeps/wordsize-32/symbol-hacks.h: Likewise. * elf/Makefile (CPPFLAGS-interp.c): Set to -DNO_SYMBOL_HACKS=1. * nptl/Makefile ($(objpfx)libpthread.so): Add $(+interp). Signed-off-by: Gleb Fotengauer-Malinovskiy Signed-off-by: Dmitry V. Levin --- elf/Makefile | 1 + nptl/Makefile | 1 + sysdeps/generic/symbol-hacks.h | 3 ++- sysdeps/wordsize-32/symbol-hacks.h | 3 ++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/elf/Makefile b/elf/Makefile index e5b142c..0f646a7 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -354,6 +354,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map) mv -f $@.new $@ # interp.c exists just to get the runtime linker path into libc.so. +CPPFLAGS-interp.c = -DNO_SYMBOL_HACKS=1 $(objpfx)interp.os: $(elf-objpfx)runtime-linker.h $(elf-objpfx)runtime-linker.h: $(elf-objpfx)runtime-linker.st; @: diff --git a/nptl/Makefile b/nptl/Makefile index 7c39d6d..0e546bb 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -542,6 +542,7 @@ extra-B-pthread.so = -B$(common-objpfx)nptl/ $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs)) $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs)) $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs)) +$(objpfx)libpthread.so: $(+interp) # Make sure we link with the thread library. ifeq ($(build-shared),yes) diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h index ce576c9..e2da923 100644 --- a/sysdeps/generic/symbol-hacks.h +++ b/sysdeps/generic/symbol-hacks.h @@ -1,6 +1,7 @@ /* Some compiler optimizations may transform loops into memset/memmove calls and without proper declaration it may generate PLT calls. */ -#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED +#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED \ + && !defined NO_SYMBOL_HACKS asm ("memmove = __GI_memmove"); asm ("memset = __GI_memset"); asm ("memcpy = __GI_memcpy"); diff --git a/sysdeps/wordsize-32/symbol-hacks.h b/sysdeps/wordsize-32/symbol-hacks.h index ceabb76..0bdf785 100644 --- a/sysdeps/wordsize-32/symbol-hacks.h +++ b/sysdeps/wordsize-32/symbol-hacks.h @@ -23,7 +23,8 @@ therefore we get PLTs. Unnecessarily so. Changing gcc is a big task which might not be worth it so we play tricks with the assembler. */ -#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) && defined SHARED +#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) \ + && defined SHARED && !defined NO_SYMBOL_HACKS asm ("__divdi3 = __divdi3_internal"); asm ("__udivdi3 = __udivdi3_internal"); asm ("__moddi3 = __moddi3_internal");