[PATCH] D29453: [ELF] - Allow going over alignment commands in algorithm of placing non-alloc orphans.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 11:42:38 PST 2017


grimar added inline comments.


================
Comment at: ELF/LinkerScript.cpp:701-704
   const auto *Assign = dyn_cast<SymbolAssignment>(&Cmd);
   if (!Assign)
     return true;
+  return !IsAlloc || Assign->Name != ".";
----------------
ruiu wrote:
> This is the linker script you are trying to handle.
> 
>   . = ALIGN(16);
>   .bss            :
>   {
>     __bss_start = .;
>     *(.bss)
>     __bss_end = .;
>   }
>   . = ALIGN(16);
>   _end = .;
> 
> It doesn't seem to be related to SHF_ALLOC. I wonder if you want to skip a pair of an alignment and an assignment to a symbol instead.
I think comment above says why we can not do that:

// We don't want to go over alignments for SHF_ALLOC sections, since doing so in
//  rx_sec : { *(rx_sec) }
//  . = ALIGN(0x1000);
//  /* The RW PT_LOAD starts here*/
//  rw_sec : { *(rw_sec) }

So if we just skip pair, case above will be broken.
Behavior of placing orphans is not specified, but at least what we implemented looks worked and what this 
patch adds is what at least some scripts relies on. Since bfd behaves in that way.


https://reviews.llvm.org/D29453





More information about the llvm-commits mailing list