public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] pointer-compare-1.c: Add __attribute__((used))
@ 2020-11-16 12:10 H.J. Lu
  0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2020-11-16 12:10 UTC (permalink / raw)
  To: gcc-patches

I am going to install this patch as requested:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97803#c5

H.J.
---
c-c++-common/asan/pointer-compare-1.c assumes the certain order for
variable placement.  Add __attribute__((used)) to avoid variable
placement changes due to SHF_GNU_RETAIN.

	PR testsuite/97803
	* c-c++-common/asan/pointer-compare-1.c (global1): Add
	__attribute__((used))
	(global2): Likewise.
	(small_global): Likewise.
	(large_global): Likewise.
---
 gcc/testsuite/c-c++-common/asan/pointer-compare-1.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/asan/pointer-compare-1.c b/gcc/testsuite/c-c++-common/asan/pointer-compare-1.c
index 1ce349e4917..4b558bf8179 100644
--- a/gcc/testsuite/c-c++-common/asan/pointer-compare-1.c
+++ b/gcc/testsuite/c-c++-common/asan/pointer-compare-1.c
@@ -14,12 +14,13 @@ foo (char *p, char *q)
   v = p > q;
 }
 
-char global1[100] = {}, global2[100] = {};
+char __attribute__((used)) global1[100] = {};
+char __attribute__((used)) global2[100] = {};
 char __attribute__((used)) smallest_global[5] = {};
-char small_global[7] = {};
+char __attribute__((used)) small_global[7] = {};
 char __attribute__((used)) little_global[10] = {};
 char __attribute__((used)) medium_global[4000] = {};
-char large_global[5000] = {};
+char __attribute__((used)) large_global[5000] = {};
 char __attribute__((used)) largest_global[6000] = {};
 
 int
-- 
2.28.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-16 12:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 12:10 [PATCH] pointer-compare-1.c: Add __attribute__((used)) H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).