diff options
| author | George Rimar <grimar@accesssoftek.com> | 2017-04-14 09:37:00 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2017-04-14 09:37:00 +0000 |
| commit | 1022112d770f49b3697d2b7267f5f9915409de41 (patch) | |
| tree | 4e4284f0d94a39a3d669f24e8f46fb2278fb5e56 | |
| parent | 36a0b98e242e92e257acca87accfc1679798a41e (diff) | |
| download | bcm5719-llvm-1022112d770f49b3697d2b7267f5f9915409de41.tar.gz bcm5719-llvm-1022112d770f49b3697d2b7267f5f9915409de41.zip | |
[ELF] - Linkerscript: make section with no content to be SHT_PROGBITS by default.
Imagine next script:
SECTIONS { BYTE(0x11); }
Section content written to disk will be 0x11. Previous LLD behavior was to make this
section SHT_NOBITS. What is not correct because section has content.
ld.bfd makes such sections SHT_PROGBITS, this patch do the same.
This fixes PR32537
Differential revision: https://reviews.llvm.org/D32016
llvm-svn: 300317
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 2 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/orphan-first-cmd.s | 4 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/symbol-only.s | 2 |
3 files changed, 5 insertions, 3 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 5a9e4652b22..ab2ca22e9e1 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -632,7 +632,7 @@ void LinkerScript::adjustSectionsBeforeSorting() { // '.' is assigned to, but creating these section should not have any bad // consequeces and gives us a section to put the symbol in. uint64_t Flags = SHF_ALLOC; - uint32_t Type = SHT_NOBITS; + uint32_t Type = SHT_PROGBITS; for (BaseCommand *Base : Opt.Commands) { auto *Cmd = dyn_cast<OutputSectionCommand>(Base); if (!Cmd) diff --git a/lld/test/ELF/linkerscript/orphan-first-cmd.s b/lld/test/ELF/linkerscript/orphan-first-cmd.s index 3fb3b31b9a4..263cb30d686 100644 --- a/lld/test/ELF/linkerscript/orphan-first-cmd.s +++ b/lld/test/ELF/linkerscript/orphan-first-cmd.s @@ -4,7 +4,7 @@ # RUN: foo = 123; \ # RUN: . = 0x1000; \ # RUN: . = 0x2000; \ -# RUN: .bar : { . = . + 1; } \ +# RUN: .bar : { *(.bar) } \ # RUN: }" > %t.script # RUN: ld.lld -o %t -T %t.script %t.o -shared # RUN: llvm-readobj -s %t | FileCheck %s @@ -16,3 +16,5 @@ # CHECK-NEXT: SHF_EXECINSTR # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x1000 + +.section .bar, "aw" diff --git a/lld/test/ELF/linkerscript/symbol-only.s b/lld/test/ELF/linkerscript/symbol-only.s index 76d54f01cdc..2fb57260b33 100644 --- a/lld/test/ELF/linkerscript/symbol-only.s +++ b/lld/test/ELF/linkerscript/symbol-only.s @@ -12,7 +12,7 @@ # CHECK: Sections: # CHECK-NEXT: Idx Name Size Address # CHECK-NEXT: 0 00000000 0000000000000000 -# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] BSS +# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] DATA # CHECK-NEXT: bar 00000000 0000000000001000 DATA # CHECK: SYMBOL TABLE: |

