Roll abseil_revision 38db52adb2..23f1f9cf6d

Change Log:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+log/38db52adb2..23f1f9cf6d
Full diff:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+/38db52adb2..23f1f9cf6d

Bug: None
Change-Id: I04510ff5e775ab2a7e0a80513f083f0b2e7994e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2288566
Reviewed-by: Mirko Bonadei <mbonadei@chromium.org>
Commit-Queue: Danil Chapovalov <danilchap@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#786709}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 9a4c868662c9c8c718fe7d7977f594554e34eb64
diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake
index 86ff9eb..8b2925c 100644
--- a/CMake/AbseilHelpers.cmake
+++ b/CMake/AbseilHelpers.cmake
@@ -23,7 +23,9 @@
 # project that sets
 #    set_property(GLOBAL PROPERTY USE_FOLDERS ON)
 # For example, Visual Studio supports folders.
-set(ABSL_IDE_FOLDER Abseil)
+if(NOT DEFINED ABSL_IDE_FOLDER)
+  set(ABSL_IDE_FOLDER Abseil)
+endif()
 
 # absl_cc_library()
 #
diff --git a/CMake/AbseilInstallDirs.cmake b/CMake/AbseilInstallDirs.cmake
index b67272f..6fc914b 100644
--- a/CMake/AbseilInstallDirs.cmake
+++ b/CMake/AbseilInstallDirs.cmake
@@ -10,11 +10,11 @@
   set(ABSL_SUBDIR "${PROJECT_NAME}_${PROJECT_VERSION}")
   set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}/${ABSL_SUBDIR}")
   set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${ABSL_SUBDIR}")
-  set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/{ABSL_SUBDIR}")
+  set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/${ABSL_SUBDIR}")
   set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${ABSL_SUBDIR}")
 else()
   set(ABSL_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
   set(ABSL_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
   set(ABSL_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}")
   set(ABSL_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
-endif()
\ No newline at end of file
+endif()
diff --git a/README.chromium b/README.chromium
index 6b5c628..f6db166 100644
--- a/README.chromium
+++ b/README.chromium
@@ -4,7 +4,7 @@
 License: Apache 2.0
 License File: LICENSE
 Version: 0
-Revision: 38db52adb2eabc0969195b33b30763e0a1285ef9
+Revision: 23f1f9cf6d02f834d55c0595566c0d607d4c5ed8
 Security Critical: yes
 
 Description:
diff --git a/absl/container/btree_test.cc b/absl/container/btree_test.cc
index 1738d29..c580807 100644
--- a/absl/container/btree_test.cc
+++ b/absl/container/btree_test.cc
@@ -2463,9 +2463,12 @@
   EXPECT_THAT(s2, ElementsAre(IsEmpty(), ElementsAre(IsNull())));
 }
 
-// GCC 4.9 has a bug in the std::pair constructors that prevents explicit
-// conversions between pair types.
-#if defined(__clang__) || !defined(__GNUC__) || __GNUC__ >= 5
+// libstdc++ included with GCC 4.9 has a bug in the std::pair constructors that
+// prevents explicit conversions between pair types.
+// We only run this test for the libstdc++ from GCC 7 or newer because we can't
+// reliably check the libstdc++ version prior to that release.
+#if !defined(__GLIBCXX__) || \
+    (defined(_GLIBCXX_RELEASE) && _GLIBCXX_RELEASE >= 7)
 TEST(Btree, MapRangeConstructorAndInsertSupportExplicitConversionComparable) {
   const std::pair<absl::string_view, int> names[] = {{"n1", 1}, {"n2", 2}};
 
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index f18dd4c..90bb96e 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -64,7 +64,7 @@
 // `std::vector` for use cases where the vector's size is sufficiently small
 // that it can be inlined. If the inlined vector does grow beyond its estimated
 // capacity, it will trigger an initial allocation on the heap, and will behave
-// as a `std:vector`. The API of the `absl::InlinedVector` within this file is
+// as a `std::vector`. The API of the `absl::InlinedVector` within this file is
 // designed to cover the same API footprint as covered by `std::vector`.
 template <typename T, size_t N, typename A = std::allocator<T>>
 class InlinedVector {
diff --git a/absl/debugging/symbolize_elf.inc b/absl/debugging/symbolize_elf.inc
index b7f8663..2f97cc7 100644
--- a/absl/debugging/symbolize_elf.inc
+++ b/absl/debugging/symbolize_elf.inc
@@ -57,6 +57,7 @@
 #include <unistd.h>
 
 #include <algorithm>
+#include <array>
 #include <atomic>
 #include <cerrno>
 #include <cinttypes>
@@ -184,6 +185,7 @@
         fd(-1),
         elf_type(-1) {
     SafeMemZero(&elf_header, sizeof(elf_header));
+    SafeMemZero(&phdr[0], sizeof(phdr));
   }
 
   char *filename;
@@ -196,6 +198,10 @@
   int fd;
   int elf_type;
   ElfW(Ehdr) elf_header;
+
+  // PT_LOAD program header describing executable code.
+  // Normally we expect just one, but SWIFT binaries have two.
+  std::array<ElfW(Phdr), 2> phdr;
 };
 
 // Build 4-way associative cache for symbols. Within each cache line, symbols
@@ -1272,6 +1278,36 @@
       ABSL_RAW_LOG(WARNING, "%s: failed to read elf header", obj->filename);
       return false;
     }
+    const int phnum = obj->elf_header.e_phnum;
+    const int phentsize = obj->elf_header.e_phentsize;
+    size_t phoff = obj->elf_header.e_phoff;
+    int num_executable_load_segments = 0;
+    for (int j = 0; j < phnum; j++) {
+      ElfW(Phdr) phdr;
+      if (!ReadFromOffsetExact(obj->fd, &phdr, sizeof(phdr), phoff)) {
+        ABSL_RAW_LOG(WARNING, "%s: failed to read program header %d",
+                     obj->filename, j);
+        return false;
+      }
+      phoff += phentsize;
+      constexpr int rx = PF_X | PF_R;
+      if (phdr.p_type != PT_LOAD || (phdr.p_flags & rx) != rx) {
+        // Not a LOAD segment, or not executable code.
+        continue;
+      }
+      if (num_executable_load_segments < obj->phdr.size()) {
+        memcpy(&obj->phdr[num_executable_load_segments++], &phdr, sizeof(phdr));
+      } else {
+        ABSL_RAW_LOG(WARNING, "%s: too many executable LOAD segments",
+                     obj->filename);
+        break;
+      }
+    }
+    if (num_executable_load_segments == 0) {
+      // This object has no "r-x" LOAD segments. That's unexpected.
+      ABSL_RAW_LOG(WARNING, "%s: no executable LOAD segments", obj->filename);
+      return false;
+    }
   }
   return true;
 }
