Merge pull request #27610 from protocolbuffers/upb-ub-34
Avoid UB in upb by switching to the XCT section, which will run our c…
diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c
index 51cbc31..8e7fe72 100644
--- a/php/ext/google/protobuf/php-upb.c
+++ b/php/ext/google/protobuf/php-upb.c
@@ -664,10 +664,10 @@
* to prevent optimizers from removing the constructor. Our solution is to
* create a dummy exported weak symbol that prevent this stripping.
*/
-#pragma section(".CRT$XCU", long, read)
+#pragma section(".CRT$XCT", read)
#define UPB_CONSTRUCTOR(name, unique_name) \
static void __cdecl UPB_PRIVATE(name)(void); \
- __declspec(allocate(".CRT$XCU"), selectany) void( \
+ __declspec(allocate(".CRT$XCT"), selectany) void( \
__cdecl * UPB_PRIVATE(name##_))(void) = UPB_PRIVATE(name); \
__declspec(selectany, dllexport) void* UPB_PRIVATE(name##_force_linkage) = \
&UPB_PRIVATE(name##_); \
diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h
index 059ce36..34f08be 100644
--- a/php/ext/google/protobuf/php-upb.h
+++ b/php/ext/google/protobuf/php-upb.h
@@ -663,10 +663,10 @@
* to prevent optimizers from removing the constructor. Our solution is to
* create a dummy exported weak symbol that prevent this stripping.
*/
-#pragma section(".CRT$XCU", long, read)
+#pragma section(".CRT$XCT", read)
#define UPB_CONSTRUCTOR(name, unique_name) \
static void __cdecl UPB_PRIVATE(name)(void); \
- __declspec(allocate(".CRT$XCU"), selectany) void( \
+ __declspec(allocate(".CRT$XCT"), selectany) void( \
__cdecl * UPB_PRIVATE(name##_))(void) = UPB_PRIVATE(name); \
__declspec(selectany, dllexport) void* UPB_PRIVATE(name##_force_linkage) = \
&UPB_PRIVATE(name##_); \
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c
index 89e84b7..19bc79d 100644
--- a/ruby/ext/google/protobuf_c/ruby-upb.c
+++ b/ruby/ext/google/protobuf_c/ruby-upb.c
@@ -664,10 +664,10 @@
* to prevent optimizers from removing the constructor. Our solution is to
* create a dummy exported weak symbol that prevent this stripping.
*/
-#pragma section(".CRT$XCU", long, read)
+#pragma section(".CRT$XCT", read)
#define UPB_CONSTRUCTOR(name, unique_name) \
static void __cdecl UPB_PRIVATE(name)(void); \
- __declspec(allocate(".CRT$XCU"), selectany) void( \
+ __declspec(allocate(".CRT$XCT"), selectany) void( \
__cdecl * UPB_PRIVATE(name##_))(void) = UPB_PRIVATE(name); \
__declspec(selectany, dllexport) void* UPB_PRIVATE(name##_force_linkage) = \
&UPB_PRIVATE(name##_); \
diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h
index 387c677..24d8410 100755
--- a/ruby/ext/google/protobuf_c/ruby-upb.h
+++ b/ruby/ext/google/protobuf_c/ruby-upb.h
@@ -663,10 +663,10 @@
* to prevent optimizers from removing the constructor. Our solution is to
* create a dummy exported weak symbol that prevent this stripping.
*/
-#pragma section(".CRT$XCU", long, read)
+#pragma section(".CRT$XCT", read)
#define UPB_CONSTRUCTOR(name, unique_name) \
static void __cdecl UPB_PRIVATE(name)(void); \
- __declspec(allocate(".CRT$XCU"), selectany) void( \
+ __declspec(allocate(".CRT$XCT"), selectany) void( \
__cdecl * UPB_PRIVATE(name##_))(void) = UPB_PRIVATE(name); \
__declspec(selectany, dllexport) void* UPB_PRIVATE(name##_force_linkage) = \
&UPB_PRIVATE(name##_); \
diff --git a/upb/port/def.inc b/upb/port/def.inc
index 4616c65..b398a95 100644
--- a/upb/port/def.inc
+++ b/upb/port/def.inc
@@ -668,10 +668,10 @@
* to prevent optimizers from removing the constructor. Our solution is to
* create a dummy exported weak symbol that prevent this stripping.
*/
-#pragma section(".CRT$XCU", long, read)
+#pragma section(".CRT$XCT", read)
#define UPB_CONSTRUCTOR(name, unique_name) \
static void __cdecl UPB_PRIVATE(name)(void); \
- __declspec(allocate(".CRT$XCU"), selectany) void( \
+ __declspec(allocate(".CRT$XCT"), selectany) void( \
__cdecl * UPB_PRIVATE(name##_))(void) = UPB_PRIVATE(name); \
__declspec(selectany, dllexport) void* UPB_PRIVATE(name##_force_linkage) = \
&UPB_PRIVATE(name##_); \