This is the mail archive of the 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: Rewrite relro adjusting code

On Wed, Apr 22, 2015 at 6:52 AM, Alan Modra <> wrote:
> The linker tries to put the end of the last section in the relro
> segment exactly on a page boundary, because the relro segment itself
> must end on a page boundary.  If for any reason this can't be done,
> padding is inserted.  Since the end of the relro segment is typically
> between .got and .got.plt, padding effectively increases the size of
> the GOT.  This isn't nice for targets and code models with limited GOT
> addressing.
> The problem with the current code is that it doesn't cope very well
> with aligned sections in the relro segment.  When making .got aligned
> to a 256 byte boundary for PowerPC64, I found that often the initial
> alignment attempt failed and the fallback attempt to be less than
> adequate.  This is a particular problem for PowerPC64 since the
> distance between .got and .plt affects the size of plt call stubs,
> leading to "stubs don't match calculated size" errors.
> So this rewrite takes a direct approach to calculating a new relro
> base.  Starting from the last section in the segment, we calculate
> where it must start to position its end on the boundary, or as near as
> possible considering alignment requirements.  The new start then
> becomes the goal for the previous section to end, and so on for all
> sections.  This of course ignores the possibility that user scripts
> will place . = ALIGN(xxx); in the relro segment, or provide section
> address expressions.  In those cases we might fail, but the old code
> probably did too, and a fallback is provided.

> diff --git a/ld/testsuite/ld-x86-64/pr18176.d b/ld/testsuite/ld-x86-64/pr18176.d
> index 3a08539..4e3ad9f 100644
> --- a/ld/testsuite/ld-x86-64/pr18176.d
> +++ b/ld/testsuite/ld-x86-64/pr18176.d
> @@ -5,5 +5,5 @@
>  #target: x86_64-*-linux*
>  #...
> -  GNU_RELRO      0x04bd07 0x000000000024bd07 0x000000000024bd07 0x0022f9 0x0022f9 R   0x1
> +  GNU_RELRO      0x04bd17 0x000000000024bd17 0x000000000024bd17 0x0022e9 0x0022e9 R   0x1
>  #pass

Does it increase memory size?


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