[PATCH] D59531: [ELF] Produce multiple PT_NOTE segments as needed

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 13:23:41 PDT 2019


pcc added a comment.

In D59531#1434812 <https://reviews.llvm.org/D59531#1434812>, @ruiu wrote:

> In D59531#1434312 <https://reviews.llvm.org/D59531#1434312>, @pcc wrote:
>
> > Is it possible for this to fail with a linker script that looks like:
> >
> >   SECTIONS {
> >     . = SIZEOF_HEADERS;
> >     .note1 : { *(.note1) }
> >     . = 0x10000;
> >     .note2 : { *(.note2) }
> >   }
> >
> >
> > ?
>
>
> Is this realistic? I'm not worried too much about this because it seems you are intentionally creating a large gap between .note sections.


I suppose not. I guess a slightly more realistic case is where one of the notes appears in the linker script and another gets placed next to it as an orphan section. I'm not sure if that could actually result in a gap being created, though.

In D59531#1435362 <https://reviews.llvm.org/D59531#1435362>, @jakehehrlich wrote:

> I think pcc's case is valid and we should be able to update the script to account for it (I think anyway). This issue arises when the offset/vaddr of the output section is already known to be larger than gap that note traversal would assume. My current algorithm makes assumptions about how section layout occurs.
>
> Is the vaddr/offset of the output section already decided at this point? If so we can simplify this code *and* account for pcc's case. I was attempting to avoid causing this code to depend on section offsets already being decided when I wrote this.
>
> If we can't know section vaddr/offsets at this point then I vote we fallback to just one PT_NOTE per SHT_NOTE section as was already discussed. It's not ideal but I don't see a way to support pcc's case without knowing either the vaddr of the note or the offset. Assuming all notes go into the same PT_LOAD using offset should be just as good as using vaddr.


We don't know addresses at this point, and indeed we can't because the layout of the rest of the output file depends on how many program headers there are, which is decided by this function. I would be in favour of the one PT_NOTE per SHT_NOTE as it is simpler and handles more cases.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59531/new/

https://reviews.llvm.org/D59531





More information about the llvm-commits mailing list