1
1
mirror of https://github.com/rui314/mold.git synced 2024-12-24 17:01:50 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-12-19 08:32:07 +09:00
parent b8af7082c7
commit c49e33dd2b
4 changed files with 13 additions and 7 deletions

View File

@ -6,7 +6,7 @@ TBB_LIBDIR=$(wildcard $(CURRENT_DIR)/oneTBB/build/linux_intel64_*_release/)
CPPFLAGS=-g -IoneTBB/include -pthread -std=c++20 -Wno-deprecated-volatile -O2
LDFLAGS=-L$(TBB_LIBDIR) -Wl,-rpath=$(TBB_LIBDIR) -fuse-ld=lld -pthread
LIBS=-ltbb
LIBS=-ltbb -ltbbmalloc -ltbbmalloc_proxy
OBJS=main.o object_file.o input_sections.o output_chunks.o mapfile.o perf.o \
linker_script.o archive_file.o

View File

@ -49,6 +49,7 @@ void InputSection::copy_buf() {
// Apply relocations
u8 *base = out::buf + output_section->shdr.sh_offset + offset;
int ref_idx = 0;
ElfRela *dynrel = nullptr;
if (out::reldyn)
@ -57,10 +58,13 @@ void InputSection::copy_buf() {
for (int i = 0; i < rels.size(); i++) {
const ElfRela &rel = rels[i];
StringPieceRef &ref = rel_pieces[i];
Symbol &sym = *file->symbols[rel.r_sym];
u8 *loc = base + rel.r_offset;
const StringPieceRef *ref = nullptr;
if (has_rel_piece[i])
ref = &rel_pieces[ref_idx++];
auto write = [&](u64 val) {
switch (get_rel_size(rel.r_type)) {
case 1: *loc = val; return;
@ -71,8 +75,8 @@ void InputSection::copy_buf() {
unreachable();
};
#define S (ref.piece ? ref.piece->get_addr() : sym.get_addr())
#define A (ref.piece ? ref.addend : rel.r_addend)
#define S (ref ? ref->piece->get_addr() : sym.get_addr())
#define A (ref ? ref->addend : rel.r_addend)
#define P (output_section->shdr.sh_addr + offset + rel.r_offset)
#define L sym.get_plt_addr()
#define G (sym.get_got_addr() - out::got->shdr.sh_addr)

1
mold.h
View File

@ -262,6 +262,7 @@ public:
void report_undefined_symbols();
std::span<ElfRela> rels;
std::vector<bool> has_rel_piece;
std::vector<StringPieceRef> rel_pieces;
std::vector<RelType> rel_types;
u64 reldyn_offset = 0;

View File

@ -128,7 +128,7 @@ void ObjectFile::initialize_sections() {
if (target) {
target->rels = get_data<ElfRela>(shdr);
target->rel_types.resize(target->rels.size());
target->rel_pieces.resize(target->rels.size());
target->has_rel_piece.resize(target->rels.size());
if (target->shdr.sh_flags & SHF_ALLOC) {
static Counter counter("relocs_alloc");
@ -270,8 +270,9 @@ void ObjectFile::initialize_mergeable_sections() {
if (!ref)
error(to_string(this) + ": bad relocation at " + std::to_string(rel.r_sym));
isec->rel_pieces[i].piece = ref->piece;
isec->rel_pieces[i].addend = offset - ref->input_offset;
isec->rel_pieces.push_back(
{.piece = ref->piece, .addend = (i32)(offset - ref->input_offset)});
isec->has_rel_piece[i] = true;
}
}
}