[sanitizers] Explainer about dyld and weak overrides on Darwin. (NFC)
authorRoy Sundahl <rsundahl@apple.com>
Thu, 23 Mar 2023 17:53:11 +0000 (10:53 -0700)
committerRoy Sundahl <rsundahl@apple.com>
Fri, 31 Mar 2023 15:55:49 +0000 (08:55 -0700)
Explain in the release notes that the Darwin dynamic linker (dyld) requires
that at least one weak symbol be present in any mach-o file that defines an
intended override of a sanitizer dylib weak reference.

rdar://103453678

Reviewed By: thetruestblue

Differential Revision: https://reviews.llvm.org/D146745

llvm/docs/ReleaseNotes.rst

index 4acb69f..da0ede2 100644 (file)
@@ -238,6 +238,20 @@ Changes to LLDB
 
 Changes to Sanitizers
 ---------------------
+* For Darwin users that override weak symbols, note that the dynamic linker will
+  only consider symbols in other mach-o modules which themselves contain at
+  least one weak symbol. A consequence is that if your program or dylib contains
+  an intended override of a weak symbol, then it must contain at least one weak
+  symbol as well for the override to be effective. That weak symbol may be the
+  intended override itself, an otherwise usused weak symbol added solely to meet
+  the requirement, or an existing but unrelated weak symbol.
+
+    Examples:
+      __attribute__((weak)) const char * __asan_default_options(void) {...}
+
+      __attribute__((weak,unused)) unsigned __enableOverrides;
+      
+      __attribute__((weak)) bool unrelatedWeakFlag;
 
 Other Changes
 -------------