[pushed] Darwin: Make sanitizer local vars linker-visible.

Message ID 6460FCAA-83A7-456F-9BE7-5258816AACF6@sandoe.co.uk
State New
Headers show
Series
  • [pushed] Darwin: Make sanitizer local vars linker-visible.
Related show

Commit Message

Iain Sandoe May 24, 2020, 11:50 a.m.
Hi

Another case where we need a linker-visible symbols in order to
preserve the ld64 atom model.  If these symbols are emitted as
'local' the linker cannot see that they are separate from any
global weak entry that precedes them.  This will cause the linker
to complain that there is (apparently) direct access to such a
weak global, preventing it from being replaced.

This is a short-term fix for the problem - we need generic
handling for relevant cases (that also does not pessimise objects
by emitting unnecessary symbols and relocations).

tested on x86_64-darwin16,
applied to master and 10.2, so far.
thanks
Iain

gcc/ChangeLog:

2020-05-23  Iain Sandoe  <iain@sandoe.co.uk>

	* config/darwin.h (ASM_GENERATE_INTERNAL_LABEL):
	Make ubsan_{data,type},ASAN symbols linker-visible.
---
 gcc/ChangeLog       | 5 +++++
 gcc/config/darwin.h | 6 ++++++
 2 files changed, 11 insertions(+)

-- 
2.24.1

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7a7b599ff93..ede1f15eb7a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2020-05-23 Iain Sandoe <iain@sandoe.co.uk>
+
+	* config/darwin.h (ASM_GENERATE_INTERNAL_LABEL): Make
+	ubsan_{data,type},ASAN symbols linker-visible.
+
 2020-05-22  Jan Hubicka  <hubicka@ucw.cz>
 
 	* lto-streamer-out.c (DFS::DFS): Silence warning.
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 27665b34a18..f528b1766bf 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -808,6 +808,12 @@  extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
   do {							\
     if (strcmp ("LC", PREFIX) == 0)			\
       sprintf (LABEL, "*%s%ld", "lC", (long)(NUM));	\
+    else if (strcmp ("Lubsan_data", PREFIX) == 0)	\
+      sprintf (LABEL, "*%s%ld", "lubsan_data", (long)(NUM));\
+    else if (strcmp ("Lubsan_type", PREFIX) == 0)	\
+      sprintf (LABEL, "*%s%ld", "lubsan_type", (long)(NUM));\
+    else if (strcmp ("LASAN", PREFIX) == 0)	\
+      sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\
     else						\
       sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM));	\
   } while (0)