summaryrefslogtreecommitdiff
path: root/src/gnu.cpp
blob: 7f8ebe1ef640eaaf64f35523e7d594552f67af68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
}