11 static const bool debug =
false;
92 fprintf(stderr,
"COFF aux func %s: bf_idx=%u, size=%u, lnum_ptr=%u, next_fn_idx=%u, res1=%u\n",
105 fprintf(stderr,
"COFF aux %s: res1=%u, lnum=%u, res2=%u, res3=%u, next_bf=%u, res4=%u\n",
117 fprintf(stderr,
"COFF aux weak %s: sym2_idx=%u, flags=%u, res1=%u, res2=%u, res3=%u\n",
127 if (fname_offset < 4)
throw FormatError(
"name collides with size field");
130 fprintf(stderr,
"COFF aux file: offset=%"PRIu64
", name=\"%s\"\n",
131 fname_offset,
get_name()->get_string(
true).c_str());
136 char fname[COFFSymbol_disk_size+1];
137 memcpy(fname, &(
p_aux_data[0]), COFFSymbol_disk_size);
141 fprintf(stderr,
"COFF aux file: inline-name=\"%s\"\n",
get_name()->get_string(
true).c_str());
159 "COFF aux section: size=%u, nrel=%u, nln_ents=%u, cksum=%u, sect_id=%u, comdat=%u, res1=%u, res2=%u\n",
160 size, nrel, nln_ents, cksum, sect_id, comdat, res1, res2);
167 fprintf(stderr,
"COFF aux comdat %s: (FIXME) not implemented yet\n",
escapeString(
p_st_name).c_str());
171 fprintf(stderr,
"COFF aux unknown %s: (FIXME) st_storage_class=%u, st_type=0x%02x, st_section_num=%d\n",
207 char p[4096], ss[128], tt[128];
208 const char *s=NULL, *t=NULL;
210 sprintf(p,
"%sCOFFSymbol[%zd].", prefix, idx);
212 sprintf(p,
"%sCOFFSymbol.", prefix);
221 case 0: s =
"external, not assigned";
break;
222 case -1: s =
"absolute value";
break;
223 case -2: s =
"general debug, no section";
break;
226 fprintf(f,
"%s%-*s = %s\n", p, w,
"st_section_num", s);
229 case 0x00: s =
"none";
break;
230 case 0x10: s =
"pointer";
break;
231 case 0x20: s =
"function";
break;
232 case 0x30: s =
"array";
break;
239 case 0x00: t =
"none";
break;
240 case 0x01: t =
"void";
break;
241 case 0x02: t =
"char";
break;
242 case 0x03: t =
"short";
break;
243 case 0x04: t =
"int";
break;
244 case 0x05: t =
"long";
break;
245 case 0x06: t =
"float";
break;
246 case 0x07: t =
"double";
break;
247 case 0x08: t =
"struct";
break;
248 case 0x09: t =
"union";
break;
249 case 0x0a: t =
"enum";
break;
250 case 0x0b: t =
"enum member";
break;
251 case 0x0c: t =
"byte";
break;
252 case 0x0d: t =
"2-byte word";
break;
253 case 0x0e: t =
"unsigned int";
break;
254 case 0x0f: t =
"4-byte unsigned";
break;
260 fprintf(f,
"%s%-*s = %s / %s\n", p, w,
"st_type", s, t);
263 case 0: s =
"none"; t =
"";
break;
264 case 1: s =
"auto variable"; t =
"stack frame offset";
break;
265 case 2: s =
"external"; t =
"size or section offset";
break;
266 case 3: s =
"static"; t =
"offset in section or section name";
break;
267 case 4: s =
"register"; t =
"register number";
break;
268 case 5: s =
"extern_def"; t =
"";
break;
269 case 6: s =
"label"; t =
"offset in section";
break;
270 case 7: s =
"label(undef)"; t =
"";
break;
271 case 8: s =
"struct member"; t =
"member number";
break;
272 case 9: s =
"formal arg"; t =
"argument number";
break;
273 case 10: s =
"struct tag"; t =
"tag name";
break;
274 case 11: s =
"union member"; t =
"member number";
break;
275 case 12: s =
"union tag"; t =
"tag name";
break;
276 case 13: s =
"typedef"; t =
"";
break;
277 case 14: s =
"static(undef)"; t =
"";
break;
278 case 15: s =
"enum tag"; t =
"";
break;
279 case 16: s =
"enum member"; t =
"member number";
break;
280 case 17: s =
"register param"; t =
"";
break;
281 case 18: s =
"bit field"; t =
"bit number";
break;
282 case 19: s =
"auto arg"; t =
"";
break;
283 case 20: s =
"dummy entry (EOB)"; t=
"";
break;
284 case 100: s =
"block(bb,eb)"; t =
"relocatable address";
break;
285 case 101: s =
"function"; t =
"nlines or size";
break;
286 case 102: s =
"struct end"; t =
"";
break;
287 case 103: s =
"file"; t =
"";
break;
288 case 104: s =
"section/line#"; t =
"";
break;
289 case 105: s =
"weak extern"; t =
"";
break;
290 case 106: s =
"ext in dmert pub lib";t=
"";
break;
291 case 107: s =
"CLR token"; t =
"";
break;
292 case 0xff: s =
"end of function"; t =
"";
break;
299 fprintf(f,
"%s%-*s = %s\n", p, w,
"st_storage_class", s);
302 fprintf(f,
"%s%-*s = %zu bytes\n", p, w,
"aux_data",
p_aux_data.size());
323 ROSE_ASSERT(fhdr!=NULL);
343 if (strtab_size <
sizeof(uint32_t))
344 throw FormatError(
"COFF symbol table string table size is less than four bytes");
354 fprintf(stderr,
"SgAsmCoffSymbolTable::parse: warning: read past end of section \"%s\" [%d]\n"
355 " symbol #%zu at file offset 0x%08"PRIx64
"\n"
356 " skipping %zu symbols (including this one)\n",
373 size_t nslots = nsyms;
374 for (
size_t i=0; i<nsyms; i++) {
404 sprintf(p,
"%sCOFFSymtab[%zd].", prefix, idx);
406 sprintf(p,
"%sCOFFSymtab.", prefix);