This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix relro when COMMONPAGESIZE < MAXPAGESIZE


On Wed, Sep 08, 2004 at 12:09:49PM +0200, Andreas Schwab wrote:
> Jakub Jelinek <jakub@redhat.com> writes:
> 
> > And, if you change 0x100ddc to 0x10a370, then I'm very sure .got.plt + 24
> > is not at 4K boundary if it was on 4K boundary with 0x100ddc.
> 
> Then the relro adjustment calculation is broken.  It does not make sense
> to waste 1MB in a 120K object just to get 4K alignment.

So, can you suggest a better solution?
The constraints are:
1) for all segments, (p_vaddr % MAXPAGESIZE) == (p_offset % MAXPAGESIZE)
   This is because the ELF object ought to be usable on systems with
   MAXPAGESIZE page size.
2) so that the PT_GNU_RELRO region can be successfully protected
   when system page size <= COMMONPAGESIZE, PT_GNU_RELRO's end must be
   COMMONPAGESIZE aligned.  For system page size > COMMONPAGESIZE the
   library/binary shall be usable, but no protection will work.

> Also, looking at the linker script template elf.sc, I'm wondering why
> DATA_SEGMENT_RELRO_GOTPLT_END isn't defined as this:
> 
>     DATA_SEGMENT_RELRO_GOTPLT_END=". = DATA_SEGMENT_RELRO_END (. + ${SEPARATE_GOTPLT}) - ${SEPARATE_GOTPLT};"

DATA_SEGMENT_RELRO_END as currently implemented returns dot, not its
argument.  If you don't like this, feel free to submit a patch which
will change both the ldexp.c part end elf.sc (and pray nobody uses
it in their linker scripts other than the built-in ones).

> and why this definition is only active when COMMONPAGESIZE is defined.  In
> other places SEPARATE_GOTPLT is used even when COMMONPAGESIZE is not
> defined.

Because DATA_SEGMENT_RELRO_END relies on DATA_SEGMENT_ALIGN/DATA_SEGMENT_END
directives to be also present in the linker script, and they are only
present if COMMONPAGESIZE is defined.
If you want them appear, but the commonly used page size is equal to
MAXPAGESIZE, just define COMMONPAGESIZE to MAXPAGESIZE as already
e.g. i386 is doing.
When there is no COMMONPAGESIZE definition, that tells the linker
to not do any DATA_SEGMENT_* adjustements (as even without -z relro
they are disk space unfriendly; though without -z relro they may
waste just up to COMMONPAGESIZE bytes on the disk).

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]