mirror of
https://github.com/rui314/mold.git
synced 2024-12-25 17:34:02 +03:00
temporary
This commit is contained in:
parent
b8088b7113
commit
7fbad02cd4
@ -96,11 +96,11 @@ struct tbb_hash_compare<StringRef> {
|
||||
|
||||
class SymbolTable {
|
||||
public:
|
||||
void add(StringRef key, StringRef val);
|
||||
StringRef get(StringRef key);
|
||||
void add(StringRef key, Symbol sym);
|
||||
Symbol *get(StringRef key);
|
||||
|
||||
private:
|
||||
typedef tbb::concurrent_hash_map<StringRef, StringRef> MapType;
|
||||
typedef tbb::concurrent_hash_map<StringRef, Symbol> MapType;
|
||||
|
||||
MapType map;
|
||||
};
|
||||
@ -133,6 +133,7 @@ private:
|
||||
std::vector<InputSection> sections;
|
||||
std::vector<Symbol *> symbols;
|
||||
std::vector<Symbol> symbol_instances;
|
||||
int firstGlobal;
|
||||
bool is_alive = false;
|
||||
};
|
||||
|
||||
|
@ -34,28 +34,37 @@ void ObjectFile::parse() {
|
||||
const ELF64LE::Shdr *symtab_sec
|
||||
= findSection(sections, is_dso ? SHT_DYNSYM : SHT_SYMTAB);
|
||||
|
||||
int firstGlobal = symtab_sec->sh_info;
|
||||
firstGlobal = symtab_sec->sh_info;
|
||||
|
||||
ArrayRef<ELF64LE::Sym> elf_syms = CHECK(obj.symbols(symtab_sec), this);
|
||||
StringRef string_table =
|
||||
CHECK(obj.getStringTableForSymtab(*symtab_sec, sections), this);
|
||||
|
||||
symbol_instances.reserve(elf_syms.size());
|
||||
symbols.reserve(elf_syms.size());
|
||||
|
||||
for (int i = 0; i < elf_syms.size(); i++) {
|
||||
StringRef name;
|
||||
if (firstGlobal <= i)
|
||||
name = CHECK(elf_syms[i].getName(string_table), this);
|
||||
symbol_instances.push_back({name, this});
|
||||
}
|
||||
|
||||
for (const ELF64LE::Sym &sym : elf_syms.slice(firstGlobal)) {
|
||||
StringRef name = CHECK(sym.getName(string_table), this);
|
||||
symbol_table.add(name, name);
|
||||
llvm::errs() << symbol_table.get(name) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectFile::register_defined_symbols() {}
|
||||
void ObjectFile::register_defined_symbols() {
|
||||
for (int i = 0; i < symbol_instances.size(); i++) {
|
||||
Symbol &sym = symbol_instances[i];
|
||||
|
||||
if (i < firstGlobal) {
|
||||
symbols.push_back(&sym);
|
||||
continue;
|
||||
}
|
||||
|
||||
symbol_table.add(sym.name, sym);
|
||||
llvm::errs() << symbol_table.get(sym.name).name << "\n";
|
||||
symbols.push_back(&sym);
|
||||
}
|
||||
}
|
||||
|
||||
StringRef ObjectFile::getFilename() {
|
||||
return mb.getBufferIdentifier();
|
||||
|
14
symtab.cc
14
symtab.cc
@ -1,15 +1,15 @@
|
||||
#include "chibild.h"
|
||||
|
||||
void SymbolTable::add(StringRef key, StringRef val) {
|
||||
void SymbolTable::add(StringRef name, Symbol sym) {
|
||||
MapType::accessor acc;
|
||||
map.insert(acc, key);
|
||||
acc->second = val;
|
||||
map.insert(acc, name);
|
||||
acc->second = sym;
|
||||
acc.release();
|
||||
}
|
||||
|
||||
StringRef SymbolTable::get(StringRef key) {
|
||||
Symbol *SymbolTable::get(StringRef name) {
|
||||
MapType::accessor acc;
|
||||
if (map.find(acc, key))
|
||||
return acc->second;
|
||||
return "";
|
||||
if (map.find(acc, name))
|
||||
return &acc->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user