This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC][BZ #7233] Do not let tr_break call be optimized away.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Thu, 17 Oct 2013 20:09:04 +0200
- Subject: [RFC][BZ #7233] Do not let tr_break call be optimized away.
- Authentication-results: sourceware.org; auth=none
Hi,
In following bug a gcc optimizes tr_break call in tr_freehook. Adding
side effect prevents that.
Is using asm portable way to archieve that or is there a better way?
* malloc/mtrace.c (tr_break): Prevent compiler to optimize calls away.
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index ee94133..691b7a2 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -71,9 +71,11 @@ static __ptr_t (*tr_old_memalign_hook) (size_t __alignment, size_t __size,
extern void tr_break (void) __THROW;
libc_hidden_proto (tr_break)
-void
+void
+__attribute__ ((noinline))
tr_break (void)
{
+ __asm__ __volatile__ ("");
}
libc_hidden_def (tr_break)