[PATCH] D28272: ELF: Reserve space for copy relocations of read-only symbols in relro.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 13:49:37 PST 2017


Peter Collingbourne <peter at pcc.me.uk> writes:

> On Thu, Jan 5, 2017 at 1:17 PM, Rafael Avila de Espindola <
> rafael.espindola at gmail.com> wrote:
>
>> Peter Collingbourne via Phabricator <reviews at reviews.llvm.org> writes:
>>
>> > Relatedly, I discovered a bug in this patch. We can't use SHT_NOBITS for
>> the new section because we need to lay out all NOBITS sections contiguously
>> at the end of the LOAD. RELRO also needs to be contiguous (there can only
>> be one RELRO header), so we can't have another RELRO covering part of the
>> bss.
>>
>> You could move the RELRO to the end of the regular RW PT_LOAD, no? That
>> way it
>> will be just before the nobits sections and the nobits sections could
>> start with RELRO ones. That way the RELRO segment would span the end of
>> the regular (non-nobits) sections and the start of the nobits ones.
>>
>
> Yes, I think that would work, thanks. So the layout would be:
>
> non-RELRO non-NOBITS
> [page alignment]
> RELRO non-NOBITS
> RELRO NOBITS
> [page alignment]
> non-RELRO NOBITS
>
> The downside is that there would be an extra page alignment, but that
> doesn't seem too important.

We already have two alignments. What we currently have is:

   [page alignment]
   RELRO (always non-NOBITS)
   [page alignment]
   non-RELRO non-NOBITS
   non-RELRO NOBITS

Cheers,
Rafael


More information about the llvm-commits mailing list