public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
@ 2011-01-18 13:32 Manjunath Matti
  2011-01-18 19:20 ` Andreas Schwab
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-01-18 13:32 UTC (permalink / raw)
  To: libc-ports; +Cc: philb, ryosei.takagi, madhvesh.s

Hello

I noticed that gprof (-pg option) on arm-unknown-linux-gnueabi is broken,
if one would like to profile the library functions. This distribution is built
using the following sources:

binutils: 2.20.51.0.11
gcc: 4.5.1
glibc, glibc-ports: 2.11.2

Here, --enable-profile option is passed while building glibc.

Using our earlier distribution, library function profiling was possible.
This distribution was built using the following sources:
binutils: 2.19.51
gcc: 4.3.3
glibc, glibc-ports: 2.9

I am aware that the reason is the new implementation "__gnu_mcount_nc".

The legacy _mcount implementation assumes r11 points to a 4-word APCS frame.
This is generally not true for EABI targets, particularly not in Thumb mode.

Since gcc 4.4.x the name and calling convention for function profiling
on ARM changed. The new implementation __gnu_mcount_nc with an ABI that
doesn't require the compiler to generate old APCS frames. The "nc" comes
from the fact that we do not need to pass mcount the location of a counter.

This new EABI-compatible profiling interface for EABI targets, requires a
function __gnu_mcount_nc, which is provided by GNU libc versions 2.8
and later.


testcase


#include <stdio.h>

void hello(int i)
{
    printf("Hello World! %d\n", i);
}

int main(void)
{
    int i;
    for (i = 0; i < 10000; i ++) {
        hello(i);
    }
}

command line option
# gcc -pg hello.c -o hello.exe -static -lc_p
# ./hello.exe

Error: Segmentation Fault.

On investigation it was found that some glibc functions such as read, write,
open, uname still had the hook "_mcount" for function profiling.

Solution :
1. Make the library insert the new profiling hook "__gnu_mcount_nc"
2. Stop the poping of LR register after the execution returns from the
profiling function, as the new implementation __gnu_mcount_nc restores
the original LR value before returning.

The following patch fixes this issue for both ARMv7 and thumb2, this has been
tested.

{{{
--- a/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-17
19:15:26.000000000 +0530
+++ b/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-17
19:23:40.000000000 +0530
@@ -89,10 +89,16 @@

 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef PROF
+# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#define CALL_MCOUNT                    \
+       str     lr,[sp, #-4]!   ;       \
+       bl      PLTJMP(mcount)  ;
+# else
 #define CALL_MCOUNT                    \
        str     lr,[sp, #-4]!   ;       \
        bl      PLTJMP(mcount)  ;       \
        ldr     lr, [sp], #4    ;
+# endif
 #else
 #define CALL_MCOUNT            /* Do nothing.  */
 #endif
@@ -102,8 +108,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define        syscall_error   __syscall_error
+# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+#define mcount         __gnu_mcount_nc
+# else
 #define mcount         _mcount
 #endif
+#endif

 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte
}}}

Since this is my first patch to the mailing list kindly review and
help me mainline
this patch.


Regards,
Manjunath S Matti
Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-18 13:32 [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi Manjunath Matti
@ 2011-01-18 19:20 ` Andreas Schwab
  2011-01-19  9:19   ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2011-01-18 19:20 UTC (permalink / raw)
  To: Manjunath Matti; +Cc: libc-ports, philb, ryosei.takagi, madhvesh.s

Manjunath Matti <manjunath81@gmail.com> writes:

> +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)

        __GNUC_PREREQ(4, 4)

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-18 19:20 ` Andreas Schwab
@ 2011-01-19  9:19   ` Manjunath Matti
  2011-01-19 11:06     ` Andreas Schwab
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-01-19  9:19 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-ports, philb, ryosei.takagi, madhvesh.s

Hi,

On Tue, Jan 18, 2011 at 7:02 PM, Andreas Schwab <schwab@redhat.com> wrote:
>
>> +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
>
>        __GNUC_PREREQ(4, 4)
>
> Andreas.
>

I guess its just replacing a one-liner with another one or are there any
advantages ?

Regards,
Manjunath S Matti
Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-19  9:19   ` Manjunath Matti
@ 2011-01-19 11:06     ` Andreas Schwab
  2011-01-24 19:58       ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Andreas Schwab @ 2011-01-19 11:06 UTC (permalink / raw)
  To: Manjunath Matti; +Cc: libc-ports, philb, ryosei.takagi, madhvesh.s

Manjunath Matti <manjunath81@gmail.com> writes:

> I guess its just replacing a one-liner with another one or are there any
> advantages ?

The advantage is that it works.

Andreas.

-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-19 11:06     ` Andreas Schwab
@ 2011-01-24 19:58       ` Manjunath Matti
  2011-01-25 18:21         ` Joseph S. Myers
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-01-24 19:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-ports, philb, ryosei.takagi, madhvesh.s

