[PATCH] D22683: [ELF] Symbol assignment within input section list

Eugene Leviant via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 8 09:12:59 PDT 2016


evgeny777 updated this revision to Diff 67179.
evgeny777 added a comment.

Review updated.
Added support for "." assignment within input section list. Now the following script can be successfully parsed and processed:

  SECTIONS {
     .foo : { 
          * (.foo)
          sizeof_foo_1 = SIZEOF(.foo); /* sizeof_foo_1 is equal to sizeof( *.foo ) */
         * (.bar)
         sizeof_foo_2 = SIZEOF(.foo); /* sizeof_foo_2 is equal to sizeof ( *.foo ) + sizeof ( *.bar) */
         . = ALIGN(0x1000); /* The section ends on page boundary */ 
     }
  }

This patch uses virtual input sections (once again, yeah), but they're created and processed inside LinkerScript<ELFT>, without any change introduced to base class InputSection<ELFT>. The reason is that with "." assignments real section size depends on VA and can only be calculated in assignAddresses(). For example sizes of .foo and .bar output sections in example below will be different:

  SECTIONS {
      . = 0x500;
      .foo {  . = ALIGN(0x1000);  }  /* size of .foo is 0x1000 - 0x500 */        
  }
  SECTIONS {
      . = 0xA00;
      .bar {  . = ALIGN(0x1000);  }  /* size of .bar is 0x1000 - 0xA00 */        
  }

Please also check the test case


https://reviews.llvm.org/D22683

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/Symbols.cpp
  ELF/Writer.cpp
  test/ELF/linkerscript/linkerscript-symbols-synthetic.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22683.67179.patch
Type: text/x-patch
Size: 17824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160808/48e5ba7f/attachment.bin>


More information about the llvm-commits mailing list