1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-14 07:18:42 +03:00

[Mach-O] wip

This commit is contained in:
Rui Ueyama 2021-10-04 21:01:28 +09:00
parent 7dd9a38b3b
commit 0a130212cb
2 changed files with 15 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#include "../mold.h"
#include <memory>
#include <tbb/concurrent_hash_map.h>
namespace mold::macho {
@ -80,6 +81,8 @@ struct Symbol {
Symbol(std::string_view name) : name(name) {}
Symbol(const Symbol &other) : name(other.name) {}
static inline Symbol *intern(Context &ctx, std::string_view name);
std::string_view name;
ObjectFile *file = nullptr;
@ -449,6 +452,8 @@ struct Context {
bool has_error = false;
tbb::concurrent_hash_map<std::string_view, Symbol> symbol_map;
std::unique_ptr<OutputFile> output_file;
u8 *buf;
@ -488,4 +493,14 @@ struct Context {
int main(int argc, char **argv);
//
// Inline functions
//
Symbol *Symbol::intern(Context &ctx, std::string_view name) {
typename decltype(ctx.symbol_map)::const_accessor acc;
ctx.symbol_map.insert(acc, {name, Symbol(name)});
return const_cast<Symbol*>(&acc->second);
}
} // namespace mold::macho

View File

@ -43,7 +43,6 @@ void ObjectFile::parse(Context &ctx) {
for (i64 j = 0; j < cmd.nsyms; j++) {
std::string_view name = (char *)(buf + cmd.stroff + mach_sym[j].stroff);
SyncOut(ctx) << "name=" << name;
}
break;
}