aapt2/patches/androidfw.patch
oSumAtrIX 8285e73cd7
fix: Specify minimum alignment for ResStringPool_span to fix SIGBUS on ARMv7
Apparently, a SIGSEGV is also fixed by that.
2024-07-17 18:29:18 +02:00

71 lines
2.8 KiB
Diff

Submodule src/base contains modified content
diff --git a/src/base/libs/androidfw/ResourceTypes.cpp b/src/base/libs/androidfw/ResourceTypes.cpp
index cae2d0bc16b3..13c5f8fc84e8 100644
--- a/src/base/libs/androidfw/ResourceTypes.cpp
+++ b/src/base/libs/androidfw/ResourceTypes.cpp
@@ -43,7 +43,7 @@
#include <utils/String16.h>
#include <utils/String8.h>
-#ifdef __ANDROID__
+#if 0
#include <binder/TextOutput.h>
#endif
diff --git a/src/base/libs/androidfw/include/androidfw/ResourceTypes.h b/libs/androidfw/include/androidfw/ResourceTypes.h
index 3d66244646d5..2d27c34a9154 100644
--- a/src/base/libs/androidfw/include/androidfw/ResourceTypes.h
+++ b/src/base/libs/androidfw/include/androidfw/ResourceTypes.h
@@ -500,7 +500,7 @@ struct ResStringPool_span
// The range of characters in the string that this span applies to.
uint32_t firstChar, lastChar;
-};
+} __attribute__((__packed__, aligned(1)));
/**
* Convenience class for accessing data in a ResStringPool resource.
diff --git a/src/base/libs/androidfw/include/androidfw/StringPiece.h b/src/base/libs/androidfw/include/androidfw/StringPiece.h
index 921877dc4982..27e27e1c2b94 100644
--- a/src/base/libs/androidfw/include/androidfw/StringPiece.h
+++ b/src/base/libs/androidfw/include/androidfw/StringPiece.h
@@ -75,6 +75,11 @@ class BasicStringPiece {
bool operator>(const BasicStringPiece<TChar>& rhs) const;
bool operator==(const BasicStringPiece<TChar>& rhs) const;
bool operator!=(const BasicStringPiece<TChar>& rhs) const;
+ // for std::basic_string
+ bool operator<(const std::basic_string<TChar>& rhs) const;
+ bool operator>(const std::basic_string<TChar>& rhs) const;
+ bool operator==(const std::basic_string<TChar>& rhs) const;
+ bool operator!=(const std::basic_string<TChar>& rhs) const;
const_iterator begin() const;
const_iterator end() const;
@@ -256,6 +261,26 @@ inline bool BasicStringPiece<TChar>::operator!=(const BasicStringPiece<TChar>& r
return compare(rhs) != 0;
}
+template <typename TChar>
+inline bool BasicStringPiece<TChar>::operator<(const std::basic_string<TChar>& rhs) const {
+ return compare(BasicStringPiece(rhs)) < 0;
+}
+
+template <typename TChar>
+inline bool BasicStringPiece<TChar>::operator>(const std::basic_string<TChar>& rhs) const {
+ return compare(BasicStringPiece(rhs)) > 0;
+}
+
+template <typename TChar>
+inline bool BasicStringPiece<TChar>::operator==(const std::basic_string<TChar>& rhs) const {
+ return compare(BasicStringPiece(rhs)) == 0;
+}
+
+template <typename TChar>
+inline bool BasicStringPiece<TChar>::operator!=(const std::basic_string<TChar>& rhs) const{
+ return compare(BasicStringPiece(rhs)) != 0;
+}
+
template <typename TChar>
inline typename BasicStringPiece<TChar>::const_iterator BasicStringPiece<TChar>::begin() const {
return data_;