From f93b8c29c8f6e71c07276cbaeb8b9cd6d06cbe52 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 26 Nov 2016 06:55:35 +0000 Subject: [PATCH] Create sections with just assignments as STT_NOBITS. This matches the behaviour of bfd ld. Using 0 was causing problems with strip, which would remove these sections. llvm-svn: 287969 --- lld/ELF/LinkerScript.cpp | 2 +- lld/test/ELF/linkerscript/symbol-only.s | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 51efa2e..5618abd 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -566,7 +566,7 @@ template 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. uintX_t Flags = SHF_ALLOC; - uint32_t Type = 0; + uint32_t Type = SHT_NOBITS; for (const std::unique_ptr &Base : Opt.Commands) { auto *Cmd = dyn_cast(Base.get()); if (!Cmd) diff --git a/lld/test/ELF/linkerscript/symbol-only.s b/lld/test/ELF/linkerscript/symbol-only.s index 67da70c..76d54f0 100644 --- a/lld/test/ELF/linkerscript/symbol-only.s +++ b/lld/test/ELF/linkerscript/symbol-only.s @@ -12,8 +12,8 @@ # CHECK: Sections: # CHECK-NEXT: Idx Name Size Address # CHECK-NEXT: 0 00000000 0000000000000000 -# CHECK-NEXT: 1 abc 00000000 [[ADDR:[0-9a-f]*]] -# CHECK-NEXT: 2 bar 00000000 0000000000001000 DATA +# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] BSS +# CHECK-NEXT: bar 00000000 0000000000001000 DATA # CHECK: SYMBOL TABLE: # CHECK: [[ADDR]] abc 00000000 foo -- 2.7.4