[PATCH] D34977: [ELF] - Allow moving location counter backward in some cases.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 4 03:49:42 PDT 2017


grimar created this revision.
Herald added a subscriber: emaste.

  PHDRS {
   text PT_LOAD FLAGS(5); /* R_E */
   data PT_LOAD FLAGS(6); /* RW_ */
   percpu PT_LOAD FLAGS(6); /* RW_ */
   init PT_LOAD FLAGS(7); /* RWE */
   note PT_NOTE FLAGS(0); /* ___ */
  }
  SECTIONS
  {
   . = (0xffffffff80000000 + ALIGN(0x1000000, 0x200000));
  
   .text : AT(ADDR(.text) - 0xffffffff80000000) {...} :text = 0x9090
   .notes : AT(ADDR(.notes) - 0xffffffff80000000) {...} :text :note
   __ex_table : AT(ADDR(__ex_table) - 0xffffffff80000000) {...} :text = 0x9090
   ...
   .data..percpu 0 : AT(__per_cpu_load - 0xffffffff80000000) { } :percpu
   . = __per_cpu_load + SIZEOF(.data..percpu);
  ...
  }

When trying to assign address 0x0 to `.data..percpu` LLD fails with 
"unable to move location counter backward" error. Though it should be safe to do
because script controls segments via PHDRS command by itself.

This patch suggests to change logic we use currently. I think what we can do instead of
restricting moving counter always is to check that all sections in PT_LOAD are in assending order.


https://reviews.llvm.org/D34977

Files:
  ELF/LinkerScript.cpp
  ELF/Writer.cpp
  test/ELF/linkerscript/locationcounter-moveback.s
  test/ELF/linkerscript/locationcountererr2.s
  test/ELF/linkerscript/out-of-order.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34977.105149.patch
Type: text/x-patch
Size: 6180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170704/3bae4ed4/attachment-0001.bin>


More information about the llvm-commits mailing list