public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH/RFC] profil01: don't use address of function
@ 2014-08-20 14:00 Jan Stancek
  2014-08-20 14:32 ` chrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Stancek @ 2014-08-20 14:00 UTC (permalink / raw)
  To: ltp-list

This testcase is failing on ppc64 BE system, because
address of &test_profil does not reference beginning of code,
but entry in .opd section:
  "This section contains the official procedure descriptors.
   A pointer to a function shall reference a procedure descriptor
   in this section."
which was at address larger than all .text of test_profil.

This patch is replacing address of function approach with gcc's
__builtin_return_address() to get current pc value.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/profil/profil01.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/testcases/kernel/syscalls/profil/profil01.c b/testcases/kernel/syscalls/profil/profil01.c
index 5511f68..521ef97 100644
--- a/testcases/kernel/syscalls/profil/profil01.c
+++ b/testcases/kernel/syscalls/profil/profil01.c
@@ -31,9 +31,11 @@
 
 #define PROFIL_TIME 5
 
-/* should be large enough to hold data for test_profil() .text
- * on x86_64 this is ~600 bytes, so 16k should enough for all arches */
-#define PROFIL_BUFLEN (16*1024)
+/* Should be large enough to hold data for test_profil() .text,
+ * on x86_64 this is ~600 bytes, so 16k should enough for all arches.
+ * We will monitor 16k on each side around current pc value,
+ * just in case compiler put call to get_pc() below "data shuffling" code */
+#define PROFIL_BUFLEN (32*1024)
 
 char *TCID = "profil01";
 int TST_TOTAL = 1;
@@ -46,11 +48,16 @@ static void alrm_handler(int sig)
 	profil_done = 1;
 }
 
+static void __attribute__ ((noinline)) *get_pc(void)
+{
+	return __builtin_return_address(0);
+}
+
 static void test_profil(void)
 {
 	unsigned short buf[PROFIL_BUFLEN] = { 0 };
 	volatile int data[8] = { 0 };
-	size_t offset = (size_t) &test_profil, count = 0;
+	size_t offset = (size_t) get_pc() - PROFIL_BUFLEN/2, count = 0;
 	int ret, i;
 
 	/* reset for test looping */
-- 
1.7.1


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-08-26  9:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-20 14:00 [LTP] [PATCH/RFC] profil01: don't use address of function Jan Stancek
2014-08-20 14:32 ` chrubis
     [not found]   ` <290231308.10805374.1408632310290.JavaMail.zimbra@redhat.com>
2014-08-26  8:55     ` chrubis
     [not found]       ` <1624956800.12985322.1409044708265.JavaMail.zimbra@redhat.com>
2014-08-26  9:22         ` chrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox