diff options
author | Oxore <oxore@protonmail.com> | 2024-03-24 02:37:54 +0300 |
---|---|---|
committer | Oxore <oxore@protonmail.com> | 2024-11-21 00:18:24 +0300 |
commit | 2294d3e82e986894c0645840d01ddd6b2cb08523 (patch) | |
tree | 4742e883898fd585ec50b0f40f159b08fd75b57e /src/gnu.cpp | |
parent | 55245a2c76baeaebb032613617e426df899e9ee7 (diff) |
Move some GAS specific behavior to gnu.cpp
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); +} |