}
else
{
- expld.result.value += expld.dot & (maxpage - 1);
+ if (!link_info.relro)
+ expld.result.value += expld.dot & (maxpage - 1);
if (seg->phase == exp_seg_done)
{
/* OK. */
{
seg->phase = exp_seg_align_seen;
seg->base = expld.result.value;
- seg->pagesize = commonpage;
+ seg->commonpagesize = commonpage;
seg->maxpagesize = maxpage;
+ seg->relropagesize = maxpage;
seg->relro_end = 0;
}
else
seg->relro_end = lhs->value + expld.result.value;
if (seg->phase == exp_seg_relro_adjust
- && (seg->relro_end & (seg->pagesize - 1)))
+ && (seg->relro_end & (seg->relropagesize - 1)))
{
- seg->relro_end += seg->pagesize - 1;
- seg->relro_end &= ~(seg->pagesize - 1);
+ seg->relro_end += seg->relropagesize - 1;
+ seg->relro_end &= ~(seg->relropagesize - 1);
expld.result.value = seg->relro_end - expld.result.value;
}
else
typedef struct {
enum phase_enum phase;
- bfd_vma base, relro_offset, relro_end, end, pagesize, maxpagesize;
+ bfd_vma base, relro_offset, relro_end, end;
+ /* MAXPAGESIZE and COMMMONPAGESIZE as passed to DATA_SEGMENT_ALIGN.
+ relropagesize sets the alignment of the end of the relro segment. */
+ bfd_vma maxpagesize, commonpagesize, relropagesize;
enum relro_enum relro;
a page could be saved in the data segment. */
bfd_vma first, last;
- first = -seg->base & (seg->pagesize - 1);
- last = seg->end & (seg->pagesize - 1);
+ first = -seg->base & (seg->commonpagesize - 1);
+ last = seg->end & (seg->commonpagesize - 1);
if (first && last
- && ((seg->base & ~(seg->pagesize - 1))
- != (seg->end & ~(seg->pagesize - 1)))
- && first + last <= seg->pagesize)
+ && ((seg->base & ~(seg->commonpagesize - 1))
+ != (seg->end & ~(seg->commonpagesize - 1)))
+ && first + last <= seg->commonpagesize)
{
seg->phase = exp_seg_adjust;
return true;
asection *sec;
/* Compute the expected PT_GNU_RELRO/PT_LOAD segment end. */
- relro_end = ((seg->relro_end + seg->pagesize - 1)
- & ~(seg->pagesize - 1));
+ relro_end = (seg->relro_end + seg->relropagesize - 1) & -seg->relropagesize;
/* Adjust by the offset arg of XXX_SEGMENT_RELRO_END. */
desired_end = relro_end - seg->relro_offset;