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

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 11:02:30 PST 2017


On Fri, Jan 6, 2017 at 10:54 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Peter Collingbourne via Phabricator <reviews at reviews.llvm.org> writes:
>
>
> > Index: lld/test/ELF/relocation-copy-relro.s
> > ===================================================================
> > --- /dev/null
> > +++ lld/test/ELF/relocation-copy-relro.s
> > @@ -0,0 +1,33 @@
> > +// REQUIRES: x86
> > +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
> > +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux
> %p/Inputs/relocation-copy-relro.s -o %t2.o
> > +// RUN: ld.lld -shared %t2.o -o %t.so
> > +// RUN: ld.lld %t.o %t.so -o %t3
> > +// RUN: llvm-readobj -program-headers -s -r %t3 | FileCheck %s
> > +
> > +// CHECK:        Index: 7
>
> I don't think the index is relevant for the test.
>

Ok, I'll remove it.

>
> > +// CHECK-NEXT:   Name: .data.rel.ro (48)
>
> Why not the original .bss.rel.ro name?
>

Sorry, this should be testing for .bss.rel.ro (and NOBITS below). I'll fix
this once I update the remaining tests.

> +// CHECK-NEXT:   Type: SHT_PROGBITS (0x1)
> > +// CHECK-NEXT:   Flags [ (0x3)
> > +// CHECK-NEXT:     SHF_ALLOC (0x2)
> > +// CHECK-NEXT:     SHF_WRITE (0x1)
> > +// CHECK-NEXT:   ]
> > +// CHECK-NEXT:   Address: 0x2020B0
> > +// CHECK-NEXT:   Offset: 0x20B0
> > +// CHECK-NEXT:   Size: 8
>
>
> > -  // The TLS initialization block needs to be a single contiguous block
> in a R/W
> > -  // PT_LOAD, so stick TLS sections directly before R/W sections. The
> TLS NOBITS
> > -  // sections are placed here as they don't take up virtual address
> space in the
> > -  // PT_LOAD.
> >    bool AIsTls = A->Flags & SHF_TLS;
> >    bool BIsTls = B->Flags & SHF_TLS;
> > -  if (AIsTls != BIsTls)
> > -    return AIsTls;
>
> Why was it necessary to move TLS? Was there any problem with keeping it
> at the start of the RW PT_LOAD?
>

All TLS sections are RELRO (see
http://llvm-cs.pcc.me.uk/tools/lld/ELF/Writer.cpp#487) so they need to be
kept contiguous with the other RELRO sections.

Thanks,
-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170106/d032470b/attachment.html>


More information about the llvm-commits mailing list