[PATCH] D103815: [LLD][ELF] Fix PT_LOAD program header creation for NO_LOAD sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 17:45:13 PDT 2021


MaskRay added inline comments.


================
Comment at: lld/test/ELF/linkerscript/nobits-offset.s:22
 # CHECK:      Type Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
-# CHECK-NEXT: LOAD 0x000400 0x0000000000000400 0x0000000000000400 0x000000 0x000001 RW  0x1000
+# CHECK-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x000000 0x000001 R   0x1000
+# CHECK-NEXT: LOAD 0x001400 0x0000000000000400 0x0000000000000400 0x000000 0x000001 RW  0x1000
----------------
kschwarz wrote:
> Independent from this change, GNU ld assigns `WA` section flags to output sections defined as
> 
> ```
> .sec1 (NOLOAD) : { . += 1; }
> ```
> , while ld.lld assigns `A`. Is this intended?
> 
> This has also an effect on the number of program headers we create. In the test, the `bss` section has `WA`
> flags, thus getting its own header.
I think our behavior is intended.

The GNU ld behavior (I don't know what the current state is) was not ideal: https://sourceware.org/bugzilla/show_bug.cgi?id=26378#c8


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103815



More information about the llvm-commits mailing list