1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-28 19:04:27 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-10-23 00:52:36 +09:00
parent c81ab20e97
commit 04f3af2d66
3 changed files with 20 additions and 6 deletions

View File

@ -6,6 +6,7 @@ using namespace llvm::ELF;
std::atomic_int num_defined;
std::atomic_int num_undefined;
std::atomic_int num_files;
std::atomic_int num_string_pieces;
ObjectFile::ObjectFile(MemoryBufferRef mb, StringRef archive_name)
: mb(mb), archive_name(archive_name),
@ -73,8 +74,8 @@ void ObjectFile::initialize_sections() {
case SHT_NULL:
break;
default: {
if ((shdr.sh_flags & SHF_STRINGS) && (shdr.sh_flags & SHF_ALLOC) &&
!(shdr.sh_flags & SHF_WRITE) && shdr.sh_entsize == 1) {
if ((shdr.sh_flags & SHF_STRINGS) && !(shdr.sh_flags & SHF_WRITE) &&
shdr.sh_entsize == 1) {
read_string_pieces(shdr);
break;
}
@ -118,7 +119,11 @@ void ObjectFile::initialize_symbols() {
}
void ObjectFile::read_string_pieces(const ELF64LE::Shdr &shdr) {
static ConcurrentMap<StringPiece> map;
static ConcurrentMap<StringPiece> map1;
static ConcurrentMap<StringPiece> map2;
bool is_alloc = shdr.sh_type & SHF_ALLOC;
ConcurrentMap<StringPiece> &map = is_alloc ? map1 : map2;
ArrayRef<uint8_t> arr = CHECK(obj.getSectionContents(shdr), this);
StringRef data((const char *)&arr[0], arr.size());
@ -130,8 +135,14 @@ void ObjectFile::read_string_pieces(const ELF64LE::Shdr &shdr) {
StringRef substr = data.substr(0, end + 1);
StringPiece *piece = map.insert(substr, StringPiece(substr));
merged_strings.push_back(piece);
if (is_alloc)
merged_strings_alloc.push_back(piece);
else
merged_strings_noalloc.push_back(piece);
data = data.substr(end + 1);
num_string_pieces++;
}
}

View File

@ -314,7 +314,8 @@ int main(int argc, char **argv) {
<< " filesize=" << filesize << "\n"
<< " num_defined=" << num_defined << "\n"
<< "num_undefined=" << num_undefined << "\n"
<< " num_relocs=" << num_relocs << "\n";
<< " num_relocs=" << num_relocs << "\n"
<< " num_str=" << num_string_pieces << "\n";
llvm::TimerGroup::printAll(llvm::outs());
llvm::outs().flush();

4
mold.h
View File

@ -382,7 +382,8 @@ private:
MemoryBufferRef mb;
std::vector<Symbol *> symbols;
std::vector<std::pair<bool *, ArrayRef<ELF64LE::Word>>> comdat_groups;
std::vector<StringPiece *> merged_strings;
std::vector<StringPiece *> merged_strings_alloc;
std::vector<StringPiece *> merged_strings_noalloc;
ArrayRef<ELF64LE::Shdr> elf_sections;
ArrayRef<ELF64LE::Sym> elf_syms;
@ -422,3 +423,4 @@ extern std::atomic_int num_defined;
extern std::atomic_int num_undefined;
extern std::atomic_int num_files;
extern std::atomic_int num_relocs;
extern std::atomic_int num_string_pieces;