1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-22 10:27:48 +03:00

temporary

This commit is contained in:
Rui Ueyama 2020-11-03 21:51:40 +09:00
parent e689466710
commit a1f42cf154
3 changed files with 25 additions and 15 deletions

View File

@ -41,16 +41,16 @@ void InputSection::scan_relocations() {
case R_X86_64_GOTPCRELX:
case R_X86_64_REX_GOTPCRELX: {
std::lock_guard lock(sym->mu);
if (sym->got_offset == 0) {
sym->got_offset = -1;
if (!sym->needs_got) {
sym->needs_got = true;
file->num_got++;
}
break;
}
case R_X86_64_GOTTPOFF: {
std::lock_guard lock(sym->mu);
if (sym->gottp_offset == 0) {
sym->gottp_offset = -1;
if (!sym->needs_gottp) {
sym->needs_gottp = true;
file->num_got++;
}
break;
@ -60,10 +60,10 @@ void InputSection::scan_relocations() {
break;
std::lock_guard lock(sym->mu);
if (sym->plt_offset == 0) {
assert(sym->gotplt_offset == 0);
sym->plt_offset = -1;
sym->gotplt_offset = -1;
if (!sym->needs_plt) {
assert(!sym->needs_gotplt);
sym->needs_plt = true;
sym->needs_gotplt = true;
file->num_plt++;
file->num_gotplt++;
file->num_relplt++;

View File

@ -265,26 +265,26 @@ static void assign_got_offsets(ArrayRef<ObjectFile *> files) {
if (sym->file != file)
continue;
if (sym->got_offset == -1) {
if (sym->needs_got) {
out::got->symbols.push_back({GotSection::REGULAR, sym});
sym->got_offset = got_offset;
got_offset += 8;
}
if (sym->gottp_offset == -1) {
if (sym->needs_gottp) {
out::got->symbols.push_back({GotSection::TPOFF, sym});
sym->gottp_offset = got_offset;
got_offset += 8;
}
if (sym->gotplt_offset == -1) {
if (sym->needs_gotplt) {
assert(sym->type == STT_GNU_IFUNC);
out::gotplt->symbols.push_back({GotSection::IREL, sym});
sym->gotplt_offset = gotplt_offset;
gotplt_offset += 8;
}
if (sym->plt_offset == -1) {
if (sym->needs_plt) {
out::plt->symbols.push_back(sym);
sym->plt_offset = plt_offset;
plt_offset += 16;

16
mold.h
View File

@ -144,8 +144,13 @@ private:
class Symbol {
public:
Symbol(StringRef name) : name(name) {}
Symbol(const Symbol &other) : name(other.name), file(other.file) {}
Symbol(StringRef name)
: name(name), needs_got(false), needs_gotplt(false),
needs_gottp(false), needs_plt(false) {}
Symbol(const Symbol &other)
: name(other.name), file(other.file), needs_got(false),
needs_gotplt(false), needs_gottp(false), needs_plt(false) {}
static Symbol *intern(StringRef name) {
static ConcurrentMap<Symbol> map;
@ -155,6 +160,7 @@ public:
StringRef name;
ObjectFile *file = nullptr;
InputSection *input_section = nullptr;
tbb::spin_mutex mu;
u64 addr = 0;
uint32_t got_offset = 0;
@ -162,7 +168,11 @@ public:
uint32_t gottp_offset = 0;
uint32_t plt_offset = 0;
tbb::spin_mutex mu;
u8 needs_got : 1;
u8 needs_gotplt : 1;
u8 needs_gottp : 1;
u8 needs_plt : 1;
u8 visibility = 0;
u8 type = llvm::ELF::STT_NOTYPE;
bool is_weak = false;