Merge "Fix usage of Read instead of ReadFully."

This commit is contained in:
Christopher Ferris 2019-01-16 15:27:01 +00:00 committed by Gerrit Code Review
commit 61f4ceb55a
2 changed files with 6 additions and 6 deletions

View file

@ -177,14 +177,14 @@ bool ElfInterface::ReadAllHeaders(uint64_t* load_bias) {
template <typename EhdrType, typename PhdrType>
uint64_t ElfInterface::GetLoadBias(Memory* memory) {
EhdrType ehdr;
if (!memory->Read(0, &ehdr, sizeof(ehdr))) {
if (!memory->ReadFully(0, &ehdr, sizeof(ehdr))) {
return false;
}
uint64_t offset = ehdr.e_phoff;
for (size_t i = 0; i < ehdr.e_phnum; i++, offset += ehdr.e_phentsize) {
PhdrType phdr;
if (!memory->Read(offset, &phdr, sizeof(phdr))) {
if (!memory->ReadFully(offset, &phdr, sizeof(phdr))) {
return 0;
}
if (phdr.p_type == PT_LOAD && phdr.p_offset == 0) {
@ -308,7 +308,7 @@ void ElfInterface::ReadSectionHeaders(const EhdrType& ehdr) {
// Skip the first header, it's always going to be NULL.
offset += ehdr.e_shentsize;
for (size_t i = 1; i < ehdr.e_shnum; i++, offset += ehdr.e_shentsize) {
if (!memory_->Read(offset, &shdr, sizeof(shdr))) {
if (!memory_->ReadFully(offset, &shdr, sizeof(shdr))) {
return;
}
@ -320,7 +320,7 @@ void ElfInterface::ReadSectionHeaders(const EhdrType& ehdr) {
continue;
}
uint64_t str_offset = ehdr.e_shoff + shdr.sh_link * ehdr.e_shentsize;
if (!memory_->Read(str_offset, &str_shdr, sizeof(str_shdr))) {
if (!memory_->ReadFully(str_offset, &str_shdr, sizeof(str_shdr))) {
continue;
}
if (str_shdr.sh_type != SHT_STRTAB) {

View file

@ -135,7 +135,7 @@ bool RegsMips::StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_me
Memory* elf_memory = elf->memory();
// Read from elf memory since it is usually more expensive to read from
// process memory.
if (!elf_memory->Read(rel_pc, &data, sizeof(data))) {
if (!elf_memory->ReadFully(rel_pc, &data, sizeof(data))) {
return false;
}
@ -160,7 +160,7 @@ bool RegsMips::StepIfSignalHandler(uint64_t rel_pc, Elf* elf, Memory* process_me
// read sc_pc and sc_regs[32] from stack
uint64_t values[MIPS_REG_LAST];
if (!process_memory->Read(regs_[MIPS_REG_SP] + offset, values, sizeof(values))) {
if (!process_memory->ReadFully(regs_[MIPS_REG_SP] + offset, values, sizeof(values))) {
return false;
}