aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2014-07-17 18:34:18 +0000
committerthestig@chromium.org <thestig@chromium.org@4c0a9323-5329-0410-9bdc-e9ce6186880e>2014-07-17 18:34:18 +0000
commitd91bd8d23a80da30496b09a657b3325202b70803 (patch)
treec649c31ede15572239eaaaa692b38e38f2b9c08f
parentEnsure C:/Dumps/ exists in crash_generation_app (diff)
downloadbreakpad-d91bd8d23a80da30496b09a657b3325202b70803.tar.xz
Change some ELF utils to return the length as a size_t.
R=mark@chromium.org Review URL: https://breakpad.appspot.com/7694002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1349 4c0a9323-5329-0410-9bdc-e9ce6186880e
-rw-r--r--src/common/linux/elfutils.cc14
-rw-r--r--src/common/linux/elfutils.h10
-rw-r--r--src/common/linux/file_id.cc9
3 files changed, 17 insertions, 16 deletions
diff --git a/src/common/linux/elfutils.cc b/src/common/linux/elfutils.cc
index 1fd504d9..a79391c1 100644
--- a/src/common/linux/elfutils.cc
+++ b/src/common/linux/elfutils.cc
@@ -44,7 +44,7 @@ void FindElfClassSection(const char *elf_base,
const char *section_name,
typename ElfClass::Word section_type,
const void **section_start,
- int *section_size) {
+ size_t *section_size) {
typedef typename ElfClass::Ehdr Ehdr;
typedef typename ElfClass::Shdr Shdr;
@@ -58,10 +58,10 @@ void FindElfClassSection(const char *elf_base,
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
const Shdr* sections =
- GetOffset<ElfClass,Shdr>(elf_header, elf_header->e_shoff);
+ 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);
+ GetOffset<ElfClass, char>(elf_header, section_names->sh_offset);
const char *names_end = names + section_names->sh_size;
const Shdr* section =
@@ -79,7 +79,7 @@ template<typename ElfClass>
void FindElfClassSegment(const char *elf_base,
typename ElfClass::Word segment_type,
const void **segment_start,
- int *segment_size) {
+ size_t *segment_size) {
typedef typename ElfClass::Ehdr Ehdr;
typedef typename ElfClass::Phdr Phdr;
@@ -93,7 +93,7 @@ void FindElfClassSegment(const char *elf_base,
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
const Phdr* phdrs =
- GetOffset<ElfClass,Phdr>(elf_header, elf_header->e_phoff);
+ GetOffset<ElfClass, Phdr>(elf_header, elf_header->e_phoff);
for (int i = 0; i < elf_header->e_phnum; ++i) {
if (phdrs[i].p_type == segment_type) {
@@ -122,7 +122,7 @@ bool FindElfSection(const void *elf_mapped_base,
const char *section_name,
uint32_t section_type,
const void **section_start,
- int *section_size,
+ size_t *section_size,
int *elfclass) {
assert(elf_mapped_base);
assert(section_start);
@@ -158,7 +158,7 @@ bool FindElfSection(const void *elf_mapped_base,
bool FindElfSegment(const void *elf_mapped_base,
uint32_t segment_type,
const void **segment_start,
- int *segment_size,
+ size_t *segment_size,
int *elfclass) {
assert(elf_mapped_base);
assert(segment_start);
diff --git a/src/common/linux/elfutils.h b/src/common/linux/elfutils.h
index fe12e251..dccdc235 100644
--- a/src/common/linux/elfutils.h
+++ b/src/common/linux/elfutils.h
@@ -30,8 +30,8 @@
// elfutils.h: Utilities for dealing with ELF files.
//
-#ifndef COMMON_LINUX_ELFUTILS_H__
-#define COMMON_LINUX_ELFUTILS_H__
+#ifndef COMMON_LINUX_ELFUTILS_H_
+#define COMMON_LINUX_ELFUTILS_H_
#include <elf.h>
#include <link.h>
@@ -79,7 +79,7 @@ bool FindElfSection(const void *elf_mapped_base,
const char *section_name,
uint32_t section_type,
const void **section_start,
- int *section_size,
+ size_t *section_size,
int *elfclass);
// Internal helper method, exposed for convenience for callers
@@ -101,7 +101,7 @@ FindElfSectionByName(const char* name,
bool FindElfSegment(const void *elf_mapped_base,
uint32_t segment_type,
const void **segment_start,
- int *segment_size,
+ size_t *segment_size,
int *elfclass);
// Convert an offset from an Elf header into a pointer to the mapped
@@ -115,4 +115,4 @@ GetOffset(const typename ElfClass::Ehdr* elf_header,
} // namespace google_breakpad
-#endif // COMMON_LINUX_ELFUTILS_H__
+#endif // COMMON_LINUX_ELFUTILS_H_
diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc
index 31ea9da5..dc74e9e0 100644
--- a/src/common/linux/file_id.cc
+++ b/src/common/linux/file_id.cc
@@ -57,7 +57,7 @@ FileID::FileID(const char* path) : path_(path) {}
// and use the syscall/libc wrappers instead of direct syscalls or libc.
template<typename ElfClass>
-static bool ElfClassBuildIDNoteIdentifier(const void *section, int length,
+static bool ElfClassBuildIDNoteIdentifier(const void *section, size_t length,
uint8_t identifier[kMDGUIDSize]) {
typedef typename ElfClass::Nhdr Nhdr;
@@ -92,7 +92,8 @@ static bool ElfClassBuildIDNoteIdentifier(const void *section, int length,
static bool FindElfBuildIDNote(const void *elf_mapped_base,
uint8_t identifier[kMDGUIDSize]) {
void* note_section;
- int note_size, elfclass;
+ size_t note_size;
+ int elfclass;
if ((!FindElfSegment(elf_mapped_base, PT_NOTE,
(const void**)&note_section, &note_size, &elfclass) ||
note_size == 0) &&
@@ -118,7 +119,7 @@ static bool FindElfBuildIDNote(const void *elf_mapped_base,
static bool HashElfTextSection(const void *elf_mapped_base,
uint8_t identifier[kMDGUIDSize]) {
void* text_section;
- int text_size;
+ size_t text_size;
if (!FindElfSection(elf_mapped_base, ".text", SHT_PROGBITS,
(const void**)&text_section, &text_size, NULL) ||
text_size == 0) {
@@ -127,7 +128,7 @@ static bool HashElfTextSection(const void *elf_mapped_base,
my_memset(identifier, 0, kMDGUIDSize);
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(text_section);
- const uint8_t* ptr_end = ptr + std::min(text_size, 4096);
+ const uint8_t* ptr_end = ptr + std::min(text_size, static_cast<size_t>(4096));
while (ptr < ptr_end) {
for (unsigned i = 0; i < kMDGUIDSize; i++)
identifier[i] ^= ptr[i];