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

Side by Side Diff: courgette/disassembler_elf_32.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
« no previous file with comments | « no previous file | courgette/disassembler_elf_32_x86.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.h" 5 #include "courgette/disassembler_elf_32.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 std::vector<size_t>::iterator end_abs_offset = abs_offsets.end(); 256 std::vector<size_t>::iterator end_abs_offset = abs_offsets.end();
257 ScopedVector<TypedRVA>::iterator end_rel = rel32_locations_.end(); 257 ScopedVector<TypedRVA>::iterator end_rel = rel32_locations_.end();
258 258
259 for (int section_id = 0; 259 for (int section_id = 0;
260 section_id < SectionHeaderCount(); 260 section_id < SectionHeaderCount();
261 section_id++) { 261 section_id++) {
262 262
263 const Elf32_Shdr *section_header = SectionHeader(section_id); 263 const Elf32_Shdr *section_header = SectionHeader(section_id);
264 264
265 if (section_header->sh_type == SHT_NOBITS)
dgarrett 2014/10/20 18:15:44 This seems like the right thing to do... I'm surpr
Will Harris 2014/10/20 19:01:44 NOBITS are in almost every ELF file as the .bss is
266 continue;
267
265 if (!ParseSimpleRegion(file_offset, 268 if (!ParseSimpleRegion(file_offset,
266 section_header->sh_offset, 269 section_header->sh_offset,
267 program)) 270 program))
268 return false; 271 return false;
269 file_offset = section_header->sh_offset; 272 file_offset = section_header->sh_offset;
270 273
271 switch (section_header->sh_type) { 274 switch (section_header->sh_type) {
272 case SHT_REL: 275 case SHT_REL:
273 if (!ParseRelocationSection(section_header, program)) 276 if (!ParseRelocationSection(section_header, program))
274 return false; 277 return false;
275 file_offset = section_header->sh_offset + section_header->sh_size; 278 file_offset = section_header->sh_offset + section_header->sh_size;
276 break; 279 break;
277 case SHT_PROGBITS: 280 case SHT_PROGBITS:
278 if (!ParseProgbitsSection(section_header, 281 if (!ParseProgbitsSection(section_header,
279 &current_abs_offset, end_abs_offset, 282 &current_abs_offset, end_abs_offset,
280 &current_rel, end_rel, 283 &current_rel, end_rel,
281 program)) 284 program))
282 return false; 285 return false;
283 file_offset = section_header->sh_offset + section_header->sh_size; 286 file_offset = section_header->sh_offset + section_header->sh_size;
284 break; 287 break;
285 case SHT_NOBITS:
286 // Fall through
287 case SHT_INIT_ARRAY: 288 case SHT_INIT_ARRAY:
288 // Fall through 289 // Fall through
289 case SHT_FINI_ARRAY: 290 case SHT_FINI_ARRAY:
290 while (current_abs_offset != end_abs_offset && 291 while (current_abs_offset != end_abs_offset &&
291 *current_abs_offset >= section_header->sh_offset && 292 *current_abs_offset >= section_header->sh_offset &&
292 *current_abs_offset < 293 *current_abs_offset <
293 (section_header->sh_offset + section_header->sh_size)) { 294 (section_header->sh_offset + section_header->sh_size)) {
294 // Skip any abs_offsets appear in the unsupported INIT_ARRAY section 295 // Skip any abs_offsets appear in the unsupported INIT_ARRAY section
295 VLOG(1) << "Skipping relocation entry for unsupported section: " << 296 VLOG(1) << "Skipping relocation entry for unsupported section: " <<
296 section_header->sh_type; 297 section_header->sh_type;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 return false; 494 return false;
494 } 495 }
495 496
496 std::sort(rel32_locations_.begin(), 497 std::sort(rel32_locations_.begin(),
497 rel32_locations_.end(), 498 rel32_locations_.end(),
498 TypedRVA::IsLessThan); 499 TypedRVA::IsLessThan);
499 return true; 500 return true;
500 } 501 }
501 502
502 } // namespace courgette 503 } // namespace courgette
OLDNEW
« no previous file with comments | « no previous file | courgette/disassembler_elf_32_x86.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698