diff options
Diffstat (limited to 'src/gnu.cpp')
-rw-r--r-- | src/gnu.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gnu.cpp b/src/gnu.cpp new file mode 100644 index 0000000..7f8ebe1 --- /dev/null +++ b/src/gnu.cpp @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: Unlicense + */ + +#include "gnu.h" + +using namespace Gnu; + +static constexpr const char *SymbolTypeToElfTypeString(SymbolType t) +{ + switch (t) { + case SymbolType::kNone: return nullptr; + case SymbolType::kFunction: return "function"; + case SymbolType::kObject: return "object"; + } + return nullptr; +} + +void Gnu::EmitSymbolMetadata(FILE *out, const char *indent, const Symbol &symbol) +{ + const char *const type = SymbolTypeToElfTypeString(symbol.type); + if (type) { + fprintf(out, "%s.type\t%s, @%s\n", indent, symbol.name, type); + } +} + +void Gnu::EmitSymbolSize(FILE *out, const char *indent, const char *sym_name) +{ + fprintf(out, "%s.size\t%s,.-%s\n", indent, sym_name, sym_name); +} |