This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PING: [PATCH] BZ #14544: Use crtbeginT.o to statically link programs


On Thu, Sep 6, 2012 at 6:20 AM, Carlos O'Donell
<carlos_odonell@mentor.com> wrote:
> On 9/6/2012 8:50 AM, H.J. Lu wrote:
>> On Tue, Sep 4, 2012 at 7:58 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
>>> Hi,
>>>
>>> We should use crtbeginT.o instead of crtbegin.o to statically link
>>> programs.  Tested on Linux/x86-64.  OK to install?
>
> How is it that this doesn't cause serious problems in the testsuite?
>
> It is just that we are lucky (looking at the disassembly shows that might be the case)?

That is pure luck.

> What's this history here?
>
> When did this change in upstream?

It was added to GCC 3.1 by

http://gcc.gnu.org/ml/gcc-patches/2001-12/msg01552.html

to support .eh_frame_hdr section.

> Is crtbeginT.o used by all gcc's that we support?

We require GCC 4.3 or newer.

> Could you please verify this works fine on x86 also?

It works on x86, x32 and x86-64.

>>> H.J.
>>> ---
>>>  ChangeLog  | 12 ++++++++++++
>>>  Makeconfig | 11 +++++++----
>>>  2 files changed, 19 insertions(+), 4 deletions(-)
>>>
>>> From b0eb4b944f6d540df6a810d073014c5712335440 Mon Sep 17 00:00:00 2001
>>> From: "H.J. Lu" <hjl.tools@gmail.com>
>>> Date: Tue, 4 Sep 2012 19:53:24 -0700
>>> Subject: [PATCH] Use crtbeginT.o to statically link programs
>>>
>>> ---
>>>  ChangeLog  | 12 ++++++++++++
>>>  Makeconfig | 11 +++++++----
>>>  2 files changed, 19 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/ChangeLog b/ChangeLog
>>> index 5411be3..721a96f 100644
>>> --- a/ChangeLog
>>> +++ b/ChangeLog
>>> @@ -1,3 +1,15 @@
>>> +2012-09-04  H.J. Lu  <hongjiu.lu@intel.com>
>>> +
>>> +       [BZ #14544]
>>> +       * Makeconfig (link-static-before-libc): Replace $(+prector)
>>> +       with $(+prectorT).
>>> +       (link-static-after-libc): Replace $(+postctor) with
>>> +       $(+postctorT).
>>> +       (link-bounded): Replace $(+prector)/$(+postctor) with
>>> +       $(+prectorT)/$(+postctorT).
>>> +       (+prectorT): New macro.
>>> +       (+postctorT): Likewise.
>>> +
>>>  2012-09-04  Florian Weimer  <fweimer@redhat.com>
>>>
>>>         * stdlib/tst-secure-getenv.c (alternative_main): Only warn on SGID
>>> diff --git a/Makeconfig b/Makeconfig
>>> index 57f35f9..1c87973 100644
>>> --- a/Makeconfig
>>> +++ b/Makeconfig
>>> @@ -445,13 +445,13 @@ ifndef +link-static
>>>  +link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
>>>               $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
>>>               $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
>>> -             $(+preinit) $(+prector) \
>>> +             $(+preinit) $(+prectorT) \
>>>               $(filter-out $(addprefix $(csu-objpfx),start.o \
>>>                                                      $(start-installed-name))\
>>>                            $(+preinit) $(link-extra-libs-static) \
>>>                            $(common-objpfx)libc% $(+postinit),$^) \
>>>               $(link-extra-libs-static) $(link-libc-static)
>>> -+link-static-after-libc = $(+postctor) $(+postinit)
>>> ++link-static-after-libc = $(+postctorT) $(+postinit)
>>>  +link-static = $(+link-static-before-libc) $(link-libc-static) \
>>>                $(+link-static-after-libc)
>>>  +link-static-tests = $(+link-static-before-libc) $(link-libc-static-tests) \
>>> @@ -462,12 +462,12 @@ ifndef +link-bounded
>>>  +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
>>>               $(sysdep-LDFLAGS) $(LDFLAGS)  \
>>>               $(addprefix $(csu-objpfx),b$(static-start-installed-name)) \
>>> -             $(+preinit) $(+prector) \
>>> +             $(+preinit) $(+prectorT) \
>>>               $(filter-out $(addprefix $(csu-objpfx),start.ob \
>>>                                                      $(start-installed-name))\
>>>                            $(+preinit) $(link-extra-libs-bounded) \
>>>                            $(common-objpfx)libc% $(+postinit),$^) \
>>> -             $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctor) $(+postinit)
>>> +             $(link-extra-libs-bounded) $(link-libc-bounded) $(+postctorT) $(+postinit)
>>>  endif
>>>  ifndef config-LDFLAGS
>>>  ifeq (yes,$(build-shared))
>>> @@ -576,6 +576,9 @@ endif
>>>  +postinit = $(addprefix $(csu-objpfx),crtn.o)
>>>  +prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
>>>  +postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
>>> +# Variants of the two previous definitions for statically linking programs.
>>> ++prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
>>> ++postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
>>>  # Variants of the two previous definitions for linking PIE programs.
>>>  +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
>>>  +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
>>> --
>>> 1.7.11.4
>>>
>>
>> PING.
>>
>
> This looks fine to me, but I'd like one more person to review this.
>


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]