mirror of
https://github.com/rui314/mold.git
synced 2024-12-25 09:25:15 +03:00
temporary
This commit is contained in:
parent
e99ce26374
commit
8b2493b3a9
24
main.cc
24
main.cc
@ -451,6 +451,23 @@ static void scan_rels() {
|
||||
}
|
||||
}
|
||||
|
||||
static void export_dynamic() {
|
||||
MyTimer t("export_dynamic", before_copy_timer);
|
||||
if (!config.export_dynamic)
|
||||
return;
|
||||
|
||||
std::vector<std::vector<Symbol *>> vec(out::objs.size());
|
||||
|
||||
tbb::parallel_for(0, (int)out::objs.size(), [&](int i) {
|
||||
for (Symbol *sym : out::objs[i]->symbols)
|
||||
if (sym->file == out::objs[i])
|
||||
vec[i].push_back(sym);
|
||||
});
|
||||
|
||||
for (Symbol *sym : flatten(vec))
|
||||
out::dynsym->add_symbol(sym);
|
||||
}
|
||||
|
||||
static void fill_symbol_versions() {
|
||||
MyTimer t("fill_symbol_versions", before_copy_timer);
|
||||
|
||||
@ -1002,6 +1019,9 @@ int main(int argc, char **argv) {
|
||||
// .got.plt, .dynsym, .dynstr, etc.
|
||||
scan_rels();
|
||||
|
||||
// Put symbols to .dynsym.
|
||||
export_dynamic();
|
||||
|
||||
// Fill .gnu.version and .gnu.version_r section contents.
|
||||
fill_symbol_versions();
|
||||
|
||||
@ -1014,8 +1034,8 @@ int main(int argc, char **argv) {
|
||||
// section indices to them, so we can fix section header contents
|
||||
// for all output sections.
|
||||
tbb::parallel_for_each(out::chunks, [](OutputChunk *chunk) {
|
||||
chunk->update_shdr();
|
||||
});
|
||||
chunk->update_shdr();
|
||||
});
|
||||
|
||||
// Assign offsets to output sections
|
||||
u64 filesize = set_osec_offsets(out::chunks);
|
||||
|
@ -27,11 +27,10 @@ void OutputEhdr::copy_buf() {
|
||||
}
|
||||
|
||||
void OutputShdr::update_shdr() {
|
||||
int i = 1;
|
||||
shdr.sh_size = sizeof(ELF64LE::Shdr);
|
||||
for (OutputChunk *chunk : out::chunks)
|
||||
if (chunk->kind != OutputChunk::HEADER)
|
||||
i++;
|
||||
shdr.sh_size = i * sizeof(ELF64LE::Shdr);
|
||||
shdr.sh_size += sizeof(ELF64LE::Shdr);
|
||||
}
|
||||
|
||||
void OutputShdr::copy_buf() {
|
||||
|
@ -1,5 +1,6 @@
|
||||
// RUN: cc -o %t.o -c %s
|
||||
// RUN: mold -o %t.exe %t.o --export-dynamic
|
||||
// RUN: cc -o %t1.o -c %s
|
||||
// RUN: cc -shared -fPIC -o %t2.so -xc - < /dev/null
|
||||
// RUN: mold -o %t.exe %t1.o %t2.so --export-dynamic
|
||||
// RUN: readelf --dyn-syms %t.exe | FileCheck %s
|
||||
|
||||
.text
|
||||
|
Loading…
Reference in New Issue
Block a user