Bug 22630 - $(no-pie-ldflag) is no longer effective
Summary: $(no-pie-ldflag) is no longer effective
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: 2.27
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-18 22:23 UTC by H.J. Lu
Modified: 2018-03-31 12:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2017-12-18 22:23:36 UTC
commit 9d7a3741c9e59eba87fb3ca6b9f979befce07826
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Dec 15 16:59:33 2017 -0800

    Add --enable-static-pie configure option to build static PIE [BZ #19574]

and

commit 00c714df398b63934540d95ce3792596f7a94a6c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 18 12:24:26 2017 -0800

    Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614]

$(no-pie-ldflag) is no longer effective since no-pie-ldflag is defined
to -no-pie only if GCC defaults to PIE.  When --enable-static-pie is
used to configure glibc build and GCC doesn't default to PIE. no-pie-ldflag
is undefined and these tests:

elf/Makefile:LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
elf/Makefile:LDFLAGS-tst-prelink = $(no-pie-ldflag)
elf/Makefile:LDFLAGS-tst-main1 = $(no-pie-ldflag)
gmon/Makefile:LDFLAGS-tst-gmon := $(no-pie-ldflag)

may fail to link.
Comment 1 Sourceware Commits 2017-12-18 23:03:54 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pie/static has been created
        at  09e96bf7aa81e7b55dc8f96c1cd0a88a0952d8b0 (commit)

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=09e96bf7aa81e7b55dc8f96c1cd0a88a0952d8b0

