mirror of
https://github.com/rui314/mold.git
synced 2024-12-27 10:23:41 +03:00
temporary
This commit is contained in:
parent
777782674c
commit
4b4f647fae
24
main.cc
24
main.cc
@ -307,6 +307,9 @@ int main(int argc, char **argv) {
|
||||
// Create program header contents.
|
||||
out::phdr->construct(output_chunks);
|
||||
|
||||
// Fill section header.
|
||||
fill_shdrs(output_chunks);
|
||||
|
||||
// Assign offsets to input sections
|
||||
uint64_t filesize = 0;
|
||||
{
|
||||
@ -319,7 +322,7 @@ int main(int argc, char **argv) {
|
||||
while (j < output_chunks.size() && !output_chunks[j]->starts_segment)
|
||||
j++;
|
||||
|
||||
slices.push_back(ArrayRef(output_chunks).slice(i, j));
|
||||
slices.push_back(ArrayRef(output_chunks).slice(i, j - i));
|
||||
i = j;
|
||||
}
|
||||
|
||||
@ -336,12 +339,18 @@ int main(int argc, char **argv) {
|
||||
|
||||
chunk->set_offset(vaddr, fileoff);
|
||||
|
||||
vaddr += chunk->shdr.sh_size;
|
||||
vaddr += chunk->get_filesz();
|
||||
if (!is_bss)
|
||||
fileoff += chunk->shdr.sh_size;
|
||||
fileoff += chunk->get_filesz();
|
||||
}
|
||||
}
|
||||
|
||||
for (OutputChunk *chunk : output_chunks) {
|
||||
llvm::outs() << chunk->name
|
||||
<< " vaddr=" << chunk->shdr.sh_addr
|
||||
<< " offset=" << chunk->shdr.sh_offset
|
||||
<< "\n";
|
||||
|
||||
uint64_t vaddr = 0x200000;
|
||||
uint64_t fileoff = 0;
|
||||
|
||||
@ -362,18 +371,9 @@ int main(int argc, char **argv) {
|
||||
else
|
||||
fileoff = last->shdr.sh_offset + last->shdr.sh_size;
|
||||
}
|
||||
|
||||
for (OutputChunk *chunk : output_chunks) {
|
||||
llvm::outs() << chunk->name
|
||||
<< " vaddr=" << chunk->shdr.sh_addr
|
||||
<< " offset=" << chunk->shdr.sh_offset
|
||||
<< "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Fill section header.
|
||||
fill_shdrs(output_chunks);
|
||||
|
||||
{
|
||||
MyTimer t("unlink", before_copy);
|
||||
unlink_async(tg, config.output);
|
||||
|
@ -67,15 +67,22 @@ void OutputPhdr::construct(std::vector<OutputChunk *> &chunks) {
|
||||
|
||||
// Create PT_LOAD segments.
|
||||
add(PT_LOAD, PF_R, {});
|
||||
|
||||
bool last_was_bss = false;
|
||||
|
||||
for (OutputChunk *chunk : chunks) {
|
||||
if (!(chunk->shdr.sh_flags & SHF_ALLOC))
|
||||
break;
|
||||
|
||||
uint32_t flags = to_phdr_flags(chunk->shdr.sh_flags);
|
||||
if (entries.back().phdr.p_flags == flags)
|
||||
entries.back().members.push_back(chunk);
|
||||
else
|
||||
bool this_is_bss = chunk->shdr.sh_type & SHT_NOBITS;
|
||||
|
||||
if (entries.back().phdr.p_flags != flags || (last_was_bss && !this_is_bss))
|
||||
add(PT_LOAD, flags, {chunk});
|
||||
else
|
||||
entries.back().members.push_back(chunk);
|
||||
|
||||
last_was_bss = this_is_bss;
|
||||
}
|
||||
|
||||
// Create a PT_TLS.
|
||||
@ -118,6 +125,8 @@ void OutputSection::set_offset(uint64_t vaddr, uint64_t fileoff) {
|
||||
shdr.sh_addr = vaddr;
|
||||
shdr.sh_offset = fileoff;
|
||||
|
||||
llvm::outs() << name << " " << vaddr << " " << fileoff << "\n";
|
||||
|
||||
if (!(shdr.sh_type & SHT_NOBITS))
|
||||
assert(vaddr == fileoff);
|
||||
|
||||
@ -126,6 +135,9 @@ void OutputSection::set_offset(uint64_t vaddr, uint64_t fileoff) {
|
||||
isec->offset = vaddr;
|
||||
vaddr += isec->shdr.sh_size;
|
||||
}
|
||||
|
||||
shdr.sh_size = vaddr - shdr.sh_size;
|
||||
llvm::outs() << name << " " << vaddr << " " << fileoff << "\n";
|
||||
}
|
||||
|
||||
static StringRef get_output_name(StringRef name) {
|
||||
|
Loading…
Reference in New Issue
Block a user