OLD | NEW |
---|---|
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 Loading... | |
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 ¤t_abs_offset, end_abs_offset, | 282 ¤t_abs_offset, end_abs_offset, |
280 ¤t_rel, end_rel, | 283 ¤t_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 Loading... | |
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 |
OLD | NEW |