On Thu, 2018-08-30 at 18:15 +0200, Mark Wielaard wrote:
> Sorry for dropping this after you provided such an excellent analysis.
> So the problem really is that main gets split into main.cold which is
> jumped into, so a simple backtrace won't see the "hot" main anymore. If
> we would use the debuginfo we might be able to get the "correct"
> function name, but that isn't really the purpose of this testcase.
> 
> The only problem is that I haven't been able to replicate this in the
> testsuite (I do see the partitioning in the standalone testcase you
> posted).
> 
> Is it just run-backtrace-dwarf that is a problem for you?
> In that case, does the attached patch help? It puts all of main in its
> own section, which should prevent gcc from partitioning it.

I pushed the attached to master assuming it helps and doesn't cause any
issues.

Cheers,

Mark
From a1e892e920bbde60a9daa1f98c105c227ee7427d Mon Sep 17 00:00:00 2001
From: Mark Wielaard <m...@klomp.org>
Date: Tue, 11 Sep 2018 12:58:14 +0200
Subject: [PATCH] tests: Add section attribute to defeat
 -freorder-blocks-and-partition.

GCC could partition main into an cold and hot block causing our symbol
lookup to fail in the backtrace-dwarf testcase. Add a section attribute
on "main" so that it will be kept together.

Signed-off-by: Mark Wielaard <m...@klomp.org>
---
 tests/ChangeLog         | 4 ++++
 tests/backtrace-dwarf.c | 1 +
 2 files changed, 5 insertions(+)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index 2a20ffa..8d70891 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2018-09-11  Mark Wielaard  <m...@klomp.org>
+
+	* backtrace-dwarf.c (main): Add section attribute.
+
 2018-07-24  Mark Wielaard  <m...@klomp.org>
 
 	* run-annobingroup.sh: Add testfile-annobingroup-i386.o tests.
diff --git a/tests/backtrace-dwarf.c b/tests/backtrace-dwarf.c
index e1eb492..35f25ed 100644
--- a/tests/backtrace-dwarf.c
+++ b/tests/backtrace-dwarf.c
@@ -124,6 +124,7 @@ thread_callback (Dwfl_Thread *thread, void *thread_arg)
 }
 
 int
+__attribute__((section(".main"))) /* Defeat -freorder-blocks-and-partition  */
 main (int argc __attribute__ ((unused)), char **argv)
 {
   /* We use no threads here which can interfere with handling a stream.  */
-- 
1.8.3.1

Reply via email to