mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 01:06:32 +00:00
[ELF] Move PhdrEntry to SyntheticSections
The next change will change Partition::phdrs to a unique_ptr vector, which requires PhdrEntry to be a complete type. And make OutputSection::getLMA out-of-line, since it should not include either SyntheticSections.h or Writer.h.
This commit is contained in:
parent
c6bce68f9a
commit
fa4d1860d2
@ -72,6 +72,10 @@ OutputSection::OutputSection(Ctx &ctx, StringRef name, uint32_t type,
|
||||
/*info=*/0, /*link=*/0),
|
||||
ctx(ctx) {}
|
||||
|
||||
uint64_t OutputSection::getLMA() const {
|
||||
return ptLoad ? addr + ptLoad->lmaOffset : addr;
|
||||
}
|
||||
|
||||
// We allow sections of types listed below to merged into a
|
||||
// single progbits section. This is typically done by linker
|
||||
// scripts. Merging nobits and progbits will force disk space
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
return s->kind() == SectionBase::Output;
|
||||
}
|
||||
|
||||
uint64_t getLMA() const { return ptLoad ? addr + ptLoad->lmaOffset : addr; }
|
||||
uint64_t getLMA() const;
|
||||
template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *sHdr);
|
||||
|
||||
Ctx &ctx;
|
||||
|
@ -1439,6 +1439,31 @@ Defined *addSyntheticLocal(Ctx &ctx, StringRef name, uint8_t type,
|
||||
|
||||
void addVerneed(Ctx &, Symbol &ss);
|
||||
|
||||
// This describes a program header entry.
|
||||
// Each contains type, access flags and range of output sections that will be
|
||||
// placed in it.
|
||||
struct PhdrEntry {
|
||||
PhdrEntry(Ctx &ctx, unsigned type, unsigned flags)
|
||||
: p_align(type == llvm::ELF::PT_LOAD ? ctx.arg.maxPageSize : 0),
|
||||
p_type(type), p_flags(flags) {}
|
||||
void add(OutputSection *sec);
|
||||
|
||||
uint64_t p_paddr = 0;
|
||||
uint64_t p_vaddr = 0;
|
||||
uint64_t p_memsz = 0;
|
||||
uint64_t p_filesz = 0;
|
||||
uint64_t p_offset = 0;
|
||||
uint32_t p_align = 0;
|
||||
uint32_t p_type = 0;
|
||||
uint32_t p_flags = 0;
|
||||
|
||||
OutputSection *firstSec = nullptr;
|
||||
OutputSection *lastSec = nullptr;
|
||||
bool hasLMA = false;
|
||||
|
||||
uint64_t lmaOffset = 0;
|
||||
};
|
||||
|
||||
// Linker generated per-partition sections.
|
||||
struct Partition {
|
||||
Ctx &ctx;
|
||||
|
@ -10,40 +10,12 @@
|
||||
#define LLD_ELF_WRITER_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace lld::elf {
|
||||
class InputFile;
|
||||
class OutputSection;
|
||||
void copySectionsIntoPartitions(Ctx &ctx);
|
||||
template <class ELFT> void writeResult(Ctx &ctx);
|
||||
|
||||
// This describes a program header entry.
|
||||
// Each contains type, access flags and range of output sections that will be
|
||||
// placed in it.
|
||||
struct PhdrEntry {
|
||||
PhdrEntry(Ctx &ctx, unsigned type, unsigned flags)
|
||||
: p_align(type == llvm::ELF::PT_LOAD ? ctx.arg.maxPageSize : 0),
|
||||
p_type(type), p_flags(flags) {}
|
||||
void add(OutputSection *sec);
|
||||
|
||||
uint64_t p_paddr = 0;
|
||||
uint64_t p_vaddr = 0;
|
||||
uint64_t p_memsz = 0;
|
||||
uint64_t p_filesz = 0;
|
||||
uint64_t p_offset = 0;
|
||||
uint32_t p_align = 0;
|
||||
uint32_t p_type = 0;
|
||||
uint32_t p_flags = 0;
|
||||
|
||||
OutputSection *firstSec = nullptr;
|
||||
OutputSection *lastSec = nullptr;
|
||||
bool hasLMA = false;
|
||||
|
||||
uint64_t lmaOffset = 0;
|
||||
};
|
||||
|
||||
void addReservedSymbols(Ctx &ctx);
|
||||
bool includeInSymtab(Ctx &, const Symbol &);
|
||||
unsigned getSectionRank(Ctx &, OutputSection &osec);
|
||||
|
Loading…
x
Reference in New Issue
Block a user