about summary refs log tree commit diff
path: root/gmon
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-07-30 19:07:30 -0700
committerH.J. Lu <hjl.tools@gmail.com>2021-08-24 06:44:18 -0700
commit84a7eb1f87c1d01b58ad887a0ab5d87abbc1c772 (patch)
tree12496d55064d5d05d9aba22afa22a0312e341873 /gmon
parent5eb3e2c794c3fdd553833af5342740051221479c (diff)
downloadglibc-84a7eb1f87c1d01b58ad887a0ab5d87abbc1c772.tar.gz
glibc-84a7eb1f87c1d01b58ad887a0ab5d87abbc1c772.tar.xz
glibc-84a7eb1f87c1d01b58ad887a0ab5d87abbc1c772.zip
Use __executable_start as the lowest address for profiling [BZ #28153]
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.
Diffstat (limited to 'gmon')
-rw-r--r--gmon/tst-gmon-gprof.sh2
-rw-r--r--gmon/tst-gmon-static-gprof.sh2
2 files changed, 4 insertions, 0 deletions
diff --git a/gmon/tst-gmon-gprof.sh b/gmon/tst-gmon-gprof.sh
index 9d371582b9..dc0be02110 100644
--- a/gmon/tst-gmon-gprof.sh
+++ b/gmon/tst-gmon-gprof.sh
@@ -39,12 +39,14 @@ trap cleanup 0
 cat > "$expected" <<EOF
 f1 2000
 f2 1000
+f3 1
 EOF
 
 # Special version for powerpc with function descriptors.
 cat > "$expected_dot" <<EOF
 .f1 2000
 .f2 1000
+.f3 1
 EOF
 
 "$GPROF" -C "$program" "$data" \
diff --git a/gmon/tst-gmon-static-gprof.sh b/gmon/tst-gmon-static-gprof.sh
index 79218df967..4cc99c80d0 100644
--- a/gmon/tst-gmon-static-gprof.sh
+++ b/gmon/tst-gmon-static-gprof.sh
@@ -39,6 +39,7 @@ trap cleanup 0
 cat > "$expected" <<EOF
 f1 2000
 f2 1000
+f3 1
 main 1
 EOF
 
@@ -46,6 +47,7 @@ EOF
 cat > "$expected_dot" <<EOF
 .f1 2000
 .f2 1000
+.f3 1
 .main 1
 EOF