Message ID | 20171219010728.GA3002@gmail.com |
---|---|
State | New |
Headers | show |
Series | Replece LDFLAGS-* = $(no-pie-ldflag) with tst-*-no-pie = yes [BZ #22630] | expand |
On Mon, 18 Dec 2017, H.J. Lu wrote: > $(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 Why is --enable-static-pie causing non-static test cases to be built as PIE? I see nothing in the NEWS or INSTALL entries to indicate such an effect. That looks like the underlying problem here.
On Tue, Dec 19, 2017 at 9:07 AM, Joseph Myers <joseph@codesourcery.com> wrote: > On Mon, 18 Dec 2017, H.J. Lu wrote: > >> $(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 > > Why is --enable-static-pie causing non-static test cases to be built as > PIE? I see nothing in the NEWS or INSTALL entries to indicate such an > effect. That looks like the underlying problem here. > To build static PIE, all .o files need to compiled with -fPIE. Given all input .o files are compiled with -fPIE when creating an executable, should we generate PIE or nor no-PIE?
On Tue, 19 Dec 2017, H.J. Lu wrote: > On Tue, Dec 19, 2017 at 9:07 AM, Joseph Myers <joseph@codesourcery.com> wrote: > > On Mon, 18 Dec 2017, H.J. Lu wrote: > > > >> $(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 > > > > Why is --enable-static-pie causing non-static test cases to be built as > > PIE? I see nothing in the NEWS or INSTALL entries to indicate such an > > effect. That looks like the underlying problem here. > > > > To build static PIE, all .o files need to compiled with -fPIE. Given all > input .o files are compiled with -fPIE when creating an executable, should > we generate PIE or nor no-PIE? I'd expect a normal executable, in the case of dynamic executables, since nothing about --enable-static-pie says it changes how non-static executables are built.
On Tue, Dec 19, 2017 at 10:01 AM, Joseph Myers <joseph@codesourcery.com> wrote: > On Tue, 19 Dec 2017, H.J. Lu wrote: > >> On Tue, Dec 19, 2017 at 9:07 AM, Joseph Myers <joseph@codesourcery.com> wrote: >> > On Mon, 18 Dec 2017, H.J. Lu wrote: >> > >> >> $(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 >> > >> > Why is --enable-static-pie causing non-static test cases to be built as >> > PIE? I see nothing in the NEWS or INSTALL entries to indicate such an >> > effect. That looks like the underlying problem here. >> > >> >> To build static PIE, all .o files need to compiled with -fPIE. Given all >> input .o files are compiled with -fPIE when creating an executable, should >> we generate PIE or nor no-PIE? > > I'd expect a normal executable, in the case of dynamic executables, since > nothing about --enable-static-pie says it changes how non-static > executables are built. I can certainly make a patch to do that. On the other hand, should --enable-static-pie imply PIE?
On Tue, 19 Dec 2017, H.J. Lu wrote: > >> To build static PIE, all .o files need to compiled with -fPIE. Given all > >> input .o files are compiled with -fPIE when creating an executable, should > >> we generate PIE or nor no-PIE? > > > > I'd expect a normal executable, in the case of dynamic executables, since > > nothing about --enable-static-pie says it changes how non-static > > executables are built. > > I can certainly make a patch to do that. On the other hand, should > --enable-static-pie imply PIE? Logically, it doesn't need to. Practically, I don't know if people will want static PIEs without dynamic PIEs, but if it implies both static and dynamic PIEs, the documentation needs to say so.
On Tue, Dec 19, 2017 at 10:18 AM, Joseph Myers <joseph@codesourcery.com> wrote: > On Tue, 19 Dec 2017, H.J. Lu wrote: > >> >> To build static PIE, all .o files need to compiled with -fPIE. Given all >> >> input .o files are compiled with -fPIE when creating an executable, should >> >> we generate PIE or nor no-PIE? >> > >> > I'd expect a normal executable, in the case of dynamic executables, since >> > nothing about --enable-static-pie says it changes how non-static >> > executables are built. >> >> I can certainly make a patch to do that. On the other hand, should >> --enable-static-pie imply PIE? > > Logically, it doesn't need to. Practically, I don't know if people will > want static PIEs without dynamic PIEs, but if it implies both static and > dynamic PIEs, the documentation needs to say so. > I will submit a patch to update documentation.
On Tue, 19 Dec 2017, H.J. Lu wrote: > On Tue, Dec 19, 2017 at 10:18 AM, Joseph Myers <joseph@codesourcery.com> wrote: > > On Tue, 19 Dec 2017, H.J. Lu wrote: > > > >> >> To build static PIE, all .o files need to compiled with -fPIE. Given all > >> >> input .o files are compiled with -fPIE when creating an executable, should > >> >> we generate PIE or nor no-PIE? > >> > > >> > I'd expect a normal executable, in the case of dynamic executables, since > >> > nothing about --enable-static-pie says it changes how non-static > >> > executables are built. > >> > >> I can certainly make a patch to do that. On the other hand, should > >> --enable-static-pie imply PIE? > > > > Logically, it doesn't need to. Practically, I don't know if people will > > want static PIEs without dynamic PIEs, but if it implies both static and > > dynamic PIEs, the documentation needs to say so. > > > > I will submit a patch to update documentation. If the documentation achieves consensus, then this patch is also OK, since I think it's the correct way in that context of avoiding trying to link these particular tests as PIE.
diff --git a/Makeconfig b/Makeconfig index 80c498e33b..34bed9790f 100644 --- a/Makeconfig +++ b/Makeconfig @@ -413,7 +413,8 @@ link-extra-libs-tests = $(libsupport) # Command for linking PIE programs with the C library. ifndef +link-pie -+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \ ++link-pie-before-libc = $(CC) $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \ + -Wl,-O1 -nostdlib -nostartfiles -o $@ \ $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \ diff --git a/elf/Makefile b/elf/Makefile index 47c3d23ed8..a987614b6f 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -195,7 +195,7 @@ tests-internal += loadtest unload unload2 circleload1 \ tst-ptrguard1 tst-stackguard1 ifeq ($(build-hardcoded-path-in-tests),yes) tests += tst-dlopen-aout -LDFLAGS-tst-dlopen-aout = $(no-pie-ldflag) +tst-dlopen-aout-no-pie = yes endif test-srcs = tst-pathopt selinux-enabled := $(shell cat /selinux/enforce 2> /dev/null) @@ -369,7 +369,7 @@ ifeq ($(have-glob-dat-reloc),yes) tests += tst-prelink # Don't compile tst-prelink.c with PIE for GLOB_DAT relocation. CFLAGS-tst-prelink.c += -fno-pie -LDFLAGS-tst-prelink = $(no-pie-ldflag) +tst-prelink-no-pie = yes ifeq ($(run-built-tests),yes) tests-special += $(objpfx)tst-prelink-cmp.out endif @@ -1433,6 +1433,6 @@ $(objpfx)tst-debug1mod1.so: $(objpfx)testobj1.so $(objpfx)tst-main1: $(objpfx)tst-main1mod.so CRT-tst-main1 := $(csu-objpfx)crt1.o -LDFLAGS-tst-main1 = $(no-pie-ldflag) +tst-main1-no-pie = yes LDLIBS-tst-main1 = $(libsupport) tst-main1mod.so-no-z-defs = yes diff --git a/gmon/Makefile b/gmon/Makefile index 29e746723e..6d0c620b24 100644 --- a/gmon/Makefile +++ b/gmon/Makefile @@ -49,7 +49,7 @@ endif CFLAGS-mcount.c := -fno-omit-frame-pointer CFLAGS-tst-gmon.c := -fno-omit-frame-pointer -pg -LDFLAGS-tst-gmon := $(no-pie-ldflag) +tst-gmon-no-pie = yes CRT-tst-gmon := $(csu-objpfx)gcrt1.o tst-gmon-ENV := GMON_OUT_PREFIX=$(objpfx)tst-gmon.data ifeq ($(run-built-tests),yes)