From patchwork Wed Oct 4 01:13:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 23319 Received: (qmail 120693 invoked by alias); 4 Oct 2017 01:13:28 -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 120667 invoked by uid 89); 4 Oct 2017 01:13:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-oi0-f68.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=HhMpurrMj5fr0HT1AMf6uciPPd+bOwuDY8E5hQP5h9g=; b=KGSuWOdU5hrZEP1RwuuM6XBCRB6ZjyBfimpyAbacVZvKxMvGM6DPqcyHuaQMCJRtfo YYCHlW8tmBEpRoXbgmumDo9ApsT5ayVu70ogiRFT+SA+0U5qonOhX65rCqq5xneAFLfz qOsGxtZ6HpKYFt1otdLGfc7eET++WBJ4vTGwn4+1FB8MoUeJ1egx0nJX+iIGRgkGXj0T Xu9XfQLdAtQxnnzklwVscvTD28RcvWD5vPyEuOsktqGqDeXdh0u+rNTUSeiyQWzEI+TV OieSUanDkKacjR04y7DmzFsyBwaUCPHOCsFMxYb46E+HIftMwlfXyMpYyK2JGyOq8z+P h8uw== X-Gm-Message-State: AMCzsaURmTZ796IhIc+FJSOy5IVXYPkkios0oXOUx2jRtHFkpQW+k0sr VCT1KCbDNCS37XF8y9OB89etBGXcBygllAsVtk8= X-Google-Smtp-Source: AOwi7QAkLjBVczXpyVAQjo7FcyarhdKkv6OJKJcIOUBbZNuUD2tOdlfzMifgcQylDxptYB66j5UqAfxUvVySjsgs0So= X-Received: by 10.202.61.193 with SMTP id k184mr9733596oia.10.1507079603190; Tue, 03 Oct 2017 18:13:23 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20171003224751.GA23183@gmail.com> References: <20171003224751.GA23183@gmail.com> From: "H.J. Lu" Date: Tue, 3 Oct 2017 18:13:22 -0700 Message-ID: Subject: Re: [PATCH] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc To: GNU C Library On 10/3/17, H.J. Lu wrote: > Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient > when static PIE is built by default. Use $(DEFAULT-LDFLAGS-$(@F)) in > +link-static-before-libc to make sure that tst-tls1-static-non-pie is > always built as non-PIE static executable. > > Any comments? > > H.J. > --- > * Makeconfig (+link-static-before-libc): Use > $(DEFAULT-LDFLAGS-$(@F)). > * elf/Makefile (LDFLAGS-tst-tls1-static-non-pie): Renamed to ... > (DEFAULT-LDFLAGS-tst-tls1-static-non-pie): This. > --- > Makeconfig | 1 + > elf/Makefile | 2 +- > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/Makeconfig b/Makeconfig > index b51904b797..0ceff92a3d 100644 > --- a/Makeconfig > +++ b/Makeconfig > @@ -435,6 +435,7 @@ endif > # Command for statically linking programs with the C library. > ifndef +link-static > +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \ > + $(DEFAULT-LDFLAGS-$(@F)) \ > $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ > $(addprefix $(csu-objpfx),$(static-start-installed-name)) \ > $(+preinit) $(+prectorT) \ > diff --git a/elf/Makefile b/elf/Makefile > index c6edebd4ee..06e2e4cd08 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -152,7 +152,7 @@ tests-static-internal := tst-tls1-static tst-tls2-static > \ > tst-ptrguard1-static tst-stackguard1-static \ > tst-tls1-static-non-pie > > -LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag) > +DEFAULT-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag) > > tests := tst-tls9 tst-leaks1 \ > tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \ Here is the updated patch to add +CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o so that crt1.o is always used. From a0b9dd6c93d349722f7266aac8e5f27686b8cbbe Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 3 Oct 2017 15:02:19 -0700 Subject: [PATCH 01/14] Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc Use $(LDFLAGS-$(@F)) with tst-tls1-static-non-pie may not be sufficient when static PIE is built by default. Use $(DEFAULT-LDFLAGS-$(@F)) in +link-static-before-libc to make sure that tst-tls1-static-non-pie is always built as non-PIE static executable and make sure that crt1.o is used with tst-tls1-static-non-pie. * Makeconfig (+link-static-before-libc): Use $(DEFAULT-LDFLAGS-$(@F)). * elf/Makefile (CRT-tst-tls1-static-non-pie): New. (LDFLAGS-tst-tls1-static-non-pie): Renamed to ... (DEFAULT-LDFLAGS-tst-tls1-static-non-pie): This. --- Makeconfig | 1 + elf/Makefile | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makeconfig b/Makeconfig index b51904b797..0ceff92a3d 100644 --- a/Makeconfig +++ b/Makeconfig @@ -435,6 +435,7 @@ endif # Command for statically linking programs with the C library. ifndef +link-static +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \ + $(DEFAULT-LDFLAGS-$(@F)) \ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ $(addprefix $(csu-objpfx),$(static-start-installed-name)) \ $(+preinit) $(+prectorT) \ diff --git a/elf/Makefile b/elf/Makefile index c6edebd4ee..d1c61a12ca 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -152,7 +152,8 @@ tests-static-internal := tst-tls1-static tst-tls2-static \ tst-ptrguard1-static tst-stackguard1-static \ tst-tls1-static-non-pie -LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag) +CRT-tst-tls1-static-non-pie := $(csu-objpfx)crt1.o +DEFAULT-LDFLAGS-tst-tls1-static-non-pie = $(no-pie-ldflag) tests := tst-tls9 tst-leaks1 \ tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \ -- 2.13.6