1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-20 01:18:53 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-17 20:32:18 +09:00
parent 43d009b1cf
commit 3aba72edf5
3 changed files with 32 additions and 1 deletions

View File

@ -11,7 +11,7 @@ CPPFLAGS=-g $(shell $(LLVM_CONFIG) --cxxflags) -IoneTBB/include -pthread -O2
LDFLAGS=$(shell $(LLVM_CONFIG) --ldflags) -L$(TBB_LIBDIR) -Wl,-rpath=$(TBB_LIBDIR)
LIBS=-pthread -ltbb -lcurses -Wl,--start-group $(LLVM_LIBS) -Wl,--end-group
OBJS=main.o writer.o input_files.o input_sections.o output_sections.o symtab.o \
output_file.o
output_file.o intern.o
chibild: $(OBJS)
$(CXX) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS) $(LIBS)

View File

@ -86,6 +86,25 @@ class SymbolTable;
class InputSection;
class ObjectFile;
//
// intern.cc
//
class IString {
IString() : IString("") {}
IString(const IString &other) : data(other.data), size(other.size) {}
IString(StringRef s);
bool operator==(const IString &other) { return data == other.data; }
public:
typedef tbb::concurrent_hash_map<StringRef, StringRef> MapType;
static MapType map;
const char *data;
uint32_t size;
};
//
// symtab.cc
//

12
intern.cc Normal file
View File

@ -0,0 +1,12 @@
#include "chibild.h"
IString::MapType IString::map;
IString::IString(StringRef s) {
MapType::accessor acc;
map.insert(acc, s);
if (acc->second.data() == nullptr)
acc->second = s;
data = acc->second.data();
size = acc->second.size();
}