From 1f08b541af47398afb3f64968b2fc5e96c58b7bb Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Wed, 24 Oct 2018 23:28:03 -0700 Subject: 4724 --- html/subx/034compute_segment_address.cc.html | 82 ++++++++++++++-------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'html/subx/034compute_segment_address.cc.html') diff --git a/html/subx/034compute_segment_address.cc.html b/html/subx/034compute_segment_address.cc.html index c180ef12..d1a500e1 100644 --- a/html/subx/034compute_segment_address.cc.html +++ b/html/subx/034compute_segment_address.cc.html @@ -72,7 +72,7 @@ if ('onhashchange' in window) { 11 +load: 0x09000056 -> 0b 12 +load: 0x09000057 -> 0c 13 +load: 0x09000058 -> 0d - 14 +run: add imm32 0x0d0c0b0a to reg EAX + 14 +run: add imm32 0x0d0c0b0a to reg EAX 15 +run: storing 0x0d0c0b0a 16 17 //: Update the parser to handle non-numeric segment name. @@ -82,45 +82,45 @@ if ('onhashchange' in window) { 21 //: the new data to existing data for the segment. 22 23 :(before "End Globals") - 24 map</*name*/string, int> Segment_index; - 25 bool Currently_parsing_named_segment = false; // global to permit cross-layer communication - 26 int Currently_parsing_segment_index = -1; // global to permit cross-layer communication + 24 map</*name*/string, int> Segment_index; + 25 bool Currently_parsing_named_segment = false; // global to permit cross-layer communication + 26 int Currently_parsing_segment_index = -1; // global to permit cross-layer communication 27 :(before "End Reset") - 28 Segment_index.clear(); - 29 Currently_parsing_named_segment = false; - 30 Currently_parsing_segment_index = -1; + 28 Segment_index.clear(); + 29 Currently_parsing_named_segment = false; + 30 Currently_parsing_segment_index = -1; 31 32 :(before "End Segment Parsing Special-cases(segment_title)") 33 if (!starts_with(segment_title, "0x")) { - 34 Currently_parsing_named_segment = true; - 35 if (!contains_key(Segment_index, segment_title)) { - 36 trace(99, "parse") << "new segment '" << segment_title << "'" << end(); + 34 Currently_parsing_named_segment = true; + 35 if (!contains_key(Segment_index, segment_title)) { + 36 trace(99, "parse") << "new segment '" << segment_title << "'" << end(); 37 if (segment_title == "code") - 38 put(Segment_index, segment_title, 0); + 38 put(Segment_index, segment_title, 0); 39 else if (segment_title == "data") - 40 put(Segment_index, segment_title, 1); + 40 put(Segment_index, segment_title, 1); 41 else - 42 put(Segment_index, segment_title, max(2, SIZE(out.segments))); - 43 out.segments.push_back(segment()); + 42 put(Segment_index, segment_title, max(2, SIZE(out.segments))); + 43 out.segments.push_back(segment()); 44 } 45 else { - 46 trace(99, "parse") << "prepending to segment '" << segment_title << "'" << end(); + 46 trace(99, "parse") << "prepending to segment '" << segment_title << "'" << end(); 47 } - 48 Currently_parsing_segment_index = get(Segment_index, segment_title); + 48 Currently_parsing_segment_index = get(Segment_index, segment_title); 49 } 50 51 :(before "End flush(p, lines) Special-cases") - 52 if (Currently_parsing_named_segment) { - 53 if (p.segments.empty() || Currently_parsing_segment_index < 0) { - 54 raise << "input does not start with a '==' section header\n" << end(); + 52 if (Currently_parsing_named_segment) { + 53 if (p.segments.empty() || Currently_parsing_segment_index < 0) { + 54 raise << "input does not start with a '==' section header\n" << end(); 55 return; 56 } - 57 trace(99, "parse") << "flushing to segment" << end(); - 58 vector<line>& curr_segment_data = p.segments.at(Currently_parsing_segment_index).lines; - 59 curr_segment_data.insert(curr_segment_data.begin(), lines.begin(), lines.end()); - 60 lines.clear(); - 61 Currently_parsing_named_segment = false; - 62 Currently_parsing_segment_index = -1; + 57 trace(99, "parse") << "flushing to segment" << end(); + 58 vector<line>& curr_segment_data = p.segments.at(Currently_parsing_segment_index).lines; + 59 curr_segment_data.insert(curr_segment_data.begin(), lines.begin(), lines.end()); + 60 lines.clear(); + 61 Currently_parsing_named_segment = false; + 62 Currently_parsing_segment_index = -1; 63 return; 64 } 65 @@ -145,35 +145,35 @@ if ('onhashchange' in window) { 84 //: compute segment address 85 86 :(before "End Level-2 Transforms") - 87 Transform.push_back(compute_segment_starts); + 87 Transform.push_back(compute_segment_starts); 88 89 :(code) - 90 void compute_segment_starts(program& p) { - 91 trace(99, "transform") << "-- compute segment addresses" << end(); - 92 uint32_t p_offset = /*size of ehdr*/0x34 + SIZE(p.segments)*0x20/*size of each phdr*/; - 93 for (size_t i = 0; i < p.segments.size(); ++i) { - 94 segment& curr = p.segments.at(i); + 90 void compute_segment_starts(program& p) { + 91 trace(99, "transform") << "-- compute segment addresses" << end(); + 92 uint32_t p_offset = /*size of ehdr*/0x34 + SIZE(p.segments)*0x20/*size of each phdr*/; + 93 for (size_t i = 0; i < p.segments.size(); ++i) { + 94 segment& curr = p.segments.at(i); 95 if (curr.start == 0) { - 96 curr.start = CODE_SEGMENT + i*SPACE_FOR_SEGMENT + p_offset; - 97 trace(99, "transform") << "segment " << i << " begins at address 0x" << HEXWORD << curr.start << end(); + 96 curr.start = CODE_SEGMENT + i*SPACE_FOR_SEGMENT + p_offset; + 97 trace(99, "transform") << "segment " << i << " begins at address 0x" << HEXWORD << curr.start << end(); 98 } - 99 p_offset += size_of(curr); -100 assert(p_offset < INITIAL_SEGMENT_SIZE); // for now we get less and less available space in each successive segment + 99 p_offset += size_of(curr); +100 assert(p_offset < INITIAL_SEGMENT_SIZE); // for now we get less and less available space in each successive segment 101 } 102 } 103 -104 uint32_t size_of(const segment& s) { +104 uint32_t size_of(const segment& s) { 105 uint32_t sum = 0; -106 for (int i = 0; i < SIZE(s.lines); ++i) -107 sum += num_bytes(s.lines.at(i)); +106 for (int i = 0; i < SIZE(s.lines); ++i) +107 sum += num_bytes(s.lines.at(i)); 108 return sum; 109 } 110 111 // Assumes all bitfields are packed. -112 uint32_t num_bytes(const line& inst) { +112 uint32_t num_bytes(const line& inst) { 113 uint32_t sum = 0; -114 for (int i = 0; i < SIZE(inst.words); ++i) { -115 const word& curr = inst.words.at(i); +114 for (int i = 0; i < SIZE(inst.words); ++i) { +115 const word& curr = inst.words.at(i); 116 if (has_operand_metadata(curr, "disp32") || has_operand_metadata(curr, "imm32")) // only multi-byte operands 117 sum += 4; 118 // End num_bytes(curr) Special-cases -- cgit 1.4.1-2-gfad0