[PATCH] D103815: [LLD][ELF] Fix PT_LOAD program header creation for NO_LOAD sections
Konstantin Schwarz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 9 07:52:57 PDT 2021
kschwarz 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
----------------
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.
================
Comment at: lld/test/ELF/linkerscript/noload.s:13
# CHECK: Type Offset VirtAddr PhysAddr
+# CHECK-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000
# CHECK-NEXT: LOAD 0x001000 0x0000000000020000 0x0000000000020000
----------------
GNU ld creates the following program headers:
```
LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x001000 RW 0x1000
LOAD 0x000000 0x0000000000010000 0x0000000000010000 0x000000 0x001001 RW 0x1000
LOAD 0x001000 0x0000000000020000 0x0000000000020000 0x000001 0x000001 R E 0x1000
```
Should we create a new header whenever a section has an `addrExpr` set, similar to our condition for lmaExpr?
GNU ld will only create a new header if the current section is placed at a discontiguous address.
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