1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70

base / third_party / symbolize / patches / 006-use-sandbox-hook-for-open-object-file.patch [blame]

diff --git a/base/third_party/symbolize/symbolize.cc b/base/third_party/symbolize/symbolize.cc
index 3c72fd1183f48..20d4d4106d65b 100644
--- a/base/third_party/symbolize/symbolize.cc
+++ b/base/third_party/symbolize/symbolize.cc
@@ -491,11 +491,12 @@ static char *GetHex(const char *start, const char *end, uint64_t *hex) {
   return const_cast<char *>(p);
 }
 
-int OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
-                                                 uint64_t& start_address,
-                                                 uint64_t& base_address,
-                                                 char* out_file_name,
-                                                 size_t out_file_name_size) {
+static int OpenObjectFileContainingPcAndGetStartAddressNoHook(
+    uint64_t pc,
+    uint64_t& start_address,
+    uint64_t& base_address,
+    char* out_file_name,
+    size_t out_file_name_size) {
   int object_fd;
 
   int maps_fd;
@@ -645,6 +646,20 @@ int OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
   }
 }
 
+int OpenObjectFileContainingPcAndGetStartAddress(
+    uint64_t pc,
+    uint64_t& start_address,
+    uint64_t& base_address,
+    char* out_file_name,
+    size_t out_file_name_size) {
+  if (g_symbolize_open_object_file_callback) {
+    return g_symbolize_open_object_file_callback(
+        pc, start_address, base_address, out_file_name, out_file_name_size);
+  }
+  return OpenObjectFileContainingPcAndGetStartAddressNoHook(
+      pc, start_address, base_address, out_file_name, out_file_name_size);
+}
+
 // POSIX doesn't define any async-signal safe function for converting
 // an integer to ASCII. We'll have to define our own version.
 // itoa_r() converts an (unsigned) integer to ASCII. It returns "buf", if the
@@ -734,7 +749,6 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
   uint64_t pc0 = reinterpret_cast<uintptr_t>(pc);
   uint64_t start_address = 0;
   uint64_t base_address = 0;
-  int object_fd = -1;
 
   if (out_size < 1) {
     return false;
@@ -742,16 +756,8 @@ static ATTRIBUTE_NOINLINE bool SymbolizeAndDemangle(void *pc, char *out,
   out[0] = '\0';
   SafeAppendString("(", out, out_size);
 
-  if (g_symbolize_open_object_file_callback) {
-    object_fd = g_symbolize_open_object_file_callback(pc0, start_address,
-                                                      base_address, out + 1,
-                                                      out_size - 1);
-  } else {
-    object_fd = OpenObjectFileContainingPcAndGetStartAddress(pc0, start_address,
-                                                             base_address,
-                                                             out + 1,
-                                                             out_size - 1);
-  }
+  int object_fd = OpenObjectFileContainingPcAndGetStartAddress(
+      pc0, start_address, base_address, out + 1, out_size - 1);
 
   FileDescriptor wrapped_object_fd(object_fd);