Use std::string for symbol/section/node names and assertion messages

This commit is contained in:
Rangi42
2024-02-27 18:59:38 -05:00
committed by Sylvie
parent a24df27cd8
commit 48b2e94aa3
12 changed files with 172 additions and 201 deletions

View File

@@ -6,6 +6,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <vector>
#include "helpers.hpp"
@@ -35,7 +36,7 @@ struct FileStackNode {
enum FileStackNodeType type;
union {
char *name; // NODE_FILE, NODE_MACRO
std::string *name; // NODE_FILE, NODE_MACRO
std::vector<uint32_t> *iters; // NODE_REPT
};
};
@@ -50,7 +51,7 @@ struct FileStackNode {
* Dump a file stack to stderr
* @param node The leaf node to dump the context of
*/
char const *dumpFileStack(struct FileStackNode const *node);
std::string const *dumpFileStack(struct FileStackNode const *node);
void warning(struct FileStackNode const *where, uint32_t lineNo,
char const *fmt, ...) format_(printf, 3, 4);

View File

@@ -14,7 +14,7 @@
struct Assertion {
struct Patch patch; // Also used for its `.type`
char *message;
std::string *message;
// This would be redundant with `.section->fileSymbols`... but `section` is sometimes NULL!
std::vector<struct Symbol> *fileSymbols;
};

View File

@@ -7,6 +7,7 @@
// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!
#include <stdint.h>
#include <string>
#include <vector>
#include "link/main.hpp"
@@ -30,7 +31,7 @@ struct Patch {
struct Section {
// Info contained in the object files
char *name;
std::string *name;
uint16_t size;
uint16_t offset;
enum SectionType type;
@@ -70,7 +71,7 @@ void sect_AddSection(struct Section *section);
* @param name The name of the section to look for
* @return A pointer to the section, or NULL if it wasn't found
*/
struct Section *sect_GetSection(char const *name);
struct Section *sect_GetSection(std::string const &name);
/*
* `free`s all section memory that was allocated.

View File

@@ -7,6 +7,7 @@
// GUIDELINE: external code MUST NOT BE AWARE of the data structure used!
#include <stdint.h>
#include <string>
#include "linkdefs.hpp"
@@ -14,7 +15,7 @@ struct FileStackNode;
struct Symbol {
// Info contained in the object files
char *name;
std::string *name;
enum ExportLevel type;
char const *objFileName;
struct FileStackNode const *src;
@@ -36,7 +37,7 @@ void sym_AddSymbol(struct Symbol *symbol);
* @param name The name of the symbol to look for
* @return A pointer to the symbol, or NULL if not found.
*/
struct Symbol *sym_GetSymbol(char const *name);
struct Symbol *sym_GetSymbol(std::string const &name);
/*
* `free`s all symbol memory that was allocated.