This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Test for profiling support (_mcount/gprof)
On Wed, Aug 16, 2017 at 2:10 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Wed, Aug 16, 2017 at 2:04 PM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/16/2017 10:03 PM, H.J. Lu wrote:
>>> On Wed, Aug 16, 2017 at 8:32 AM, Florian Weimer <fweimer@redhat.com> wrote:
>>>> On 08/16/2017 05:30 PM, Andreas Schwab wrote:
>>>>> On Aug 16 2017, Florian Weimer <fweimer@redhat.com> wrote:
>>>>>
>>>>>> On 08/16/2017 05:20 PM, Andreas Schwab wrote:
>>>>>>> On Aug 16 2017, Florian Weimer <fweimer@redhat.com> wrote:
>>>>>>>
>>>>>>>> If you don't use --enable-frame-pointer for GCC, there's no apparent
>>>>>>>> reason to me to build glibc with --fomit-frame-pointer because it's the
>>>>>>>> default (albeit in a fashion that is compatible with -pg).
>>>>>>>
>>>>>>> That is not true.
>>>>>>
>>>>>> It is currently true—I don't see why anyone would want to build glibc
>>>>>> this way. Could you enlighten me?
>>>>>
>>>>> To omit the frame pointer.
>>>>
>>>> But GCC does it by default if you don't build with
>>>> --enable-frame-pointer, at least on i386, which is the architecture for
>>>> which you reported the failure.
>>>
>>> gmon/tst-gmon-gprof also fails with GCC defaulting to PIE.
>>
>> That would be a real failure (due to ASLR). Does linking with -pg
>> ordinarily disable PIE? I suppose we could add -pg to LDFLAGS for this
>> test because as Andreas explained earlier, it won't link in the system
>> profiling libraries.
>>
>
> -pg and -pie are mutually exclusive since they need different crt1.os,
> gcrrt1.o vs Scrt1.o. This patch works for me:
>
> diff --git a/Makeconfig b/Makeconfig
> index 5f2469116c..b51904b797 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -409,7 +409,7 @@ ifndef +link-pie
> +link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
> $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
> $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
> - $(addprefix $(csu-objpfx),S$(start-installed-name)) \
> + $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
> $(+preinit) $(+prectorS) \
> $(filter-out $(addprefix $(csu-objpfx),start.o \
> S$(start-installed-name))\
>
>
Tested with GCC defaulting to PIE. OK for master?
--
H.J.
From f19721b98346b9493f3ecb5cd41527e102c7fedf Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Wed, 16 Aug 2017 14:15:43 -0700
Subject: [PATCH] Support -pg with GCC defaulting to PIE
-pg and -pie are mutually exclusive since they need different crt1.o,
gcrrt1.o vs Scrt1.o. Make -pg overrdies -pie.
* Makeconfig (+link-pie-before-libc): Add CRT-* hook to override
the startup object.
---
Makeconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makeconfig b/Makeconfig
index 5f2469116c..b51904b797 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -409,7 +409,7 @@ ifndef +link-pie
+link-pie-before-libc = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \
$(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
$(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
- $(addprefix $(csu-objpfx),S$(start-installed-name)) \
+ $(firstword $(CRT-$(@F)) $(csu-objpfx)S$(start-installed-name)) \
$(+preinit) $(+prectorS) \
$(filter-out $(addprefix $(csu-objpfx),start.o \
S$(start-installed-name))\
--
2.13.5