@@ -467,6 +467,12 @@ Error, UINTPTR_MAX is undefined
467
467
468
468
#undef UPB_IS_GOOGLE3
469
469
470
+ #ifdef __clang__
471
+ #define UPB_NO_SANITIZE_ADDRESS __attribute__ ((no_sanitize(" address" )))
472
+ #else
473
+ #define UPB_NO_SANITIZE_ADDRESS
474
+ #endif
475
+
470
476
// Linker arrays combine elements from multiple translation units into a single
471
477
// array that can be iterated over at runtime.
472
478
//
@@ -493,28 +499,28 @@ Error, UINTPTR_MAX is undefined
493
499
494
500
#if defined(__ELF__) || defined(__wasm__)
495
501
496
- #define UPB_LINKARR_APPEND (name ) \
497
- __attribute__ ((retain, used, section( " linkarr_ " #name), \
498
- no_sanitize( " address " )))
499
- #define UPB_LINKARR_DECLARE (name, type ) \
500
- extern type const __start_linkarr_##name; \
501
- extern type const __stop_linkarr_##name; \
502
+ #define UPB_LINKARR_APPEND (name ) \
503
+ __attribute__ ((retain, used, \
504
+ section ( " linkarr_ " #name ))) UPB_NO_SANITIZE_ADDRESS
505
+ #define UPB_LINKARR_DECLARE (name, type ) \
506
+ extern type __start_linkarr_##name; \
507
+ extern type __stop_linkarr_##name; \
502
508
UPB_LINKARR_APPEND (name) type UPB_linkarr_internal_empty_##name[1 ]
503
509
#define UPB_LINKARR_START (name ) (&__start_linkarr_##name)
504
510
#define UPB_LINKARR_STOP (name ) (&__stop_linkarr_##name)
505
511
506
512
#elif defined(__MACH__)
507
513
508
514
/* As described in: https://stackoverflow.com/a/22366882 */
509
- #define UPB_LINKARR_APPEND (name ) \
510
- __attribute__ ((retain, used, section( " __DATA,__la_ " #name), \
511
- no_sanitize( " address " )))
512
- #define UPB_LINKARR_DECLARE (name, type ) \
513
- extern type const __start_linkarr_##name __asm ( \
514
- " section$start$__DATA$__la_" #name); \
515
- extern type const __stop_linkarr_##name __asm ( \
516
- " section$end$__DATA$" \
517
- " __la_" #name); \
515
+ #define UPB_LINKARR_APPEND (name ) \
516
+ __attribute__ ((retain, used, \
517
+ section ( " __DATA,__la_ " #name ))) UPB_NO_SANITIZE_ADDRESS
518
+ #define UPB_LINKARR_DECLARE (name, type ) \
519
+ extern type __start_linkarr_##name __asm ( \
520
+ " section$start$__DATA$__la_" #name); \
521
+ extern type __stop_linkarr_##name __asm ( \
522
+ " section$end$__DATA$" \
523
+ " __la_" #name); \
518
524
UPB_LINKARR_APPEND (name) type UPB_linkarr_internal_empty_##name[1 ]
519
525
#define UPB_LINKARR_START (name ) (&__start_linkarr_##name)
520
526
#define UPB_LINKARR_STOP (name ) (&__stop_linkarr_##name)
@@ -530,7 +536,7 @@ Error, UINTPTR_MAX is undefined
530
536
// not work on MSVC.
531
537
#define UPB_LINKARR_APPEND (name ) \
532
538
__declspec (allocate(" la_" #name " $j" )) \
533
- __attribute__((retain, used, no_sanitize( " address " )))
539
+ __attribute__((retain, used)) UPB_NO_SANITIZE_ADDRESS
534
540
#define UPB_LINKARR_DECLARE (name, type ) \
535
541
__declspec (allocate(" la_" #name " $a" )) type __start_linkarr_##name; \
536
542
__declspec (allocate(" la_" #name " $z" )) type __stop_linkarr_##name; \
0 commit comments