Force PT_LOAD segments to be aligned to the page size.
This commit is contained in:
parent
41f542e70b
commit
0496d5e5b4
|
@ -610,6 +610,10 @@ Layout::set_segment_offsets(const Target* target, Output_segment* load_seg,
|
||||||
|
|
||||||
uint64_t aligned_addr = addr;
|
uint64_t aligned_addr = addr;
|
||||||
uint64_t abi_pagesize = target->abi_pagesize();
|
uint64_t abi_pagesize = target->abi_pagesize();
|
||||||
|
|
||||||
|
// FIXME: This should depend on the -n and -N options.
|
||||||
|
(*p)->set_minimum_addralign(target->common_pagesize());
|
||||||
|
|
||||||
if (was_readonly && ((*p)->flags() & elfcpp::PF_W) != 0)
|
if (was_readonly && ((*p)->flags() & elfcpp::PF_W) != 0)
|
||||||
{
|
{
|
||||||
uint64_t align = (*p)->addralign();
|
uint64_t align = (*p)->addralign();
|
||||||
|
|
|
@ -1674,6 +1674,15 @@ class Output_segment
|
||||||
uint64_t
|
uint64_t
|
||||||
set_section_addresses(uint64_t addr, off_t* poff, unsigned int* pshndx);
|
set_section_addresses(uint64_t addr, off_t* poff, unsigned int* pshndx);
|
||||||
|
|
||||||
|
// Set the minimum alignment of this segment. This may be adjusted
|
||||||
|
// upward based on the section alignments.
|
||||||
|
void
|
||||||
|
set_minimum_addralign(uint64_t align)
|
||||||
|
{
|
||||||
|
gold_assert(!this->is_align_known_);
|
||||||
|
this->align_ = align;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the offset of this segment based on the section. This should
|
// Set the offset of this segment based on the section. This should
|
||||||
// only be called for a non-PT_LOAD segment.
|
// only be called for a non-PT_LOAD segment.
|
||||||
void
|
void
|
||||||
|
@ -1735,7 +1744,9 @@ class Output_segment
|
||||||
uint64_t paddr_;
|
uint64_t paddr_;
|
||||||
// The size of the segment in memory.
|
// The size of the segment in memory.
|
||||||
uint64_t memsz_;
|
uint64_t memsz_;
|
||||||
// The segment alignment.
|
// The segment alignment. The is_align_known_ field indicates
|
||||||
|
// whether this has been finalized. It can be set to a minimum
|
||||||
|
// value before it is finalized.
|
||||||
uint64_t align_;
|
uint64_t align_;
|
||||||
// The offset of the segment data within the file.
|
// The offset of the segment data within the file.
|
||||||
off_t offset_;
|
off_t offset_;
|
||||||
|
@ -1745,7 +1756,7 @@ class Output_segment
|
||||||
elfcpp::Elf_Word type_;
|
elfcpp::Elf_Word type_;
|
||||||
// The segment flags.
|
// The segment flags.
|
||||||
elfcpp::Elf_Word flags_;
|
elfcpp::Elf_Word flags_;
|
||||||
// Whether we have set align_.
|
// Whether we have finalized align_.
|
||||||
bool is_align_known_;
|
bool is_align_known_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue