[PATCH] D62177: [ELF] Don't advance position in a memory region when assigning to the Dot

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 01:42:38 PDT 2019


grimar added a comment.

I find the behavior of the GNU linkers wierd.

If we use bfd and have:

  .section .foo,"ax";
  nop;
  
  .section .bar,"ax";
  nop;

and script:

  MEMORY {
    ram (ax) : ORIGIN = 0x42000, LENGTH = 0x100000
  }
  SECTIONS {
    .foo : { *(.foo*) }
    . += 0x2000;
    .bar : { *(.bar*) }
  }

Then `.foo` section has address 0x42000 and `.bar` has 0x42001.
I.e. moving a dot does not change the address of the next section.

But if I remove `MEMORY`:

  SECTIONS {
    .foo : { *(.foo*) }
    . += 0x2000;
    .bar : { *(.bar*) }
  }

Then `.foo` is 0x0 and `.bar` is `0x2001` (as I would expect to see)

I think it is very strange that `MEMORY` command affects on a Dot assignment behavior in that way.

Seems that original script from PR had to use a hack to move the second output section:

  aligned_dot = ALIGN(0x10 * 1024);  
      
  .data aligned_dot :
  {
    *(.data*)
  }


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62177





More information about the llvm-commits mailing list