From d3a9db3aff54ea485f409eaaef3d8f56ad77f0dc Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 5 Oct 2020 11:00:05 -0700 Subject: 6958 --- html/030translate.cc.html | 62 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'html/030translate.cc.html') diff --git a/html/030translate.cc.html b/html/030translate.cc.html index 52de2c83..b7b992ba 100644 --- a/html/030translate.cc.html +++ b/html/030translate.cc.html @@ -14,16 +14,16 @@ pre { white-space: pre-wrap; font-family: monospace; color: #000000; background- body { font-size:12pt; font-family: monospace; color: #000000; background-color: #c6c6c6; } a { color:inherit; } * { font-size:12pt; font-size: 1em; } +.PreProc { color: #c000c0; } .LineNr { } -.SalientComment { color: #0000af; } +.SpecialChar { color: #d70000; } .Constant { color: #008787; } .Comment { color: #005faf; } .Delimiter { color: #c000c0; } -.Special { color: #d70000; } .Identifier { color: #af5f00; } .Normal { color: #000000; background-color: #c6c6c6; padding-bottom: 1px; } -.PreProc { color: #c000c0; } .cSpecial { color: #008000; } +.SalientComment { color: #0000af; } --> @@ -67,15 +67,15 @@ if ('onhashchange' in window) { 6 //: be just machine code, suitable to emulate, or to write to an ELF binary. 7 8 :(before "End Main") - 9 if (is_equal(argv[1], "translate")) { + 9 if (is_equal(argv[1], "translate")) { 10 // Outside of tests, traces must be explicitly requested. - 11 if (Trace_file.is_open()) Trace_stream = new trace_stream; + 11 if (Trace_file.is_open()) Trace_stream = new trace_stream; 12 reset(); 13 // Begin bootstrap translate 14 program p; 15 string output_filename; 16 for (int i = /*skip 'bootstrap translate'*/2; i < argc; ++i) { - 17 if (is_equal(argv[i], "-o")) { + 17 if (is_equal(argv[i], "-o")) { 18 ++i; 19 if (i >= argc) { 20 print_translate_usage(); @@ -92,7 +92,7 @@ if ('onhashchange' in window) { 31 return 1; 32 } 33 parse(fin, p); - 34 if (trace_contains_errors()) return 1; + 34 if (trace_contains_errors()) return 1; 35 } 36 } 37 if (p.segments.empty()) { @@ -107,10 +107,10 @@ if ('onhashchange' in window) { 46 } 47 trace(2, "transform") << "begin" << end(); 48 transform(p); - 49 if (trace_contains_errors()) return 1; + 49 if (trace_contains_errors()) return 1; 50 trace(2, "translate") << "begin" << end(); 51 save_elf(p, output_filename); - 52 if (trace_contains_errors()) { + 52 if (trace_contains_errors()) { 53 unlink(output_filename.c_str()); 54 return 1; 55 } @@ -137,11 +137,11 @@ if ('onhashchange' in window) { 76 void save_elf(const program& p, ostream& out) { 77 // validation: stay consistent with the self-hosted translator 78 if (p.entry == 0) { - 79 raise << "no 'Entry' label found\n" << end(); + 79 raise << "no 'Entry' label found\n" << end(); 80 return; 81 } 82 if (find(p, "data") == NULL) { - 83 raise << "must include a 'data' segment\n" << end(); + 83 raise << "must include a 'data' segment\n" << end(); 84 return; 85 } 86 // processing @@ -152,22 +152,22 @@ if ('onhashchange' in window) { 91 92 void write_elf_header(ostream& out, const program& p) { 93 char c = '\0'; - 94 #define O(X) c = (X); out.write(&c, sizeof(c)) + 94 #define O(X) c = (X); out.write(&c, sizeof(c)) 95 // host is required to be little-endian - 96 #define emit(X) out.write(reinterpret_cast<const char*>(&X), sizeof(X)) + 96 #define emit(X) out.write(reinterpret_cast<const char*>(&X), sizeof(X)) 97 //// ehdr 98 // e_ident - 99 O(0x7f); O(/*E*/0x45); O(/*L*/0x4c); O(/*F*/0x46); -100 O(0x1); // 32-bit format -101 O(0x1); // little-endian -102 O(0x1); O(0x0); -103 for (size_t i = 0; i < 8; ++i) { O(0x0); } + 99 O(0x7f); O(/*E*/0x45); O(/*L*/0x4c); O(/*F*/0x46); +100 O(0x1); // 32-bit format +101 O(0x1); // little-endian +102 O(0x1); O(0x0); +103 for (size_t i = 0; i < 8; ++i) { O(0x0); } 104 // e_type -105 O(0x02); O(0x00); +105 O(0x02); O(0x00); 106 // e_machine -107 O(0x03); O(0x00); +107 O(0x03); O(0x00); 108 // e_version -109 O(0x01); O(0x00); O(0x00); O(0x00); +109 O(0x01); O(0x00); O(0x00); O(0x00); 110 // e_entry 111 uint32_t e_entry = p.entry; 112 // Override e_entry @@ -187,7 +187,7 @@ if ('onhashchange' in window) { 126 uint16_t e_phentsize = 0x20; 127 emit(e_phentsize); 128 // e_phnum -129 uint16_t e_phnum = SIZE(p.segments); +129 uint16_t e_phnum = SIZE(p.segments); 130 emit(e_phnum); 131 // e_shentsize 132 uint16_t dummy16 = 0x0; @@ -197,8 +197,8 @@ if ('onhashchange' in window) { 136 // e_shstrndx 137 emit(dummy16); 138 -139 uint32_t p_offset = /*size of ehdr*/0x34 + SIZE(p.segments)*0x20/*size of each phdr*/; -140 for (int i = 0; i < SIZE(p.segments); ++i) { +139 uint32_t p_offset = /*size of ehdr*/0x34 + SIZE(p.segments)*0x20/*size of each phdr*/; +140 for (int i = 0; i < SIZE(p.segments); ++i) { 141 const segment& curr = p.segments.at(i); 142 //// phdr 143 // p_type @@ -213,7 +213,7 @@ if ('onhashchange' in window) { 152 emit(p_start); 153 // p_filesz 154 uint32_t size = num_words(curr); -155 assert(p_offset + size < SEGMENT_ALIGNMENT); +155 assert(p_offset + size < SEGMENT_ALIGNMENT); 156 emit(size); 157 // p_memsz 158 emit(size); @@ -235,21 +235,21 @@ if ('onhashchange' in window) { 174 uint32_t p_align = 0x1000; // default page size on linux 175 emit(p_align); 176 if (p_offset % p_align != p_start % p_align) { -177 raise << "segment starting at 0x" << HEXWORD << p_start << " is improperly aligned; alignment for p_offset " << p_offset << " should be " << (p_offset % p_align) << " but is " << (p_start % p_align) << '\n' << end(); +177 raise << "segment starting at 0x" << HEXWORD << p_start << " is improperly aligned; alignment for p_offset " << p_offset << " should be " << (p_offset % p_align) << " but is " << (p_start % p_align) << '\n' << end(); 178 return; 179 } 180 181 // prepare for next segment 182 p_offset += size; 183 } -184 #undef O +184 #undef O 185 #undef emit 186 } 187 188 void write_segment(const segment& s, ostream& out) { -189 for (int i = 0; i < SIZE(s.lines); ++i) { +189 for (int i = 0; i < SIZE(s.lines); ++i) { 190 const vector<word>& w = s.lines.at(i).words; -191 for (int j = 0; j < SIZE(w); ++j) { +191 for (int j = 0; j < SIZE(w); ++j) { 192 uint8_t x = hex_byte(w.at(j).data); // we're done with metadata by this point 193 out.write(reinterpret_cast<const char*>(&x), /*sizeof(byte)*/1); 194 } @@ -258,8 +258,8 @@ if ('onhashchange' in window) { 197 198 uint32_t num_words(const segment& s) { 199 uint32_t sum = 0; -200 for (int i = 0; i < SIZE(s.lines); ++i) -201 sum += SIZE(s.lines.at(i).words); +200 for (int i = 0; i < SIZE(s.lines); ++i) +201 sum += SIZE(s.lines.at(i).words); 202 return sum; 203 } 204 -- cgit 1.4.1-2-gfad0