Index: base/strings/string_number_conversions_dup.cc |
diff --git a/base/strings/string_number_conversions_dup.cc b/base/strings/string_number_conversions_dup.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0decb2fc73dff4e3afb6a46d5f3cff9a1093687e |
--- /dev/null |
+++ b/base/strings/string_number_conversions_dup.cc |
@@ -0,0 +1,41 @@ |
+#include <string> |
+#include <vector> |
+#include <stdint.h> |
+ |
+namespace hack { |
+ |
+bool CharToDigit(char c, uint8_t* digit) { |
+ if (c >= '0' && c <= '9') { |
+ *digit = c - '0'; |
+ } else if (c >= 'a' && c < 'a' + 16 - 10) { |
+ *digit = c - 'a' + 10; |
+ } else if (c >= 'A' && c < 'A' + 16 - 10) { |
+ *digit = c - 'A' + 10; |
+ } else { |
+ return false; |
+ } |
+ return true; |
+} |
+ |
+bool HexStringToBytes(const std::string& input, std::vector<uint8_t>* output) { |
+ size_t count = input.size(); |
+ if (count == 0 || (count % 2) != 0) |
+ return false; |
+ for (uintptr_t i = 0; i < count / 2; ++i) { |
+ uint8_t msb = 0; // most significant 4 bits |
+ uint8_t lsb = 0; // least significant 4 bits |
+ if (!CharToDigit(input[i * 2], &msb) || |
+ !CharToDigit(input[i * 2 + 1], &lsb)) |
+ return false; |
+ output->push_back((msb << 4) | lsb); |
+ } |
+ return true; |
+} |
+ |
+void f() { |
+ // Make sure we have 1MB of code, so that the string accesses above have to |
+ // use adrp instead of adr. |
+ __asm__(".zero 1048576"); |
+} |
+ |
+} |