mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-07-02 11:28:13 +00:00
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
This commit is contained in:
parent
d7d532bf56
commit
d91bd8d23a
|
@ -44,7 +44,7 @@ void FindElfClassSection(const char *elf_base,
|
||||||
const char *section_name,
|
const char *section_name,
|
||||||
typename ElfClass::Word section_type,
|
typename ElfClass::Word section_type,
|
||||||
const void **section_start,
|
const void **section_start,
|
||||||
int *section_size) {
|
size_t *section_size) {
|
||||||
typedef typename ElfClass::Ehdr Ehdr;
|
typedef typename ElfClass::Ehdr Ehdr;
|
||||||
typedef typename ElfClass::Shdr Shdr;
|
typedef typename ElfClass::Shdr Shdr;
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@ void FindElfClassSection(const char *elf_base,
|
||||||
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
|
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
|
||||||
|
|
||||||
const Shdr* sections =
|
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 Shdr* section_names = sections + elf_header->e_shstrndx;
|
||||||
const char* names =
|
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 char *names_end = names + section_names->sh_size;
|
||||||
|
|
||||||
const Shdr* section =
|
const Shdr* section =
|
||||||
|
@ -79,7 +79,7 @@ template<typename ElfClass>
|
||||||
void FindElfClassSegment(const char *elf_base,
|
void FindElfClassSegment(const char *elf_base,
|
||||||
typename ElfClass::Word segment_type,
|
typename ElfClass::Word segment_type,
|
||||||
const void **segment_start,
|
const void **segment_start,
|
||||||
int *segment_size) {
|
size_t *segment_size) {
|
||||||
typedef typename ElfClass::Ehdr Ehdr;
|
typedef typename ElfClass::Ehdr Ehdr;
|
||||||
typedef typename ElfClass::Phdr Phdr;
|
typedef typename ElfClass::Phdr Phdr;
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ void FindElfClassSegment(const char *elf_base,
|
||||||
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
|
assert(elf_header->e_ident[EI_CLASS] == ElfClass::kClass);
|
||||||
|
|
||||||
const Phdr* phdrs =
|
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) {
|
for (int i = 0; i < elf_header->e_phnum; ++i) {
|
||||||
if (phdrs[i].p_type == segment_type) {
|
if (phdrs[i].p_type == segment_type) {
|
||||||
|
@ -122,7 +122,7 @@ bool FindElfSection(const void *elf_mapped_base,
|
||||||
const char *section_name,
|
const char *section_name,
|
||||||
uint32_t section_type,
|
uint32_t section_type,
|
||||||
const void **section_start,
|
const void **section_start,
|
||||||
int *section_size,
|
size_t *section_size,
|
||||||
int *elfclass) {
|
int *elfclass) {
|
||||||
assert(elf_mapped_base);
|
assert(elf_mapped_base);
|
||||||
assert(section_start);
|
assert(section_start);
|
||||||
|
@ -158,7 +158,7 @@ bool FindElfSection(const void *elf_mapped_base,
|
||||||
bool FindElfSegment(const void *elf_mapped_base,
|
bool FindElfSegment(const void *elf_mapped_base,
|
||||||
uint32_t segment_type,
|
uint32_t segment_type,
|
||||||
const void **segment_start,
|
const void **segment_start,
|
||||||
int *segment_size,
|
size_t *segment_size,
|
||||||
int *elfclass) {
|
int *elfclass) {
|
||||||
assert(elf_mapped_base);
|
assert(elf_mapped_base);
|
||||||
assert(segment_start);
|
assert(segment_start);
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
// elfutils.h: Utilities for dealing with ELF files.
|
// elfutils.h: Utilities for dealing with ELF files.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef COMMON_LINUX_ELFUTILS_H__
|
#ifndef COMMON_LINUX_ELFUTILS_H_
|
||||||
#define COMMON_LINUX_ELFUTILS_H__
|
#define COMMON_LINUX_ELFUTILS_H_
|
||||||
|
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
|
@ -79,7 +79,7 @@ bool FindElfSection(const void *elf_mapped_base,
|
||||||
const char *section_name,
|
const char *section_name,
|
||||||
uint32_t section_type,
|
uint32_t section_type,
|
||||||
const void **section_start,
|
const void **section_start,
|
||||||
int *section_size,
|
size_t *section_size,
|
||||||
int *elfclass);
|
int *elfclass);
|
||||||
|
|
||||||
// Internal helper method, exposed for convenience for callers
|
// Internal helper method, exposed for convenience for callers
|
||||||
|
@ -101,7 +101,7 @@ FindElfSectionByName(const char* name,
|
||||||
bool FindElfSegment(const void *elf_mapped_base,
|
bool FindElfSegment(const void *elf_mapped_base,
|
||||||
uint32_t segment_type,
|
uint32_t segment_type,
|
||||||
const void **segment_start,
|
const void **segment_start,
|
||||||
int *segment_size,
|
size_t *segment_size,
|
||||||
int *elfclass);
|
int *elfclass);
|
||||||
|
|
||||||
// Convert an offset from an Elf header into a pointer to the mapped
|
// 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
|
} // namespace google_breakpad
|
||||||
|
|
||||||
#endif // COMMON_LINUX_ELFUTILS_H__
|
#endif // COMMON_LINUX_ELFUTILS_H_
|
||||||
|
|
|
@ -57,7 +57,7 @@ FileID::FileID(const char* path) : path_(path) {}
|
||||||
// and use the syscall/libc wrappers instead of direct syscalls or libc.
|
// and use the syscall/libc wrappers instead of direct syscalls or libc.
|
||||||
|
|
||||||
template<typename ElfClass>
|
template<typename ElfClass>
|
||||||
static bool ElfClassBuildIDNoteIdentifier(const void *section, int length,
|
static bool ElfClassBuildIDNoteIdentifier(const void *section, size_t length,
|
||||||
uint8_t identifier[kMDGUIDSize]) {
|
uint8_t identifier[kMDGUIDSize]) {
|
||||||
typedef typename ElfClass::Nhdr Nhdr;
|
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,
|
static bool FindElfBuildIDNote(const void *elf_mapped_base,
|
||||||
uint8_t identifier[kMDGUIDSize]) {
|
uint8_t identifier[kMDGUIDSize]) {
|
||||||
void* note_section;
|
void* note_section;
|
||||||
int note_size, elfclass;
|
size_t note_size;
|
||||||
|
int elfclass;
|
||||||
if ((!FindElfSegment(elf_mapped_base, PT_NOTE,
|
if ((!FindElfSegment(elf_mapped_base, PT_NOTE,
|
||||||
(const void**)¬e_section, ¬e_size, &elfclass) ||
|
(const void**)¬e_section, ¬e_size, &elfclass) ||
|
||||||
note_size == 0) &&
|
note_size == 0) &&
|
||||||
|
@ -118,7 +119,7 @@ static bool FindElfBuildIDNote(const void *elf_mapped_base,
|
||||||
static bool HashElfTextSection(const void *elf_mapped_base,
|
static bool HashElfTextSection(const void *elf_mapped_base,
|
||||||
uint8_t identifier[kMDGUIDSize]) {
|
uint8_t identifier[kMDGUIDSize]) {
|
||||||
void* text_section;
|
void* text_section;
|
||||||
int text_size;
|
size_t text_size;
|
||||||
if (!FindElfSection(elf_mapped_base, ".text", SHT_PROGBITS,
|
if (!FindElfSection(elf_mapped_base, ".text", SHT_PROGBITS,
|
||||||
(const void**)&text_section, &text_size, NULL) ||
|
(const void**)&text_section, &text_size, NULL) ||
|
||||||
text_size == 0) {
|
text_size == 0) {
|
||||||
|
@ -127,7 +128,7 @@ static bool HashElfTextSection(const void *elf_mapped_base,
|
||||||
|
|
||||||
my_memset(identifier, 0, kMDGUIDSize);
|
my_memset(identifier, 0, kMDGUIDSize);
|
||||||
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(text_section);
|
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) {
|
while (ptr < ptr_end) {
|
||||||
for (unsigned i = 0; i < kMDGUIDSize; i++)
|
for (unsigned i = 0; i < kMDGUIDSize; i++)
|
||||||
identifier[i] ^= ptr[i];
|
identifier[i] ^= ptr[i];
|
||||||
|
|
Loading…
Reference in a new issue