[PATCH v3] Use __executable_start as the lowest address for profiling [BZ #28153]
Fangrui Song
maskray@google.com
Fri Aug 6 00:16:09 GMT 2021
On 2021-08-05, H.J. Lu via Libc-alpha wrote:
>Glibc assumes that ENTRY_POINT is the lowest address for which we need
>to keep profiling records and BFD linker uses a linker script to place
>the input sections.
>
>Starting from GCC 4.6, the main function is placed in .text.startup
>section and starting from binutils 2.22, BFD linker with
>
>commit add44f8d5c5c05e08b11e033127a744d61c26aee
>Author: Alan Modra <amodra@gmail.com>
>Date: Thu Nov 25 03:03:02 2010 +0000
>
> * scripttempl/elf.sc: Group .text.exit, text.startup and .text.hot
> sections.
>
>places .text.startup section before .text section, which leave the main
>function out of profiling records.
>
>Starting from binutils 2.15, linker provides __executable_start to mark
>the lowest address of the executable. Use __executable_start as the
>lowest address to keep the main function in profiling records. This fixes
>[BZ #28153].
>
>Tested on Linux/x86-64, Linux/x32 and Linux/i686 as well as with
>build-many-glibcs.py.
>---
> csu/gmon-start.c | 10 +++++++++-
> gmon/tst-gmon-gprof.sh | 2 ++
> gmon/tst-gmon-static-gprof.sh | 2 ++
> 3 files changed, 13 insertions(+), 1 deletion(-)
LGTM
More information about the Libc-alpha
mailing list