diff options
author | huangs <huangs@chromium.org> | 2016-01-19 14:09:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-19 22:11:12 +0000 |
commit | bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e (patch) | |
tree | 67781fd3df79bd04ed728c2555bcce6a574d609f /courgette/disassembler_win32_x64.cc | |
parent | 7f6dad4f0bdb435323452ba420d34b2e7ee536cc (diff) | |
download | chromium_src-bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e.zip chromium_src-bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e.tar.gz chromium_src-bb4b8a90a34d7a36b9a83cb663e9f29f12d16a3e.tar.bz2 |
[Courgette] Simplify EncodedProgram Label addition code; removed "1.01 x" memory fix.
This CL simplifies how Labels get flattened to a list of RVAs. In the past
EncodedProgram used DefineAbs32Label() / DefineRel32Label(), which let callers
add one Label at a time. Complexity arose from:
- Function pointer usage to avoid duplicate code for abs32 and rel32.
- Need for EncodedProgram to dynamically adjust size of RVA list. This led to
inefficient array resizing, which was fixed by the "1.01 x" memory growth.
Change: We now pass the collection of abs32 and rel32 Labels to EncodedProgram.
This simplifies the interface, and allows EncodedProgram to find the max indexes
and preallocated buffers. The trade-off is increased test code complexity, since
we'd need to create Label collection.
Other changes:
- Update namespace{} for EncodedProgram and its tests.
- Add more Label constructors (for testing).
- Add LabelManager::GetIndexBound(), for LabelVector and RVAToLabel.
- Add kUnassignedRVA in image_utils.h, with checks for its absence in images.
Review URL: https://codereview.chromium.org/1571913003
Cr-Commit-Position: refs/heads/master@{#370200}
Diffstat (limited to 'courgette/disassembler_win32_x64.cc')
-rw-r--r-- | courgette/disassembler_win32_x64.cc | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/courgette/disassembler_win32_x64.cc b/courgette/disassembler_win32_x64.cc index 357930d..74b0fe4 100644 --- a/courgette/disassembler_win32_x64.cc +++ b/courgette/disassembler_win32_x64.cc @@ -281,6 +281,7 @@ bool DisassemblerWin32X64::ParseRelocs(std::vector<RVA> *relocs) { } std::sort(relocs->begin(), relocs->end()); + DCHECK(relocs->empty() || relocs->back() != kUnassignedRVA); return true; } @@ -396,6 +397,8 @@ void DisassemblerWin32X64::ParseRel32RelocsFromSections() { file_offset += section->size_of_raw_data; } std::sort(rel32_locations_.begin(), rel32_locations_.end()); + DCHECK(rel32_locations_.empty() || + rel32_locations_.back() != kUnassignedRVA); #if COURGETTE_HISTOGRAM_TARGETS VLOG(1) << "abs32_locations_ " << abs32_locations_.size() |