summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-devtools/protobuf/protobuf/0001-Lower-init-prio-for-extension-attributes.patch79
-rw-r--r--meta-oe/recipes-devtools/protobuf/protobuf_3.19.1.bb1
2 files changed, 80 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf/0001-Lower-init-prio-for-extension-attributes.patch b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Lower-init-prio-for-extension-attributes.patch
new file mode 100644
index 0000000000..a1200e01c1
--- /dev/null
+++ b/meta-oe/recipes-devtools/protobuf/protobuf/0001-Lower-init-prio-for-extension-attributes.patch
@@ -0,0 +1,79 @@
1From 8ff34dbff1eac612326b492d0b2cb93901ad7e2b Mon Sep 17 00:00:00 2001
2From: Jani Nurminen <jani.nurminen@windriver.com>
3Date: Fri, 24 Sep 2021 09:56:11 +0200
4Subject: [PATCH] Lower init prio for extension attributes
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Added PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY in
10code generation for extension attributes.
11It has lower prio than PROTOBUF_ATTRIBUTE_INIT_PRIORITY to
12ensure that extension attributes are initialized after
13other attribute.
14This is needed in some applications to avoid segmentation fault.
15
16Reported by Karl-Herman Näslund.
17
18Signed-off-by: Jani Nurminen <jani.nurminen@windriver.com>
19
20Rebase on master
21
22Signed-off-by: He Zhe <zhe.he@windriver.com>
23---
24 src/google/protobuf/compiler/cpp/cpp_extension.cc | 2 +-
25 src/google/protobuf/port_def.inc | 12 ++++++++++++
26 src/google/protobuf/port_undef.inc | 1 +
27 3 files changed, 14 insertions(+), 1 deletion(-)
28
29diff --git a/src/google/protobuf/compiler/cpp/cpp_extension.cc b/src/google/protobuf/compiler/cpp/cpp_extension.cc
30index 8604da5f2..984345ebe 100644
31--- a/src/google/protobuf/compiler/cpp/cpp_extension.cc
32+++ b/src/google/protobuf/compiler/cpp/cpp_extension.cc
33@@ -164,7 +164,7 @@ void ExtensionGenerator::GenerateDefinition(io::Printer* printer) {
34 }
35
36 format(
37- "PROTOBUF_ATTRIBUTE_INIT_PRIORITY "
38+ "PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY "
39 "::$proto_ns$::internal::ExtensionIdentifier< $extendee$,\n"
40 " ::$proto_ns$::internal::$type_traits$, $field_type$, $packed$ >\n"
41 " $scoped_name$($constant_name$, $1$);\n",
42diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc
43index 7e9119112..a5117090d 100644
44--- a/src/google/protobuf/port_def.inc
45+++ b/src/google/protobuf/port_def.inc
46@@ -614,6 +614,18 @@
47 #define PROTOBUF_ATTRIBUTE_INIT_PRIORITY
48 #endif
49
50+// Some embedded systems get a segmentation fault if extension attributes are
51+// initialized with higher or equal priority as other attributes. This gives
52+// extension attributes high priority, but lower than other attributes.
53+#ifdef PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY
54+#error PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY was previously defined
55+#endif
56+#if PROTOBUF_GNUC_MIN(3, 0) && (!defined(__APPLE__) || defined(__clang__)) && !((defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)))
57+#define PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY __attribute__((init_priority((103))))
58+#else
59+#define PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY
60+#endif
61+
62 #ifdef PROTOBUF_PRAGMA_INIT_SEG
63 #error PROTOBUF_PRAGMA_INIT_SEG was previously defined
64 #endif
65diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc
66index ccc5daf56..2b28f3a31 100644
67--- a/src/google/protobuf/port_undef.inc
68+++ b/src/google/protobuf/port_undef.inc
69@@ -83,6 +83,7 @@
70 #undef PROTOBUF_HAVE_ATTRIBUTE_WEAK
71 #undef PROTOBUF_ATTRIBUTE_NO_DESTROY
72 #undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY
73+#undef PROTOBUF_EXTENSION_ATTRIBUTE_INIT_PRIORITY
74 #undef PROTOBUF_PRAGMA_INIT_SEG
75 #undef PROTOBUF_ASAN
76 #undef PROTOBUF_MSAN
77--
782.26.2
79
diff --git a/meta-oe/recipes-devtools/protobuf/protobuf_3.19.1.bb b/meta-oe/recipes-devtools/protobuf/protobuf_3.19.1.bb
index bff159590d..8491dbdf57 100644
--- a/meta-oe/recipes-devtools/protobuf/protobuf_3.19.1.bb
+++ b/meta-oe/recipes-devtools/protobuf/protobuf_3.19.1.bb
@@ -18,6 +18,7 @@ SRC_URI = "git://github.com/protocolbuffers/protobuf.git;branch=3.19.x;protocol=
18 file://0001-Makefile.am-include-descriptor.cc-when-building-libp.patch \ 18 file://0001-Makefile.am-include-descriptor.cc-when-building-libp.patch \
19 file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \ 19 file://0001-examples-Makefile-respect-CXX-LDFLAGS-variables-fix-.patch \
20 file://0001-Fix-linking-error-with-ld-gold.patch \ 20 file://0001-Fix-linking-error-with-ld-gold.patch \
21 file://0001-Lower-init-prio-for-extension-attributes.patch \
21 " 22 "
22SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch " 23SRC_URI:append:mips:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "
23SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch " 24SRC_URI:append:mipsel:toolchain-clang = " file://0001-Fix-build-on-mips-clang.patch "