[PATCH] D76995: [ELF] Propagate LMA offset to sections with neither AT() nor AT>

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 11:15:02 PDT 2020


MaskRay added a comment.

In D76995#1954314 <https://reviews.llvm.org/D76995#1954314>, @psmith wrote:

> LGTM thanks for the update. I think it would be good to fix the discrepancies between LLD and BFD in follow up patches if it is reasonable to do so.


Looks like our current behavior is close to GNU ld enough. Actually, GNU ld's behavior is different from the documentation

  % cat a.s
  SECTIONS {
    . = 0x1000;
    .a : { *(.a) }
    .b : AT(0x2005) { *(.b) }
  /* "If the section has a specific VMA address, then this is used as the LMA address as well." is not obeyed for .c */
    .c 0x3006 : { *(.c) }
  }



  Program Headers:
    Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
    LOAD           0x001000 0x0000000000001000 0x0000000000001000 0x000002 0x000002 R E 0x1000
    LOAD           0x001002 0x0000000000001002 0x0000000000002005 0x000001 0x000001 R   0x1000
    LOAD           0x001006 0x0000000000003006 0x0000000000004009 0x000002 0x000002 R   0x1000
    LOAD           0x001008 0x0000000000003008 0x0000000000004010 0x000001 0x000001 RW  0x1000
  
   Section to Segment mapping:
    Segment Sections...
     00     .text .a 
     01     .b 
     02     .c .d 
     03     .data


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76995





More information about the llvm-commits mailing list