commit 09e96bf7aa81e7b55dc8f96c1cd0a88a0952d8b0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 18 14:05:07 2017 -0800

    Replece LDFLAGS-* = $(no-pie-ldflag) with tst-*-no-pie = yes [BZ #22630]
    
    After
    
    commit 9d7a3741c9e59eba87fb3ca6b9f979befce07826
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Fri Dec 15 16:59:33 2017 -0800
    
        Add --enable-static-pie configure option to build static PIE [BZ #19574]
    
    and
    
    commit 00c714df398b63934540d95ce3792596f7a94a6c
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Mon Dec 18 12:24:26 2017 -0800
    
        Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614]
    
    $(no-pie-ldflag) is no longer effective since no-pie-ldflag is defined
    to -no-pie only if GCC defaults to PIE.  When --enable-static-pie is
    used to configure glibc build and GCC doesn't default to PIE. no-pie-ldflag
    is undefined and these tests:
    
    elf/Makefile:LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
    elf/Makefile:LDFLAGS-tst-prelink = $(no-pie-ldflag)
    elf/Makefile:LDFLAGS-tst-main1 = $(no-pie-ldflag)
    gmon/Makefile:LDFLAGS-tst-gmon := $(no-pie-ldflag)
    
    may fail to link.  This patch "-pie" with
    
    $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie)
    
    and uses
    
    repleces
    
    LDFLAGS-* = $(no-pie-ldflag)
    
    with tst-*-no-pie = yes
    
    so that tst-dlopen-aout, tst-prelink, tst-main1 and tst-gmon are always
    built as non-PIE, with and without --enable-static-pie, using GCC
    defaulting to PIE or non-PIE.
    
    Tested with build-many-glibcs.py without --enable-static-pie as well as
    with --enable-static-pie for x86_64, x32 and i686.
    
    	[BZ #22630]
    	* Makeconfig (link-pie-before-libc): Replace -pie with
    	$(if $($(@F)-no-pie),$(no-pie-ldflag),-pie).
    	* elf/Makefile (LDFLAGS-tst-dlopen-aout): Removed.
    	(tst-dlopen-aout-no-pie): New.
    	(LDFLAGS-tst-prelink): Removed.
    	(tst-prelink-no-pie): New.
    	(LDFLAGS-tst-main1): Removed.
    	(tst-main1-no-pie): New.
    	* gmon/Makefile (LDFLAGS-tst-gmon): Removed.
    	(tst-gmon-no-pie): New.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=35a594236fda3eb5a05bdea7e1bff37a8ffa7657

commit 35a594236fda3eb5a05bdea7e1bff37a8ffa7657
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 27 16:47:29 2017 -0700

    Add --enable-static-pie variants to x86_64, x32 and i686
    
    Since the default GCC and binutils versions used by build-many-glibcs.py,
    which are GCC 7 branch and binutils 2.29 branch, this patch adds
    --enable-static-pie glibc variants to x86_64, x32 and i686.
    
    Tested with build-many-glibcs.py.
    
    	* scripts/build-many-glibcs.py (Context.add_all_configs): Add
    	--enable-static-pie variants to x86_64, x32 and i686.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=27ea6ee71a7319eabe18a133bbbd6da43caf74db

commit 27ea6ee71a7319eabe18a133bbbd6da43caf74db
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 16:13:54 2017 -0700

    sparc: Check PIC instead of SHARED in start.S
    
    Since start.o may be compiled as PIC, we should check PIC instead of
    SHARED.
    
    	* sysdeps/sparc/sparc32/start.S (_start): Check PIC instead of
    	SHARED.
    	* sysdeps/sparc/sparc64/start.S (_start): Likewise.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4a3b974ab7a5d90b16dcee699f52046905edd9a4

commit 4a3b974ab7a5d90b16dcee699f52046905edd9a4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 16:13:22 2017 -0700

    microblaze: Check PIC instead of SHARED in start.S
    
    Since start.o may be compiled as PIC, we should check PIC instead of
    SHARED.
    
    	* sysdeps/microblaze/start.S (_start): Check PIC instead of SHARED.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=13e37fa5bb1ad8714270a012fa646969238589ef

commit 13e37fa5bb1ad8714270a012fa646969238589ef
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 14:55:18 2017 -0700

    sh: Update elf_machine_load_address for static PIE
    
    When --enable-static-pie is used to configure glibc, we need to use
    _dl_relocate_static_pie to compute load address in static PIE.
    
    	* sysdeps/sh/dl-machine.h (elf_machine_load_address): Use
    	_dl_relocate_static_pie instead of _dl_start to compute load
    	address in static PIE.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4844933a9a0b3d36759fdcecf63f7d679dc9cf3c

commit 4844933a9a0b3d36759fdcecf63f7d679dc9cf3c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 14:53:06 2017 -0700

    s390: Update elf_machine_load_address for static PIE
    
    When --enable-static-pie is used to configure glibc, we need to use
    _dl_relocate_static_pie to compute load address in static PIE.
    
    	* sysdeps/s390/s390-32/dl-machine.h (elf_machine_dynamic): Use
    	_dl_relocate_static_pie instead of _dl_start to compute load
    	address in static PIE.
    	* sysdeps/s390/s390-64/dl-machine.h (elf_machine_dynamic):
    	Likewise.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bfbc0341f3a05dd0c8940743d3dad60ea1226295

commit bfbc0341f3a05dd0c8940743d3dad60ea1226295
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Dec 1 09:49:25 2017 -0800

    nios2: Don't use MIN in dl-machine.h
    
    MIN is used, but param.h may not be included, so expand its single use
    inline.
    
    	* sysdeps/nios2/dl-machine.h (elf_machine_rela): Expand MIN.

-----------------------------------------------------------------------
Comment 2 Sourceware Commits 2017-12-19 00:01:09 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pie/static has been deleted
       was  09e96bf7aa81e7b55dc8f96c1cd0a88a0952d8b0

- Log -----------------------------------------------------------------
09e96bf7aa81e7b55dc8f96c1cd0a88a0952d8b0 Replece LDFLAGS-* = $(no-pie-ldflag) with tst-*-no-pie = yes [BZ #22630]
-----------------------------------------------------------------------
Comment 3 Sourceware Commits 2017-12-19 00:01:20 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pie/static has been created
        at  7e29e9f2beed0a108951f1b4c7543fe39ff1da1a (commit)

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7e29e9f2beed0a108951f1b4c7543fe39ff1da1a

commit 7e29e9f2beed0a108951f1b4c7543fe39ff1da1a
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Dec 18 14:05:07 2017 -0800

    Replece LDFLAGS-* = $(no-pie-ldflag) with tst-*-no-pie = yes [BZ #22630]
    
    After
    
    commit 9d7a3741c9e59eba87fb3ca6b9f979befce07826
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Fri Dec 15 16:59:33 2017 -0800
    
        Add --enable-static-pie configure option to build static PIE [BZ #19574]
    
    and
    
    commit 00c714df398b63934540d95ce3792596f7a94a6c
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Mon Dec 18 12:24:26 2017 -0800
    
        Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614]
    
    $(no-pie-ldflag) is no longer effective since no-pie-ldflag is defined
    to -no-pie only if GCC defaults to PIE.  When --enable-static-pie is
    used to configure glibc build and GCC doesn't default to PIE. no-pie-ldflag
    is undefined and these tests:
    
    elf/Makefile:LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
    elf/Makefile:LDFLAGS-tst-prelink = $(no-pie-ldflag)
    elf/Makefile:LDFLAGS-tst-main1 = $(no-pie-ldflag)
    gmon/Makefile:LDFLAGS-tst-gmon := $(no-pie-ldflag)
    
    may fail to link.  This patch replaces "-pie" with
    
    $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie)
    
    and repleces
    
    LDFLAGS-* = $(no-pie-ldflag)
    
    with
    
    tst-*-no-pie = yes
    
    so that tst-dlopen-aout, tst-prelink, tst-main1 and tst-gmon are always
    built as non-PIE, with and without --enable-static-pie, regardless if
    GCC defaults to PIE or non-PIE.
    
    Tested with build-many-glibcs.py without --enable-static-pie as well as
    with --enable-static-pie for x86_64, x32 and i686.
    
    	[BZ #22630]
    	* Makeconfig (link-pie-before-libc): Replace -pie with
    	$(if $($(@F)-no-pie),$(no-pie-ldflag),-pie).
    	* elf/Makefile (LDFLAGS-tst-dlopen-aout): Removed.
    	(tst-dlopen-aout-no-pie): New.
    	(LDFLAGS-tst-prelink): Removed.
    	(tst-prelink-no-pie): New.
    	(LDFLAGS-tst-main1): Removed.
    	(tst-main1-no-pie): New.
    	* gmon/Makefile (LDFLAGS-tst-gmon): Removed.
    	(tst-gmon-no-pie): New.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=35a594236fda3eb5a05bdea7e1bff37a8ffa7657

commit 35a594236fda3eb5a05bdea7e1bff37a8ffa7657
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Sep 27 16:47:29 2017 -0700

    Add --enable-static-pie variants to x86_64, x32 and i686
    
    Since the default GCC and binutils versions used by build-many-glibcs.py,
    which are GCC 7 branch and binutils 2.29 branch, this patch adds
    --enable-static-pie glibc variants to x86_64, x32 and i686.
    
    Tested with build-many-glibcs.py.
    
    	* scripts/build-many-glibcs.py (Context.add_all_configs): Add
    	--enable-static-pie variants to x86_64, x32 and i686.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=27ea6ee71a7319eabe18a133bbbd6da43caf74db

commit 27ea6ee71a7319eabe18a133bbbd6da43caf74db
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 16:13:54 2017 -0700

    sparc: Check PIC instead of SHARED in start.S
    
    Since start.o may be compiled as PIC, we should check PIC instead of
    SHARED.
    
    	* sysdeps/sparc/sparc32/start.S (_start): Check PIC instead of
    	SHARED.
    	* sysdeps/sparc/sparc64/start.S (_start): Likewise.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4a3b974ab7a5d90b16dcee699f52046905edd9a4

commit 4a3b974ab7a5d90b16dcee699f52046905edd9a4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 16:13:22 2017 -0700

    microblaze: Check PIC instead of SHARED in start.S
    
    Since start.o may be compiled as PIC, we should check PIC instead of
    SHARED.
    
    	* sysdeps/microblaze/start.S (_start): Check PIC instead of SHARED.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=13e37fa5bb1ad8714270a012fa646969238589ef

commit 13e37fa5bb1ad8714270a012fa646969238589ef
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 14:55:18 2017 -0700

    sh: Update elf_machine_load_address for static PIE
    
    When --enable-static-pie is used to configure glibc, we need to use
    _dl_relocate_static_pie to compute load address in static PIE.
    
    	* sysdeps/sh/dl-machine.h (elf_machine_load_address): Use
    	_dl_relocate_static_pie instead of _dl_start to compute load
    	address in static PIE.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4844933a9a0b3d36759fdcecf63f7d679dc9cf3c

commit 4844933a9a0b3d36759fdcecf63f7d679dc9cf3c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Sep 28 14:53:06 2017 -0700

    s390: Update elf_machine_load_address for static PIE
    
    When --enable-static-pie is used to configure glibc, we need to use
    _dl_relocate_static_pie to compute load address in static PIE.
    
    	* sysdeps/s390/s390-32/dl-machine.h (elf_machine_dynamic): Use
    	_dl_relocate_static_pie instead of _dl_start to compute load
    	address in static PIE.
    	* sysdeps/s390/s390-64/dl-machine.h (elf_machine_dynamic):
    	Likewise.

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bfbc0341f3a05dd0c8940743d3dad60ea1226295

commit bfbc0341f3a05dd0c8940743d3dad60ea1226295
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Dec 1 09:49:25 2017 -0800

    nios2: Don't use MIN in dl-machine.h
    
    MIN is used, but param.h may not be included, so expand its single use
    inline.
    
    	* sysdeps/nios2/dl-machine.h (elf_machine_rela): Expand MIN.

-----------------------------------------------------------------------
Comment 4 H.J. Lu 2017-12-19 16:58:19 UTC
A patch is posted at

https://sourceware.org/ml/libc-alpha/2017-12/msg00613.html
Comment 5 Sourceware Commits 2017-12-19 21:54:02 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  ce16eb52c0987fd94bc13d51ddc787134a7e4b0c (commit)
      from  126adc89d8a32193df075ce665e76ad95ebd0557 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ce16eb52c0987fd94bc13d51ddc787134a7e4b0c

commit ce16eb52c0987fd94bc13d51ddc787134a7e4b0c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Dec 19 13:53:00 2017 -0800

    Replece LDFLAGS-* = $(no-pie-ldflag) with tst-*-no-pie = yes [BZ #22630]
    
    After
    
    commit 9d7a3741c9e59eba87fb3ca6b9f979befce07826
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Fri Dec 15 16:59:33 2017 -0800
    
        Add --enable-static-pie configure option to build static PIE [BZ #19574]
    
    and
    
    commit 00c714df398b63934540d95ce3792596f7a94a6c
    Author: H.J. Lu <hjl.tools@gmail.com>
    Date:   Mon Dec 18 12:24:26 2017 -0800
    
        Pass -no-pie to GCC only if GCC defaults to PIE [BZ #22614]
    
    $(no-pie-ldflag) is no longer effective since no-pie-ldflag is defined
    to -no-pie only if GCC defaults to PIE.  When --enable-static-pie is
    used to configure glibc build and GCC doesn't default to PIE. no-pie-ldflag
    is undefined and these tests:
    
    elf/Makefile:LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag)
    elf/Makefile:LDFLAGS-tst-prelink = $(no-pie-ldflag)
    elf/Makefile:LDFLAGS-tst-main1 = $(no-pie-ldflag)
    gmon/Makefile:LDFLAGS-tst-gmon := $(no-pie-ldflag)
    
    may fail to link.  This patch replaces "-pie" with
    
    $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie)
    
    and repleces
    
    LDFLAGS-* = $(no-pie-ldflag)
    
    with
    
    tst-*-no-pie = yes
    
    so that tst-dlopen-aout, tst-prelink, tst-main1 and tst-gmon are always
    built as non-PIE, with and without --enable-static-pie, regardless if
    GCC defaults to PIE or non-PIE.
    
    Tested with build-many-glibcs.py without --enable-static-pie as well as
    with --enable-static-pie for x86_64, x32 and i686.
    
    	[BZ #22630]
    	* Makeconfig (link-pie-before-libc): Replace -pie with
    	$(if $($(@F)-no-pie),$(no-pie-ldflag),-pie).
    	* elf/Makefile (LDFLAGS-tst-dlopen-aout): Removed.
    	(tst-dlopen-aout-no-pie): New.
    	(LDFLAGS-tst-prelink): Removed.
    	(tst-prelink-no-pie): New.
    	(LDFLAGS-tst-main1): Removed.
    	(tst-main1-no-pie): New.
    	* gmon/Makefile (LDFLAGS-tst-gmon): Removed.
    	(tst-gmon-no-pie): New.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog     |   14 ++++++++++++++
 Makeconfig    |    3 ++-
 elf/Makefile  |    6 +++---
 gmon/Makefile |    2 +-
 4 files changed, 20 insertions(+), 5 deletions(-)
Comment 6 H.J. Lu 2017-12-19 22:06:26 UTC
Fixed.
Comment 7 Sourceware Commits 2018-01-20 22:57:39 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pie/static has been deleted
       was  7e29e9f2beed0a108951f1b4c7543fe39ff1da1a

- Log -----------------------------------------------------------------
7e29e9f2beed0a108951f1b4c7543fe39ff1da1a Replece LDFLAGS-* = $(no-pie-ldflag) with tst-*-no-pie = yes [BZ #22630]
-----------------------------------------------------------------------