@@ -1295,23 +1331,52 @@
   int fd = -1;
   if (obj != nullptr) {
     if (MaybeInitializeObjFile(obj)) {
-      if (obj->elf_type == ET_DYN &&
-          reinterpret_cast<uint64_t>(obj->start_addr) >= obj->offset) {
+      const size_t start_addr = reinterpret_cast<size_t>(obj->start_addr);
+      if (obj->elf_type == ET_DYN && start_addr >= obj->offset) {
         // This object was relocated.
         //
         // For obj->offset > 0, adjust the relocation since a mapping at offset
         // X in the file will have a start address of [true relocation]+X.
-        relocation = reinterpret_cast<ptrdiff_t>(obj->start_addr) - obj->offset;
+        relocation = start_addr - obj->offset;
+
+        // Note: some binaries have multiple "rx" LOAD segments. We must
+        // find the right one.
+        ElfW(Phdr) *phdr = nullptr;
+        for (int j = 0; j < obj->phdr.size(); j++) {
+          ElfW(Phdr) &p = obj->phdr[j];
+          if (p.p_type != PT_LOAD) {
+            // We only expect PT_LOADs. This must be PT_NULL that we didn't
+            // write over (i.e. we exhausted all interesting PT_LOADs).
+            ABSL_RAW_CHECK(p.p_type == PT_NULL, "unexpected p_type");
+            break;
+          }
+          if (pc < reinterpret_cast<void *>(start_addr + p.p_memsz)) {
+            phdr = &p;
+            break;
+          }
+        }
+        if (phdr == nullptr) {
+          // That's unexpected. Hope for the best.
+          ABSL_RAW_LOG(
+              WARNING,
+              "%s: unable to find LOAD segment for pc: %p, start_addr: %zx",
+              obj->filename, pc, start_addr);
+        } else {
+          // Adjust relocation in case phdr.p_vaddr != 0.
+          // This happens for binaries linked with `lld --rosegment`, and for
+          // binaries linked with BFD `ld -z separate-code`.
+          relocation -= phdr->p_vaddr - phdr->p_offset;
+        }
       }
 
       fd = obj->fd;
-    }
-    if (GetSymbolFromObjectFile(*obj, pc, relocation, symbol_buf_,
-                                sizeof(symbol_buf_), tmp_buf_,
-                                sizeof(tmp_buf_)) == SYMBOL_FOUND) {
-      // Only try to demangle the symbol name if it fit into symbol_buf_.
-      DemangleInplace(symbol_buf_, sizeof(symbol_buf_), tmp_buf_,
-                      sizeof(tmp_buf_));
+      if (GetSymbolFromObjectFile(*obj, pc, relocation, symbol_buf_,
+                                  sizeof(symbol_buf_), tmp_buf_,
+                                  sizeof(tmp_buf_)) == SYMBOL_FOUND) {
+        // Only try to demangle the symbol name if it fit into symbol_buf_.
+        DemangleInplace(symbol_buf_, sizeof(symbol_buf_), tmp_buf_,
+                        sizeof(tmp_buf_));
+      }
     }
   } else {
 #if ABSL_HAVE_VDSO_SUPPORT
diff --git a/ci/linux_docker_containers.sh b/ci/linux_docker_containers.sh
index 82a10ac..b652071 100644
--- a/ci/linux_docker_containers.sh
+++ b/ci/linux_docker_containers.sh
@@ -16,6 +16,6 @@
 # Test scripts should source this file to get the identifiers.
 
 readonly LINUX_ALPINE_CONTAINER="gcr.io/google.com/absl-177019/alpine:20191016"
-readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20200401"
+readonly LINUX_CLANG_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_clang-latest:20200706"
 readonly LINUX_GCC_LATEST_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-latest:20200319"
 readonly LINUX_GCC_49_CONTAINER="gcr.io/google.com/absl-177019/linux_gcc-4.9:20191018"
diff --git a/patches/0002-Manual-ABSL_DLL-fixes.patch b/patches/0002-Manual-ABSL_DLL-fixes.patch
deleted file mode 100644
index 19b82b2..0000000
--- a/patches/0002-Manual-ABSL_DLL-fixes.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-From 330cb7c7a62ab3187a6a2a3dc3a7b92f3690677c Mon Sep 17 00:00:00 2001
-From: Mirko Bonadei <mbonadei@chromium.org>
-Date: Wed, 17 Jun 2020 21:37:18 +0200
-Subject: [PATCH] Manual ABSL_DLL fixes.
-
----
- third_party/abseil-cpp/absl/base/internal/raw_logging.cc | 2 +-
- third_party/abseil-cpp/absl/base/internal/raw_logging.h  | 2 +-
- third_party/abseil-cpp/absl/strings/string_view.h        | 2 +-
- 3 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc
-index 40cea5506172..f27e2838d72b 100644
---- a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc
-+++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc
-@@ -227,7 +227,7 @@ bool RawLoggingFullySupported() {
- #endif  // !ABSL_LOW_LEVEL_WRITE_SUPPORTED
- }
- 
--ABSL_DLL ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
-+ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL
-     absl::base_internal::AtomicHook<InternalLogFunction>
-         internal_log_function(DefaultInternalLog);
- 
-diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.h b/third_party/abseil-cpp/absl/base/internal/raw_logging.h
-index 418d6c856feb..51551bafff48 100644
---- a/third_party/abseil-cpp/absl/base/internal/raw_logging.h
-+++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.h
-@@ -170,7 +170,7 @@ using InternalLogFunction = void (*)(absl::LogSeverity severity,
-                                      const char* file, int line,
-                                      const std::string& message);
- 
--ABSL_DLL ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES extern base_internal::AtomicHook<
-+ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL extern base_internal::AtomicHook<
-     InternalLogFunction>
-     internal_log_function;
- 
-diff --git a/third_party/abseil-cpp/absl/strings/string_view.h b/third_party/abseil-cpp/absl/strings/string_view.h
-index 8a9db8c3d796..7fb033300338 100644
---- a/third_party/abseil-cpp/absl/strings/string_view.h
-+++ b/third_party/abseil-cpp/absl/strings/string_view.h
-@@ -586,7 +586,7 @@ constexpr bool operator>=(string_view x, string_view y) noexcept {
- }
- 
- // IO Insertion Operator
--std::ostream& operator<<(std::ostream& o, string_view piece);
-+ABSL_DLL std::ostream& operator<<(std::ostream& o, string_view piece);
- 
- ABSL_NAMESPACE_END
- }  // namespace absl
--- 
-2.27.0.290.gba653c62da-goog
-