diff options
author | Andreas Gampe <agampe@google.com> | 2014-09-12 18:38:24 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2014-09-15 22:34:11 -0700 |
commit | daab38ca60c5b91787e29c87a161a2bb8c1b6f11 (patch) | |
tree | 0b155557e516ec1ff571c359af904e00d31d0c43 /patchoat | |
parent | d2e5a6934ca1a07c9e1e87d3d0b21b63e1011934 (diff) | |
download | art-daab38ca60c5b91787e29c87a161a2bb8c1b6f11.zip art-daab38ca60c5b91787e29c87a161a2bb8c1b6f11.tar.gz art-daab38ca60c5b91787e29c87a161a2bb8c1b6f11.tar.bz2 |
ART: Make elf loading not abort
Changes elf_file code to use less CHECKs and instead return error
values (usually nullptr). This avoids aborts.
In oat_file, when loading an oat file fails, try to unlink at. If
this succeeds, on the next run we may compile again.
Bug: 17491333
(cherry picked from commit afa6b8e93a0dc0de33c9d404945c7c5621e20b1a)
Change-Id: I50fdd2edacd86f25d4dacf2180ce2a6105eaf4af
Diffstat (limited to 'patchoat')
-rw-r--r-- | patchoat/patchoat.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/patchoat/patchoat.cc b/patchoat/patchoat.cc index bbdf3a3..f89a4f7 100644 --- a/patchoat/patchoat.cc +++ b/patchoat/patchoat.cc @@ -522,14 +522,15 @@ bool PatchOat::PatchElf() { t.NewTiming("Fixup Elf Headers"); // Fixup Phdr's for (unsigned int i = 0; i < oat_file_->GetProgramHeaderNum(); i++) { - Elf32_Phdr& hdr = oat_file_->GetProgramHeader(i); - if (hdr.p_vaddr != 0 && hdr.p_vaddr != hdr.p_offset) { + Elf32_Phdr* hdr = oat_file_->GetProgramHeader(i); + CHECK(hdr != nullptr); + if (hdr->p_vaddr != 0 && hdr->p_vaddr != hdr->p_offset) { need_fixup = true; - hdr.p_vaddr += delta_; + hdr->p_vaddr += delta_; } - if (hdr.p_paddr != 0 && hdr.p_paddr != hdr.p_offset) { + if (hdr->p_paddr != 0 && hdr->p_paddr != hdr->p_offset) { need_fixup = true; - hdr.p_paddr += delta_; + hdr->p_paddr += delta_; } } if (!need_fixup) { @@ -539,9 +540,10 @@ bool PatchOat::PatchElf() { } t.NewTiming("Fixup Section Headers"); for (unsigned int i = 0; i < oat_file_->GetSectionHeaderNum(); i++) { - Elf32_Shdr& hdr = oat_file_->GetSectionHeader(i); - if (hdr.sh_addr != 0) { - hdr.sh_addr += delta_; + Elf32_Shdr* hdr = oat_file_->GetSectionHeader(i); + CHECK(hdr != nullptr); + if (hdr->sh_addr != 0) { + hdr->sh_addr += delta_; } } |