Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: courgette/disassembler_elf_32_x86.cc

Issue 664803002: Fix courgette ELF x86 dissembler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: rogue extra line Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "courgette/disassembler_elf_32_x86.h" 5 #include "courgette/disassembler_elf_32_x86.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // Walk all the bytes in the section, matching relocation table or not 84 // Walk all the bytes in the section, matching relocation table or not
85 size_t file_offset = section_header->sh_offset; 85 size_t file_offset = section_header->sh_offset;
86 size_t section_end = section_header->sh_offset + section_header->sh_size; 86 size_t section_end = section_header->sh_offset + section_header->sh_size;
87 87
88 Elf32_Rel *section_relocs_iter = 88 Elf32_Rel *section_relocs_iter =
89 (Elf32_Rel *)OffsetToPointer(section_header->sh_offset); 89 (Elf32_Rel *)OffsetToPointer(section_header->sh_offset);
90 90
91 uint32 section_relocs_count = section_header->sh_size / 91 uint32 section_relocs_count = section_header->sh_size /
92 section_header->sh_entsize; 92 section_header->sh_entsize;
93 93
94 if (abs32_locations_.empty())
95 match = false;
96
94 if (abs32_locations_.size() > section_relocs_count) 97 if (abs32_locations_.size() > section_relocs_count)
95 match = false; 98 match = false;
96 99
97 std::vector<RVA>::iterator reloc_iter = abs32_locations_.begin(); 100 std::vector<RVA>::iterator reloc_iter = abs32_locations_.begin();
98 101
99 while (match && (reloc_iter != abs32_locations_.end())) { 102 while (match && (reloc_iter != abs32_locations_.end())) {
100 if (section_relocs_iter->r_info != R_386_RELATIVE || 103 if (section_relocs_iter->r_info != R_386_RELATIVE ||
101 section_relocs_iter->r_offset != *reloc_iter) 104 section_relocs_iter->r_offset != *reloc_iter)
102 match = false; 105 match = false;
103 section_relocs_iter++; 106 section_relocs_iter++;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 delete rel32_rva; 174 delete rel32_rva;
172 } 175 }
173 } 176 }
174 p += 1; 177 p += 1;
175 } 178 }
176 179
177 return true; 180 return true;
178 } 181 }
179 182
180 } // namespace courgette 183 } // namespace courgette
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698