Hi Andreas,

On Wed, Jan 19, 2011 at 2:49 PM, Andreas Schwab <schwab@redhat.com> wrote:
> Manjunath Matti <manjunath81@gmail.com> writes:
>
>> I guess its just replacing a one-liner with another one or are there any
>> advantages ?
>
> The advantage is that it works.
>
> Andreas.
>

I have modified the patch as follows

{{{
--- a/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-19
17:53:21.000000000 +0530
+++ b/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-19
17:54:14.000000000 +0530
@@ -18,6 +18,7 @@
    02111-1307 USA.  */

 #include <sysdeps/generic/sysdep.h>
+#include <features.h>

 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
@@ -89,10 +90,16 @@

 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef PROF
+#if __GNUC_PREREQ(4,4)
+#define CALL_MCOUNT                     \
+        str     lr,[sp, #-4]!   ;       \
+        bl      PLTJMP(mcount)  ;
+#else
 #define CALL_MCOUNT                    \
        str     lr,[sp, #-4]!   ;       \
        bl      PLTJMP(mcount)  ;       \
        ldr     lr, [sp], #4    ;
+#endif
 #else
 #define CALL_MCOUNT            /* Do nothing.  */
 #endif
@@ -102,8 +109,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define        syscall_error   __syscall_error
+#if __GNUC_PREREQ (4,4)
+#define mcount         __gnu_mcount_nc
+#else
 #define mcount         _mcount
 #endif
+#endif

 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte
}}}

Thanks for your comment.

Regards,
Manjunath S Matti
Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-24 19:58       ` Manjunath Matti
@ 2011-01-25 18:21         ` Joseph S. Myers
  2011-01-28 13:12           ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Joseph S. Myers @ 2011-01-25 18:21 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

On Wed, 19 Jan 2011, Manjunath Matti wrote:

>  /* If compiled for profiling, call `mcount' at the start of each function.  */
>  #ifdef PROF
> +#if __GNUC_PREREQ(4,4)

I think the condition should also include defined(__ARM_EABI__), since 
this is specific to EABI, though old-ABI is no longer maintained.

> +#define CALL_MCOUNT                     \
> +        str     lr,[sp, #-4]!   ;       \
> +        bl      PLTJMP(mcount)  ;
> +#else
>  #define CALL_MCOUNT                    \
>         str     lr,[sp, #-4]!   ;       \
>         bl      PLTJMP(mcount)  ;       \
>         ldr     lr, [sp], #4    ;
> +#endif

This patch does not appear to be against the current git sources, which 
contain CFI information for the call.  Note that you need to be careful 
about CFI information for a call to __gnu_mcount_nc (which acts like a pop 
instruction); see GCC bug 42380 for more discussion of that issue.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-25 18:21         ` Joseph S. Myers
@ 2011-01-28 13:12           ` Manjunath Matti
  2011-01-28 13:45             ` Manjunath Matti
  2011-01-31  1:17             ` Joseph S. Myers
  0 siblings, 2 replies; 18+ messages in thread
From: Manjunath Matti @ 2011-01-28 13:12 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

Hi Joseph,

>>  /* If compiled for profiling, call `mcount' at the start of each function.  */
>>  #ifdef PROF
>> +#if __GNUC_PREREQ(4,4)
>
> I think the condition should also include defined(__ARM_EABI__), since
> this is specific to EABI, though old-ABI is no longer maintained.
>

I think the move from old-ABI to EABI, for ARM was done in GCC 4.4 release.
As you have rightly pointed out that the old-ABI is no longer maintained,
hence I considered to check for GCC 4.4 which doesn't generate old APCS
frames. This GCC version also requires glibc 2.8 for __gnu_mcount_nc
implementation. So this patch checks for GCC version which conforms to
EABI and requires glibc 2.8 or later so as to support the GCC with the
implementation.

Considering your point and the change being the old-ABI-> EABI, I modified
the patch to
{{{
--- a/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-28
12:09:15.000000000 +0530
+++ b/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-28
12:13:46.000000000 +0530
@@ -89,10 +89,16 @@

 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef PROF
+#if defined(__ARM_EABI__)
+#define CALL_MCOUNT                    \
+       str     lr,[sp, #-4]!   ;       \
+       bl      PLTJMP(mcount)  ;
+#else
 #define CALL_MCOUNT                    \
        str     lr,[sp, #-4]!   ;       \
        bl      PLTJMP(mcount)  ;       \
        ldr     lr, [sp], #4    ;
+#endif
 #else
 #define CALL_MCOUNT            /* Do nothing.  */
 #endif
@@ -102,8 +108,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define        syscall_error   __syscall_error
+#if defined(__ARM_EABI__)
+#define mcount         __gnu_mcount_nc
+#else
 #define mcount         _mcount
 #endif
+#endif

 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte
}}}

This generates the same result as the previous patch. But i could not check
if this patch works with GCC version lesser than 4.4.

>
> This patch does not appear to be against the current git sources, which
> contain CFI information for the call.  Note that you need to be careful
> about CFI information for a call to __gnu_mcount_nc (which acts like a pop
> instruction); see GCC bug 42380 for more discussion of that issue.
>

During my investigation I have applied the patches submitted by
Thomas Schwinge
 - Add CFI statements to ARM's assembly code.
 - Move ARM EABI mcount into a separate .S file.

These patches have not helped to fix the profiling of the
glibc library functions.

>>On investigation it was found that some glibc functions such as read, write,
>>open, uname still had the hook "_mcount" for function profiling.

Currently we are trying to fix the issue for the following source
glibc, glibc-ports: 2.11.2

Once this patch is ok, then I will re-submit it for the latest sources from
the git repo.

> --
> Joseph S. Myers

Regards,
Manjunath S Matti
Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-28 13:12           ` Manjunath Matti
@ 2011-01-28 13:45             ` Manjunath Matti
  2011-01-31  1:17             ` Joseph S. Myers
  1 sibling, 0 replies; 18+ messages in thread
From: Manjunath Matti @ 2011-01-28 13:45 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

Hi Joseph,

>
>>>  /* If compiled for profiling, call `mcount' at the start of each function.  */
>>>  #ifdef PROF
>>> +#if __GNUC_PREREQ(4,4)
>>
>> I think the condition should also include defined(__ARM_EABI__), since
>> this is specific to EABI, though old-ABI is no longer maintained.

I am sorry about the previous patch attached, it contains only (__ARM_EABI__)
condition checking.

Below is the patch which checks for both GCC 4.4 and (__ARM_EABI__).

{{{
--- a/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-28
18:06:12.000000000 +0530
+++ b/glibc-ports-2.11/sysdeps/arm/sysdep.h     2011-01-28
18:14:34.000000000 +0530
@@ -18,6 +18,7 @@
    02111-1307 USA.  */

 #include <sysdeps/generic/sysdep.h>
+#include <features.h>

 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
@@ -89,10 +90,16 @@

 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef PROF
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
+#define CALL_MCOUNT                    \
+       str     lr,[sp, #-4]!   ;       \
+       bl      PLTJMP(mcount)  ;
+#else
 #define CALL_MCOUNT                    \
        str     lr,[sp, #-4]!   ;       \
        bl      PLTJMP(mcount)  ;       \
        ldr     lr, [sp], #4    ;
+#endif
 #else
 #define CALL_MCOUNT            /* Do nothing.  */
 #endif
@@ -102,8 +109,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define        syscall_error   __syscall_error
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
+#define mcount         __gnu_mcount_nc
+#else
 #define mcount         _mcount
 #endif
+#endif

 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte
}}}

Thanks you for your time and inputs.

>> --
>> Joseph S. Myers

 Regards,
 Manjunath S Matti
 Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-01-28 13:12           ` Manjunath Matti
  2011-01-28 13:45             ` Manjunath Matti
@ 2011-01-31  1:17             ` Joseph S. Myers
       [not found]               ` <AANLkTimQ2qgs41BAKhLK_Xpf5Ts_Kz=G=UyvY63QbMVp@mail.gmail.com>
  1 sibling, 1 reply; 18+ messages in thread
From: Joseph S. Myers @ 2011-01-31  1:17 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

On Fri, 28 Jan 2011, Manjunath Matti wrote:

> Currently we are trying to fix the issue for the following source
> glibc, glibc-ports: 2.11.2
> 
> Once this patch is ok, then I will re-submit it for the latest sources from
> the git repo.

I can only review a patch for the current sources.  Once there is a 
suitable version in there, if you wish to propose backports for previous 
release branches you can do so.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
       [not found]               ` <AANLkTimQ2qgs41BAKhLK_Xpf5Ts_Kz=G=UyvY63QbMVp@mail.gmail.com>
@ 2011-02-08 20:18                 ` Joseph S. Myers
  2011-02-15 13:32                   ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Joseph S. Myers @ 2011-02-08 20:18 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

On Mon, 31 Jan 2011, Manjunath Matti wrote:

> This time I have created the patch with the following sources
> glibc-2.12.2 and glibc-ports 2.12.2
> 
> I have even tested it on ARMv7a (Beagle Board) and hope this would be
> fine to be main lined.

Thanks, this patch is a lot closer to being ready to go in.

>  /* If compiled for profiling, call `mcount' at the start of each function.  */
>  #ifdef PROF
> +/* Call __gnu_mcount_nc if GCC > 4.4 and abi = EABI */
> +#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
> +#define CALL_MCOUNT \
> +  str  lr,[sp, #-4]!; \
> +  cfi_adjust_cfa_offset (4); \
> +  cfi_rel_offset (lr, 0); \
> +  bl PLTJMP(mcount);

I think you need

  cfi_adjust_cfa_offset (-4)
  cfi_restore (lr)

here, since from the caller's perspective the "bl PLTJMP(mcount)" 
instruction (calling __gnu_mcount_nc via the mcount macro you define 
later) acts by popping lr.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-08 20:18                 ` Joseph S. Myers
@ 2011-02-15 13:32                   ` Manjunath Matti
  2011-02-15 20:50                     ` Joseph S. Myers
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-02-15 13:32 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

Hi Joseph,

This time I have created the patch with the following sources
glibc-2.13 and glibc-ports 2.13

I have tested the profiling part on ARMv7a (Beagle Board) and have
even verified the
debug-dump.

> Thanks, this patch is a lot closer to being ready to go in.
>
>>  /* If compiled for profiling, call `mcount' at the start of each function.  */
>>  #ifdef PROF
>> +/* Call __gnu_mcount_nc if GCC > 4.4 and abi = EABI */
>> +#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
>> +#define CALL_MCOUNT \
>> +  str  lr,[sp, #-4]!; \
>> +  cfi_adjust_cfa_offset (4); \
>> +  cfi_rel_offset (lr, 0); \
>> +  bl PLTJMP(mcount);
>
> I think you need
>
>  cfi_adjust_cfa_offset (-4)
>  cfi_restore (lr)
>
> here, since from the caller's perspective the "bl PLTJMP(mcount)"
> instruction (calling __gnu_mcount_nc via the mcount macro you define
> later) acts by popping lr.

I have added the cfi assembler directives as per your comment.

{{{
--- a/glibc-ports-2.13/sysdeps/arm/sysdep.h     2011-01-26
02:30:16.000000000 +0530
+++ b/glibc-ports-2.13/sysdeps/arm/sysdep.h     2011-02-15
15:55:07.000000000 +0530
@@ -18,6 +18,7 @@
    02111-1307 USA.  */

 #include <sysdeps/generic/sysdep.h>
+#include <features.h>

 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
@@ -92,6 +93,16 @@

 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef PROF
+/* Call __gnu_mcount_nc if GCC > 4.4 and abi = EABI */
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
+#define CALL_MCOUNT \
+  str  lr,[sp, #-4]!; \
+  cfi_adjust_cfa_offset (4); \
+  cfi_rel_offset (lr, 0); \
+  bl PLTJMP(mcount); \
+  cfi_adjust_cfa_offset (-4); \
+  cfi_restore (lr)
+#else /* else call _mcount */
 #define CALL_MCOUNT \
   str  lr,[sp, #-4]!; \
   cfi_adjust_cfa_offset (4); \
@@ -100,6 +111,7 @@
   ldr lr, [sp], #4; \
   cfi_adjust_cfa_offset (-4); \
   cfi_restore (lr)
+#endif
 #else
 #define CALL_MCOUNT            /* Do nothing.  */
 #endif
@@ -109,8 +121,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define        syscall_error   __syscall_error
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
+#define mcount         __gnu_mcount_nc
+#else
 #define mcount         _mcount
 #endif
+#endif

 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte
}}}

Thanks for your valuable inputs.

Regards,
Manjunath S Matti
Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-15 13:32                   ` Manjunath Matti
@ 2011-02-15 20:50                     ` Joseph S. Myers
  2011-02-16  7:30                       ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Joseph S. Myers @ 2011-02-15 20:50 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

On Tue, 15 Feb 2011, Manjunath Matti wrote:

> Hi Joseph,
> 
> This time I have created the patch with the following sources
> glibc-2.13 and glibc-ports 2.13

Although it looks correct, it does not apply cleanly.

patching file sysdeps/arm/sysdep.h
Hunk #2 FAILED at 93.
Hunk #3 succeeded at 101 with fuzz 2.
Hunk #4 FAILED at 111.
2 out of 4 hunks FAILED -- saving rejects to file sysdeps/arm/sysdep.h.rej

It appears you may have cut-and-pasted the patch in a way that removes 
trailing whitespace and converts tabs to spaces.  If you cannot include it 
in the body of your email in a way that avoids these problems, could you 
send it as an attachment?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-15 20:50                     ` Joseph S. Myers
@ 2011-02-16  7:30                       ` Manjunath Matti
  2011-02-16 17:31                         ` Joseph S. Myers
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-02-16  7:30 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

Hi Joseph,

> Although it looks correct, it does not apply cleanly.
>
> patching file sysdeps/arm/sysdep.h
> Hunk #2 FAILED at 93.
> Hunk #3 succeeded at 101 with fuzz 2.
> Hunk #4 FAILED at 111.
> 2 out of 4 hunks FAILED -- saving rejects to file sysdeps/arm/sysdep.h.rej
>
> It appears you may have cut-and-pasted the patch in a way that removes
> trailing whitespace and converts tabs to spaces.  If you cannot include it
> in the body of your email in a way that avoids these problems, could you
> send it as an attachment?

Yes, I had copied the patch from the vim editor, my mistake. This may have
caused the problem. Now I have attached the patch, please let me know if
there are any issues.

Regards,
Manjunath S Matti
Sony India Software Centre.

[-- Attachment #2: glibc-ports-2.13-mcount_gprof_fix.patch --]
[-- Type: text/x-patch, Size: 1477 bytes --]

--- a/glibc-ports-2.13/sysdeps/arm/sysdep.h	2011-01-26 02:30:16.000000000 +0530
+++ b/glibc-ports-2.13/sysdeps/arm/sysdep.h	2011-02-15 15:55:07.000000000 +0530
@@ -18,6 +18,7 @@
    02111-1307 USA.  */
 
 #include <sysdeps/generic/sysdep.h>
+#include <features.h>
 
 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
@@ -92,6 +93,16 @@
 
 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef	PROF
+/* Call __gnu_mcount_nc if GCC > 4.4 and abi = EABI */
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__) 
+#define CALL_MCOUNT \
+  str	lr,[sp, #-4]!; \
+  cfi_adjust_cfa_offset (4); \
+  cfi_rel_offset (lr, 0); \
+  bl PLTJMP(mcount); \
+  cfi_adjust_cfa_offset (-4); \
+  cfi_restore (lr)
+#else /* else call _mcount */
 #define CALL_MCOUNT \
   str	lr,[sp, #-4]!; \
   cfi_adjust_cfa_offset (4); \
@@ -100,6 +111,7 @@
   ldr lr, [sp], #4; \
   cfi_adjust_cfa_offset (-4); \
   cfi_restore (lr)
+#endif
 #else
 #define CALL_MCOUNT		/* Do nothing.  */
 #endif
@@ -109,8 +121,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define	syscall_error	__syscall_error
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__) 
+#define mcount		__gnu_mcount_nc
+#else
 #define mcount		_mcount
 #endif
+#endif
 
 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-16  7:30                       ` Manjunath Matti
@ 2011-02-16 17:31                         ` Joseph S. Myers
  2011-02-18  5:30                           ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Joseph S. Myers @ 2011-02-16 17:31 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

On Wed, 16 Feb 2011, Manjunath Matti wrote:

> Yes, I had copied the patch from the vim editor, my mistake. This may have
> caused the problem. Now I have attached the patch, please let me know if
> there are any issues.

Thanks.  I have now committed this patch.  If no problems are seen now 
it's in we could then consider cherry-picking it to 2.13 and previous 
release branches.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-16 17:31                         ` Joseph S. Myers
@ 2011-02-18  5:30                           ` Manjunath Matti
  2011-02-18 18:01                             ` Joseph S. Myers
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-02-18  5:30 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

Hi Joseph,

> Thanks.  I have now committed this patch.  If no problems are seen now
> it's in we could then consider cherry-picking it to 2.13 and previous
> release branches.
>

Thank you for the commit, I can help you with the patches for
glibc 2.11 and 2.12 which I have already created and tested.

Do I post them on this mailing list (the very same thread) or create
a new one?  or is it ok if I mail them to you?

Regards,
Manjunath S Matti
Sony India Software Centre.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-18  5:30                           ` Manjunath Matti
@ 2011-02-18 18:01                             ` Joseph S. Myers
  2011-03-09  9:56                               ` Manjunath Matti
  0 siblings, 1 reply; 18+ messages in thread
From: Joseph S. Myers @ 2011-02-18 18:01 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

[-- Attachment #1: Type: TEXT/PLAIN, Size: 702 bytes --]

On Fri, 18 Feb 2011, Manjunath Matti wrote:

> Hi Joseph,
> 
> > Thanks.  I have now committed this patch.  If no problems are seen now
> > it's in we could then consider cherry-picking it to 2.13 and previous
> > release branches.
> >
> 
> Thank you for the commit, I can help you with the patches for
> glibc 2.11 and 2.12 which I have already created and tested.
> 
> Do I post them on this mailing list (the very same thread) or create
> a new one?  or is it ok if I mail them to you?

Yes, send them here - but let's wait a week or two to see if any problems 
arise with the mainline version, before applying it to release branches.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-02-18 18:01                             ` Joseph S. Myers
@ 2011-03-09  9:56                               ` Manjunath Matti
  2011-03-10  0:35                                 ` Joseph S. Myers
  0 siblings, 1 reply; 18+ messages in thread
From: Manjunath Matti @ 2011-03-09  9:56 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

Hi Joseph,

> Yes, send them here - but let's wait a week or two to see if any problems
> arise with the mainline version, before applying it to release branches.
>

I guess, we have no issue with the applied patches as there are no
problems reported.

I am attaching the patches for glibc 2.11, 2.12 which i had created
for my activity, kindly
commit them.

Thanks for your help and time.

Regards,
Manjunath S Matti
Sony India Software Centre.

[-- Attachment #2: glibc-ports-2.11-mcount_gprof_fix.patch --]
[-- Type: text/x-patch, Size: 1202 bytes --]

--- a/glibc-ports-2.11/sysdeps/arm/sysdep.h	2011-01-28 18:06:12.000000000 +0530
+++ b/glibc-ports-2.11/sysdeps/arm/sysdep.h	2011-01-28 18:14:34.000000000 +0530
@@ -18,6 +18,7 @@
    02111-1307 USA.  */
 
 #include <sysdeps/generic/sysdep.h>
+#include <features.h>
 
 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
@@ -89,10 +90,16 @@
 
 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef	PROF
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
+#define CALL_MCOUNT			\
+	str	lr,[sp, #-4]!	;	\
+	bl	PLTJMP(mcount)	;	
+#else
 #define CALL_MCOUNT			\
 	str	lr,[sp, #-4]!	;	\
 	bl	PLTJMP(mcount)	;	\
 	ldr	lr, [sp], #4	;
+#endif
 #else
 #define CALL_MCOUNT		/* Do nothing.  */
 #endif
@@ -102,8 +109,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define	syscall_error	__syscall_error
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__)
+#define mcount		__gnu_mcount_nc
+#else
 #define mcount		_mcount
 #endif
+#endif
 
 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte

[-- Attachment #3: glibc-ports-2.12-mcount_gprof_fix.patch --]
[-- Type: text/x-patch, Size: 1477 bytes --]

--- a/glibc-ports-2.12/sysdeps/arm/sysdep.h	2011-01-26 02:30:16.000000000 +0530
+++ b/glibc-ports-2.12/sysdeps/arm/sysdep.h	2011-02-15 15:55:07.000000000 +0530
@@ -18,6 +18,7 @@
    02111-1307 USA.  */
 
 #include <sysdeps/generic/sysdep.h>
+#include <features.h>
 
 #if (!defined (__ARM_ARCH_2__) && !defined (__ARM_ARCH_3__) \
      && !defined (__ARM_ARCH_3M__) && !defined (__ARM_ARCH_4__))
@@ -92,6 +93,16 @@
 
 /* If compiled for profiling, call `mcount' at the start of each function.  */
 #ifdef	PROF
+/* Call __gnu_mcount_nc if GCC > 4.4 and abi = EABI */
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__) 
+#define CALL_MCOUNT \
+  str	lr,[sp, #-4]!; \
+  cfi_adjust_cfa_offset (4); \
+  cfi_rel_offset (lr, 0); \
+  bl PLTJMP(mcount); \
+  cfi_adjust_cfa_offset (-4); \
+  cfi_restore (lr)
+#else /* else call _mcount */
 #define CALL_MCOUNT \
   str	lr,[sp, #-4]!; \
   cfi_adjust_cfa_offset (4); \
@@ -100,6 +111,7 @@
   ldr lr, [sp], #4; \
   cfi_adjust_cfa_offset (-4); \
   cfi_restore (lr)
+#endif
 #else
 #define CALL_MCOUNT		/* Do nothing.  */
 #endif
@@ -109,8 +121,12 @@
    on this system, the asm identifier `syscall_error' intrudes on the
    C name space.  Make sure we use an innocuous name.  */
 #define	syscall_error	__syscall_error
+#if __GNUC_PREREQ(4,4) && defined(__ARM_EABI__) 
+#define mcount		__gnu_mcount_nc
+#else
 #define mcount		_mcount
 #endif
+#endif
 
 #if defined(__ARM_EABI__)
 /* Tag_ABI_align8_preserved: This code preserves 8-byte

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi.
  2011-03-09  9:56                               ` Manjunath Matti
@ 2011-03-10  0:35                                 ` Joseph S. Myers
  0 siblings, 0 replies; 18+ messages in thread
From: Joseph S. Myers @ 2011-03-10  0:35 UTC (permalink / raw)
  To: Manjunath Matti
  Cc: Andreas Schwab, libc-ports, philb, ryosei.takagi, madhvesh.s

On Wed, 9 Mar 2011, Manjunath Matti wrote:

> Hi Joseph,
> 
> > Yes, send them here - but let's wait a week or two to see if any problems
> > arise with the mainline version, before applying it to release branches.
> >
> 
> I guess, we have no issue with the applied patches as there are no
> problems reported.
> 
> I am attaching the patches for glibc 2.11, 2.12 which i had created
> for my activity, kindly
> commit them.

Thanks.  This is now committed to 2.13, 2.12 and 2.11 branches.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-03-10  0:35 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-18 13:32 [PATCH] Fix the glibc profiling issue on arm-unknown-linux-gnueabi Manjunath Matti
2011-01-18 19:20 ` Andreas Schwab
2011-01-19  9:19   ` Manjunath Matti
2011-01-19 11:06     ` Andreas Schwab
2011-01-24 19:58       ` Manjunath Matti
2011-01-25 18:21         ` Joseph S. Myers
2011-01-28 13:12           ` Manjunath Matti
2011-01-28 13:45             ` Manjunath Matti
2011-01-31  1:17             ` Joseph S. Myers
     [not found]               ` <AANLkTimQ2qgs41BAKhLK_Xpf5Ts_Kz=G=UyvY63QbMVp@mail.gmail.com>
2011-02-08 20:18                 ` Joseph S. Myers
2011-02-15 13:32                   ` Manjunath Matti
2011-02-15 20:50                     ` Joseph S. Myers
2011-02-16  7:30                       ` Manjunath Matti
2011-02-16 17:31                         ` Joseph S. Myers
2011-02-18  5:30                           ` Manjunath Matti
2011-02-18 18:01                             ` Joseph S. Myers
2011-03-09  9:56                               ` Manjunath Matti
2011-03-10  0:35                                 ` Joseph S. Myers

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).