mirror of
https://github.com/rui314/mold.git
synced 2024-09-22 18:40:59 +03:00
temporary
This commit is contained in:
parent
17a9305bbc
commit
9ed1a00ff3
@ -26,7 +26,8 @@ void InputSection::copy_to(u8 *buf) {
|
|||||||
memcpy_nontemporal(buf, &data[0], data.size());
|
memcpy_nontemporal(buf, &data[0], data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputSection::scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt) {
|
void InputSection::scan_relocations(i32 &num_got, i32 &num_gotplt,
|
||||||
|
i32 &num_plt, i32 &num_dynrel) {
|
||||||
for (const ELF64LE::Rela &rel : rels) {
|
for (const ELF64LE::Rela &rel : rels) {
|
||||||
Symbol *sym = file->get_symbol(rel.getSymbol(false));
|
Symbol *sym = file->get_symbol(rel.getSymbol(false));
|
||||||
if (!sym || !sym->file)
|
if (!sym || !sym->file)
|
||||||
@ -46,11 +47,6 @@ void InputSection::scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt)
|
|||||||
if (sym->got_offset == 0) {
|
if (sym->got_offset == 0) {
|
||||||
sym->got_offset = -1;
|
sym->got_offset = -1;
|
||||||
num_got++;
|
num_got++;
|
||||||
|
|
||||||
if (sym->gotplt_offset == -1) {
|
|
||||||
sym->gotplt_offset = 0;
|
|
||||||
num_gotplt--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -68,13 +64,12 @@ void InputSection::scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt)
|
|||||||
|
|
||||||
std::lock_guard lock(sym->mu);
|
std::lock_guard lock(sym->mu);
|
||||||
if (sym->plt_offset == 0) {
|
if (sym->plt_offset == 0) {
|
||||||
|
assert(sym->gotplt_offset == 0);
|
||||||
sym->plt_offset = -1;
|
sym->plt_offset = -1;
|
||||||
num_plt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sym->gotplt_offset == 0 && sym->got_offset == 0) {
|
|
||||||
sym->gotplt_offset = -1;
|
sym->gotplt_offset = -1;
|
||||||
|
num_plt++;
|
||||||
num_gotplt++;
|
num_gotplt++;
|
||||||
|
num_dynrel++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
6
main.cc
6
main.cc
@ -531,17 +531,19 @@ int main(int argc, char **argv) {
|
|||||||
std::atomic_int32_t num_got = 0;
|
std::atomic_int32_t num_got = 0;
|
||||||
std::atomic_int32_t num_gotplt = 0;
|
std::atomic_int32_t num_gotplt = 0;
|
||||||
std::atomic_int32_t num_plt = 0;
|
std::atomic_int32_t num_plt = 0;
|
||||||
|
std::atomic_int32_t num_dynrel = 0;
|
||||||
|
|
||||||
for_each(files, [&](ObjectFile *file) {
|
for_each(files, [&](ObjectFile *file) {
|
||||||
i32 got = 0, gotplt = 0, plt = 0;
|
i32 got = 0, gotplt = 0, plt = 0, dynrel = 0;
|
||||||
|
|
||||||
for (InputSection *isec : file->sections)
|
for (InputSection *isec : file->sections)
|
||||||
if (isec)
|
if (isec)
|
||||||
isec->scan_relocations(got, gotplt, plt);
|
isec->scan_relocations(got, gotplt, plt, dynrel);
|
||||||
|
|
||||||
num_got += got;
|
num_got += got;
|
||||||
num_gotplt += gotplt;
|
num_gotplt += gotplt;
|
||||||
num_plt += plt;
|
num_plt += plt;
|
||||||
|
num_dynrel += dynrel;
|
||||||
});
|
});
|
||||||
|
|
||||||
out::got->size = num_got * 8;
|
out::got->size = num_got * 8;
|
||||||
|
2
mold.h
2
mold.h
@ -210,7 +210,7 @@ public:
|
|||||||
|
|
||||||
void copy_to(u8 *buf);
|
void copy_to(u8 *buf);
|
||||||
void relocate(u8 *buf);
|
void relocate(u8 *buf);
|
||||||
void scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt);
|
void scan_relocations(i32 &num_got, i32 &num_gotplt, i32 &num_plt, i32 &num_dynrel);
|
||||||
|
|
||||||
ObjectFile *file;
|
ObjectFile *file;
|
||||||
OutputSection *output_section;
|
OutputSection *output_section;
|
||||||
|
Loading…
Reference in New Issue
Block a user