mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-27 05:00:15 +00:00
84a7eb1f87
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.
65 lines
1.5 KiB
Bash
65 lines
1.5 KiB
Bash
#!/bin/sh
|
|
# Check the output of gprof against a carfully crafted static binary.
|
|
# Copyright (C) 2017-2021 Free Software Foundation, Inc.
|
|
# This file is part of the GNU C Library.
|
|
|
|
# The GNU C Library is free software; you can redistribute it and/or
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
# License as published by the Free Software Foundation; either
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
# The GNU C Library is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
# Lesser General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
# License along with the GNU C Library; if not, see
|
|
# <https://www.gnu.org/licenses/>.
|
|
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
set -e
|
|
exec 2>&1
|
|
|
|
GPROF="$1"
|
|
program="$2"
|
|
data="$3"
|
|
|
|
actual=$(mktemp)
|
|
expected=$(mktemp)
|
|
expected_dot=$(mktemp)
|
|
cleanup () {
|
|
rm -f "$actual"
|
|
rm -f "$expected"
|
|
rm -f "$expected_dot"
|
|
}
|
|
trap cleanup 0
|
|
|
|
cat > "$expected" <<EOF
|
|
f1 2000
|
|
f2 1000
|
|
f3 1
|
|
main 1
|
|
EOF
|
|
|
|
# Special version for powerpc with function descriptors.
|
|
cat > "$expected_dot" <<EOF
|
|
.f1 2000
|
|
.f2 1000
|
|
.f3 1
|
|
.main 1
|
|
EOF
|
|
|
|
"$GPROF" -C "$program" "$data" \
|
|
| awk -F '[(): ]' '/executions/{print $5, $8}' \
|
|
| sort > "$actual"
|
|
|
|
if cmp -s "$actual" "$expected_dot" \
|
|
|| diff -u --label expected "$expected" --label actual "$actual" ; then
|
|
echo "PASS"
|
|
else
|
|
echo "FAIL"
|
|
exit 1
|
|
fi
|