aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux/elfutils.cc
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2023-08-11 03:01:22 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-08-11 03:01:22 +0000
commitfe0b979764663486600861261cb885ba27aeb491 (patch)
treef98d11d6a158167e19fc9141c79d877280a616a6 /src/common/linux/elfutils.cc
parent8d0176459cfc11e28e9427a7eadcf7a42f654f62 (diff)
parent1317aa642182906c0d8ab5496dd3025632e22022 (diff)
downloadgoogle-breakpad-fe0b979764663486600861261cb885ba27aeb491.tar.gz
Upgrade google-breakpad to v2023.01.27 am: 332a4371ed am: c3c25b3748 am: 4e7c6460d7 am: c9c160dbfd am: 1317aa6421
Original change: https://android-review.googlesource.com/c/platform/external/google-breakpad/+/2704174 Change-Id: I1cb5f0b860fff4523f331cce12735979ae56fd20 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/common/linux/elfutils.cc')
-rw-r--r--src/common/linux/elfutils.cc33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/common/linux/elfutils.cc b/src/common/linux/elfutils.cc
index 9532d5ad..a68cc0af 100644
--- a/src/common/linux/elfutils.cc
+++ b/src/common/linux/elfutils.cc
@@ -1,5 +1,4 @@
-// Copyright (c) 2012, Google Inc.
-// All rights reserved.
+// Copyright 2012 Google LLC
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -11,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Google Inc. nor the names of its
+// * Neither the name of Google LLC nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
@@ -40,11 +39,11 @@ namespace google_breakpad {
namespace {
template<typename ElfClass>
-void FindElfClassSection(const char *elf_base,
- const char *section_name,
+void FindElfClassSection(const char* elf_base,
+ const char* section_name,
typename ElfClass::Word section_type,
- const void **section_start,
- size_t *section_size) {
+ const void** section_start,
+ size_t* section_size) {
typedef typename ElfClass::Ehdr Ehdr;
typedef typename ElfClass::Shdr Shdr;
@@ -57,12 +56,18 @@ void FindElfClassSection(const char *elf_base,
const Ehdr* elf_header = reinterpret_cast<const Ehdr*>(elf_base);
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
+ if (elf_header->e_shoff == 0) {
+ *section_start = NULL;
+ *section_size = 0;
+ return;
+ }
+
const Shdr* sections =
GetOffset<ElfClass, Shdr>(elf_header, elf_header->e_shoff);
const Shdr* section_names = sections + elf_header->e_shstrndx;
const char* names =
GetOffset<ElfClass, char>(elf_header, section_names->sh_offset);
- const char *names_end = names + section_names->sh_size;
+ const char* names_end = names + section_names->sh_size;
const Shdr* section =
FindElfSectionByName<ElfClass>(section_name, section_type,
@@ -76,9 +81,9 @@ void FindElfClassSection(const char *elf_base,
}
template<typename ElfClass>
-void FindElfClassSegment(const char *elf_base,
+void FindElfClassSegment(const char* elf_base,
typename ElfClass::Word segment_type,
- wasteful_vector<ElfSegment> *segments) {
+ wasteful_vector<ElfSegment>* segments) {
typedef typename ElfClass::Ehdr Ehdr;
typedef typename ElfClass::Phdr Phdr;
@@ -117,11 +122,11 @@ int ElfClass(const void* elf_base) {
return elf_header->e_ident[EI_CLASS];
}
-bool FindElfSection(const void *elf_mapped_base,
- const char *section_name,
+bool FindElfSection(const void* elf_mapped_base,
+ const char* section_name,
uint32_t section_type,
- const void **section_start,
- size_t *section_size) {
+ const void** section_start,
+ size_t* section_size) {
assert(elf_mapped_base);
assert(section_start);
assert(section_size);