diff --git a/include/link/section.hpp b/include/link/section.hpp index 74541df4..8d4da7bf 100644 --- a/include/link/section.hpp +++ b/include/link/section.hpp @@ -48,7 +48,7 @@ struct Section { std::vector patches; // Extra info computed during linking std::vector *fileSymbols; - std::vector *symbols; + std::vector symbols; struct Section *nextu; // The next "component" of this unionized sect }; diff --git a/src/link/object.cpp b/src/link/object.cpp index a863c622..bab48816 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -356,18 +356,18 @@ static void readSection(FILE *file, struct Section *section, char const *fileNam */ static void linkSymToSect(struct Symbol &symbol, struct Section *section) { - uint32_t a = 0, b = section->symbols->size(); + uint32_t a = 0, b = section->symbols.size(); while (a != b) { uint32_t c = (a + b) / 2; - if ((*section->symbols)[c]->offset > symbol.offset) + if (section->symbols[c]->offset > symbol.offset) b = c; else a = c + 1; } - section->symbols->insert(section->symbols->begin() + a, &symbol); + section->symbols.insert(section->symbols.begin() + a, &symbol); } /* @@ -499,10 +499,7 @@ void obj_ReadFile(char const *fileName, unsigned int fileID) fileSections[i]->nextu = NULL; readSection(file, fileSections[i], fileName, nodes[fileID]); fileSections[i]->fileSymbols = &fileSymbols; - fileSections[i]->symbols = new(std::nothrow) std::vector(); - if (!fileSections[i]->symbols) - err("%s: Failed to link to symbols", fileName); - fileSections[i]->symbols->reserve(nbSymPerSect[i]); + fileSections[i]->symbols.reserve(nbSymPerSect[i]); sect_AddSection(fileSections[i]); } @@ -574,7 +571,6 @@ static void freeSection(struct Section *section) if (sect_HasData(section->type)) delete section->data; - delete section->symbols; delete section; section = next; diff --git a/src/link/output.cpp b/src/link/output.cpp index eeff9712..59e34d79 100644 --- a/src/link/output.cpp +++ b/src/link/output.cpp @@ -335,7 +335,7 @@ static void writeSymBank(struct SortedSections const &bankSections, uint32_t nbSymbols = 0; forEachSortedSection(sect, { - nbSymbols += sect->symbols->size(); + nbSymbols += sect->symbols.size(); }); if (!nbSymbols) @@ -346,7 +346,7 @@ static void writeSymBank(struct SortedSections const &bankSections, symList.reserve(nbSymbols); forEachSortedSection(sect, { - for (struct Symbol const *sym : *sect->symbols) { + for (struct Symbol const *sym : sect->symbols) { // Don't output symbols that begin with an illegal character if (!sym->name->empty() && canStartSymName((*sym->name)[0])) symList.push_back({ .sym = sym, .addr = (uint16_t)(sym->offset + sect->org) }); @@ -416,7 +416,7 @@ static void writeMapBank(struct SortedSections const §List, enum SectionType if (!noSymInMap) { // Also print symbols in the following "pieces" for (uint16_t org = sect->org; sect; sect = sect->nextu) { - for (struct Symbol *sym : *sect->symbols) + for (struct Symbol *sym : sect->symbols) // Space matches "\tSECTION: $xxxx ..." fprintf(mapFile, "\t $%04" PRIx32 " = %s\n", sym->offset + org, sym->name->c_str()); diff --git a/src/link/sdas_obj.cpp b/src/link/sdas_obj.cpp index 94b10444..a4a6b350 100644 --- a/src/link/sdas_obj.cpp +++ b/src/link/sdas_obj.cpp @@ -340,10 +340,6 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file, std::vectordata = NULL; curSection->fileSymbols = &fileSymbols; // IDs are instead per-section - curSection->symbols = new(std::nothrow) std::vector(); - if (!curSection->symbols) - fatal(where, lineNo, "Failed to alloc new area's symbol list: %s", - strerror(errno)); curSection->nextu = NULL; break; } @@ -409,7 +405,7 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file, std::vectorsymbols->push_back(&symbol); + fileSections.back().section->symbols.push_back(&symbol); expectEol("'S' line is too long"); break; @@ -730,7 +726,7 @@ void sdobj_ReadFile(struct FileStackNode const *where, FILE *file, std::vectormodifier == SECTION_FRAGMENT) { // Add the fragment's offset to all of its symbols - for (struct Symbol *symbol : *section->symbols) + for (struct Symbol *symbol : section->symbols) symbol->offset += section->offset; } }