From patchwork Tue Jan 13 14:26:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 4644 Received: (qmail 26662 invoked by alias); 13 Jan 2015 14:26:13 -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 26643 invoked by uid 89); 13 Jan 2015 14:26:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f169.google.com X-Received: by 10.236.63.6 with SMTP id z6mr27331803yhc.65.1421159163940; Tue, 13 Jan 2015 06:26:03 -0800 (PST) Date: Tue, 13 Jan 2015 06:26:00 -0800 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] [BZ #17836]: -pg -pie doesn't work on x86-64 Message-ID: <20150113142600.GA13662@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) We compile gcrt1.o with -fPIC to support both "gcc -pg" and "gcc -pie -pg". Tested on x86-64, i686 and x32. OK for trunk after 2.21 is released? H.J. --- [BZ #17836] * csu/Makefile (extra-objs): Add gmon-start.o if not builing shared library. Add gmon-start.os otherwise. ($(objpfx)g$(start-installed-name)): Use $(objpfx)S% $(objpfx)gmon-start.os if builing shared library. ($(objpfx)g$(static-start-installed-name)): Likewise. --- csu/Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/csu/Makefile b/csu/Makefile index f7cf4af..9f0855a 100644 --- a/csu/Makefile +++ b/csu/Makefile @@ -32,7 +32,7 @@ aux = errno elide-routines.os = libc-tls static-only-routines = elf-init csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o) -extra-objs = start.o gmon-start.o \ +extra-objs = start.o \ $(start-installed-name) g$(start-installed-name) $(csu-dummies) \ S$(start-installed-name) omit-deps = $(patsubst %.o,%,$(start-installed-name) g$(start-installed-name) \ @@ -46,9 +46,11 @@ tests := tst-empty tst-atomic tst-atomic-long tests-static := tst-empty ifeq (yes,$(build-shared)) -extra-objs += S$(start-installed-name) +extra-objs += S$(start-installed-name) gmon-start.os install-lib += S$(start-installed-name) generated += start.os +else +extra-objs += gmon-start.o endif ifneq ($(start-installed-name),$(static-start-installed-name)) @@ -95,10 +97,17 @@ endif # The profiling startfile is made by linking together the normal # startfile with gmon-start.o, which defines a constructor function # to turn on profiling code at startup. +ifeq (yes,$(build-shared)) +$(addprefix $(objpfx),$(sort g$(start-installed-name) \ + g$(static-start-installed-name))): \ + $(objpfx)g%: $(objpfx)S% $(objpfx)gmon-start.os + $(link-relocatable) +else $(addprefix $(objpfx),$(sort g$(start-installed-name) \ g$(static-start-installed-name))): \ $(objpfx)g%: $(objpfx)% $(objpfx)gmon-start.o $(link-relocatable) +endif # These extra files are sometimes expected by system standard linking # procedures, but we have nothing for them to do. So compile empty files.