From: "H.J. Lu" <hjl.tools@gmail.com>
To: Alan Modra <amodra@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix pr80044, -static and -pie insanity, and pr81170
Date: Tue, 18 Jul 2017 14:49:00 -0000 [thread overview]
Message-ID: <CAMe9rOoEG-mx149+vEEY2Pp7JpSDd_SAidTtB3eo7FpcwFdmeA@mail.gmail.com> (raw)
In-Reply-To: <20170718140953.GL14520@bubble.grove.modra.org>
On Tue, Jul 18, 2017 at 7:09 AM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Jul 18, 2017 at 05:36:49AM -0700, H.J. Lu wrote:
>> I am working on compiling libc.a in glibc with -fPIE and building static
>> PIE. This creates static executable with PIE:
>>
>> gcc -nostdlib -nostartfiles -static -o
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/elf/sln -pie
>> -Wl,--no-dynamic-linker
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/csu/crt1.o
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/csu/crti.o `gcc
>> --print-file-name=crtbeginS.o`
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/elf/sln.o
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/elf/static-stubs.o
>> -Wl,--start-group
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/libc.a -lgcc
>> -Wl,--end-group `gcc --print-file-name=crtendS.o`
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/csu/crtn.o
>>
>> Currently, it only works with gcc configured with -disable-default-pie.
>> With --enable-default-pie, I got
>>
>> [hjl@gnu-tools-1 build-x86_64-linux]$ /usr/gcc-7.1.1-x32-pie/bin/gcc
>> -nostdlib -nostartfiles -static -o /tmp/sln -pie
>> -Wl,--no-dynamic-linker
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/csu/crt1.o
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/csu/crti.o `gcc
>> --print-file-name=crtbeginS.o`
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/elf/sln.o
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/elf/static-stubs.o
>> -Wl,--start-group
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/libc.a -lgcc
>> -Wl,--end-group `gcc --print-file-name=crtendS.o`
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/csu/crtn.o
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/libc.a(dl-support.o):
>> In function `elf_machine_load_address':
>> /export/gnu/import/git/sources/glibc/elf/../sysdeps/x86_64/dl-machine.h:59:
>> undefined reference to `_DYNAMIC'
>> /export/build/gnu/glibc-static-pie/build-x86_64-linux/libc.a(dl-support.o):
>> In function `elf_get_dynamic_info':
>> /export/gnu/import/git/sources/glibc/elf/get-dynamic-info.h:48:
>> undefined reference to `_DYNAMIC'
>> collect2: error: ld returned 1 exit status
>> [hjl@gnu-tools-1 build-x86_64-linux]$
>>
>> Will your change fix it?
>
> You have got to be joking! How should I know whether something will
> work with some hare-brained scheme of yours? One that seemingly
> requires you to specify startup files by hand!
>
The difference is with --enable-default-pie, the gcc driver doesn't pass
both -pie and -static ld when "-static -pie" is used. Does your change
pass both -pie and -static ld when "-static -pie" is used?
--
H.J.
next prev parent reply other threads:[~2017-07-18 14:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 15:29 Alan Modra
2017-06-29 13:34 ` Alan Modra
2017-07-15 12:45 ` Alan Modra
2017-07-06 13:34 ` Matthias Klose
2017-07-15 13:32 ` H.J. Lu
2017-07-17 12:33 ` Alan Modra
2017-07-17 13:01 ` H.J. Lu
2017-07-18 4:02 ` Alan Modra
2017-07-18 12:36 ` H.J. Lu
2017-07-18 14:10 ` Alan Modra
2017-07-18 14:49 ` H.J. Lu [this message]
2017-07-19 5:12 ` Alan Modra
2017-07-20 21:22 ` H.J. Lu
2017-08-28 15:44 ` Jeff Law
2017-08-29 2:35 ` Alan Modra
2017-08-29 8:39 ` Jeff Law
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMe9rOoEG-mx149+vEEY2Pp7JpSDd_SAidTtB3eo7FpcwFdmeA@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=amodra@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).