Make LZMA SDK compatibility shims conditional on the version of the SDK.
Shims were previously introduced because Chromium's LZMA SDK is behind
Android's. In this CL, we revise the shims so that they are conditional
based on the LZMA SDK version in use. This should allow us to update
Chromium's LZMA SDK. Ideally, these shims can be removed after Chromium
is updated.
Bug: 1224596
Change-Id: I4a28edb0033be4c0f2db5b9c00dcb65f7694b9be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/third_party/libunwindstack/+/2996428
Reviewed-by: Mike Wittman <wittman@chromium.org>
Bot-Commit: Mike Wittman <wittman@chromium.org>
diff --git a/patches/0001-lzma-interface.patch b/patches/0001-lzma-interface.patch
index 9ddff9e..b5b74ba 100644
--- a/patches/0001-lzma-interface.patch
+++ b/patches/0001-lzma-interface.patch
@@ -1,24 +1,39 @@
diff --git a/src/libunwindstack/ElfInterface.cpp b/src/libunwindstack/ElfInterface.cpp
-index 341275dbb..8725ad375 100644
+index 821e042..e2cac45 100644
--- a/src/libunwindstack/ElfInterface.cpp
+++ b/src/libunwindstack/ElfInterface.cpp
-@@ -39,6 +39,10 @@
+@@ -22,6 +22,7 @@
+ #include <utility>
+
+ #include <7zCrc.h>
++#include <7zVersion.h>
+ #include <Xz.h>
+ #include <XzCrc64.h>
+
+@@ -39,6 +40,12 @@
namespace unwindstack {
++#if MY_VER_MAJOR < 17
+namespace {
+typedef void* ISzAllocPtr;
+} // namespace
++#endif
+
ElfInterface::~ElfInterface() {
for (auto symbol : symbols_) {
delete symbol;
-@@ -129,7 +133,7 @@ Memory* ElfInterface::CreateGnuDebugdataMemory() {
+@@ -128,8 +135,13 @@ Memory* ElfInterface::CreateGnuDebugdataMemory() {
+ }
dst_remaining += buffer_increment;
}
- return_val = XzUnpacker_Code(&state, dst->GetPtr(dst_offset), &dst_remaining, &src[src_offset],
-- &src_remaining, true, CODER_FINISH_ANY, &status);
++#if MY_VER_MAJOR < 18 || (MY_VER_MAJOR == 18 && MY_VER_MINOR < 3)
++ return_val = XzUnpacker_Code(&state, dst->GetPtr(dst_offset), &dst_remaining, &src[src_offset],
+ &src_remaining, CODER_FINISH_ANY, &status);
++#else
+ return_val = XzUnpacker_Code(&state, dst->GetPtr(dst_offset), &dst_remaining, &src[src_offset],
+ &src_remaining, true, CODER_FINISH_ANY, &status);
++#endif
src_offset += src_remaining;
dst_offset += dst_remaining;
} while (return_val == SZ_OK && status == CODER_STATUS_NOT_FINISHED);
diff --git a/src/libunwindstack/ElfInterface.cpp b/src/libunwindstack/ElfInterface.cpp
index b9d0e44..e2cac45 100644
--- a/src/libunwindstack/ElfInterface.cpp
+++ b/src/libunwindstack/ElfInterface.cpp
@@ -22,6 +22,7 @@
#include <utility>
#include <7zCrc.h>
+#include <7zVersion.h>
#include <Xz.h>
#include <XzCrc64.h>
@@ -39,9 +40,11 @@
namespace unwindstack {
+#if MY_VER_MAJOR < 17
namespace {
typedef void* ISzAllocPtr;
} // namespace
+#endif
ElfInterface::~ElfInterface() {
for (auto symbol : symbols_) {
@@ -132,8 +135,13 @@
}
dst_remaining += buffer_increment;
}
+#if MY_VER_MAJOR < 18 || (MY_VER_MAJOR == 18 && MY_VER_MINOR < 3)
return_val = XzUnpacker_Code(&state, dst->GetPtr(dst_offset), &dst_remaining, &src[src_offset],
&src_remaining, CODER_FINISH_ANY, &status);
+#else
+ return_val = XzUnpacker_Code(&state, dst->GetPtr(dst_offset), &dst_remaining, &src[src_offset],
+ &src_remaining, true, CODER_FINISH_ANY, &status);
+#endif
src_offset += src_remaining;
dst_offset += dst_remaining;
} while (return_val == SZ_OK && status == CODER_STATUS_NOT_FINISHED);