static void sectionMapping(IO &IO, ELFYAML::MipsABIFlags &Section) { commonSectionMapping(IO, Section); IO.mapOptional("Version", Section.Version, Hex16(0)); IO.mapRequired("ISA", Section.ISALevel); IO.mapOptional("ISARevision", Section.ISARevision, Hex8(0)); IO.mapOptional("ISAExtension", Section.ISAExtension, ELFYAML::MIPS_AFL_EXT(Mips::AFL_EXT_NONE)); IO.mapOptional("ASEs", Section.ASEs, ELFYAML::MIPS_AFL_ASE(0)); IO.mapOptional("FpABI", Section.FpABI, ELFYAML::MIPS_ABI_FP(Mips::Val_GNU_MIPS_ABI_FP_ANY)); IO.mapOptional("GPRSize", Section.GPRSize, ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE)); IO.mapOptional("CPR1Size", Section.CPR1Size, ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE)); IO.mapOptional("CPR2Size", Section.CPR2Size, ELFYAML::MIPS_AFL_REG(Mips::AFL_REG_NONE)); IO.mapOptional("Flags1", Section.Flags1, ELFYAML::MIPS_AFL_FLAGS1(0)); IO.mapOptional("Flags2", Section.Flags2, Hex32(0)); }
void Rebuild_Data(SYMBOL *sym) { SYMBOL *thisSym; //uint ta = 0; int ip; int len; int n; int c; int left; int align; int opt_bss; // decode the field ip = sym->Value; if (sym->Type == SECT_bss) ip += MaxDataIP; len = sym->EndIP; left = len; // Has this been done already if (ArrayGet(&LabelDone, ip)) return; // Mark as done ArraySet(&LabelDone, ip, 1); if (!len) { len = FindLabelExtent(ip); if (!len) { RebuildEmit("// empty %s_%d,%d\n", sym->Name, sym->LocalScope, len); return; } // Save the result for later sym->EndIP = len; RebuildEmit("// found extent %s_%d,%d\n", sym->Name, sym->LocalScope, len); } align = ArrayGet(&DataAlignArray, ip); if (sym->Type == SECT_bss) { RebuildEmit("\t.comm %s_%d,%d\n", sym->Name, sym->LocalScope, len); return; } if (sym->Type != SECT_data) Error(Error_System, "(Rebuild_Data) Illegal section in data output"); // Check if this data field can be moved to bss #if 1 opt_bss = Rebuild_CanMoveToBss(ip, len); if (opt_bss) { // Make sure bss output is aligned int bss_len = len; while(bss_len & 3) bss_len++; RebuildEmit("\t.comm %s_%d,%d //moved to bss\n", sym->Name, sym->LocalScope, bss_len); return; } #endif if (align) RebuildEmit("\t.align %d\n", align); // write a data section field RebuildEmit("%s_%d:\n", sym->Name, sym->LocalScope ); // write array c = 0; for (n=ip;n<ip+len;n++) { thisSym = (SYMBOL *) ArrayGet(&DataArray, n); if (!thisSym) { RebuildEmit("\t.byte 0x%s\n", Hex8(GetDataMem(n)) ); left--; continue; } // check if we hit a .word reference if (left >= 4) { if (thisSym) { SYMBOL *labref = NULL; int addr; addr = thisSym->Value; if (thisSym->Type == SECT_code) { labref = (SYMBOL *) ArrayGet(&CodeLabelArray, addr); if (labref == 0) Error(Error_System, "Could not repoint label !!"); // labref = thisSym; } if (thisSym->Type == SECT_data) { labref = (SYMBOL *) ArrayGet(&LabelArray, addr); if (labref == 0) Error(Error_System, "Could not repoint label !!"); } if (thisSym->Type == SECT_bss) { labref = (SYMBOL *) ArrayGet(&LabelArray, addr + MaxDataIP); if (labref == 0) Error(Error_System, "Could not repoint label !!"); } if(labref == NULL) Error(Error_System, "Broken label"); RebuildEmit("\t.word %s_%d\n", labref->Name, labref->LocalScope); left-=4; n+=3; } } } RebuildEmit("\n\n"); return; }