diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -123,7 +123,8 @@ "\n>>> output section " + name + ": " + getELFSectionTypeName(config->emachine, type)); } - type = SHT_PROGBITS; + if (!typeIsSet) + type = SHT_PROGBITS; } else { type = isec->type; } diff --git a/lld/test/ELF/linkerscript/custom-section-type.s b/lld/test/ELF/linkerscript/custom-section-type.s --- a/lld/test/ELF/linkerscript/custom-section-type.s +++ b/lld/test/ELF/linkerscript/custom-section-type.s @@ -37,7 +37,7 @@ ## Mismatched progbits and expr are changed to SHT_PROGBITS. # MISMATCH: progbits PROGBITS # MISMATCH: note NOTE -# MISMATCH: expr PROGBITS +# MISMATCH: expr 0x42: # RUN: not ld.lld -T %t/unknown1.lds %t/a.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN1 # UNKNOWN1: error: {{.*}}.lds:1: symbol not found: foo diff --git a/lld/test/ELF/linkerscript/noload.s b/lld/test/ELF/linkerscript/noload.s --- a/lld/test/ELF/linkerscript/noload.s +++ b/lld/test/ELF/linkerscript/noload.s @@ -24,7 +24,7 @@ # WARN: warning: section type mismatch for .data_noload_a # CHECK2: Name Type Address Off Size -# CHECK2: .data_noload_a PROGBITS 0000000000000000 [[OFF:[0-9a-f]+]] 001001 +# CHECK2: .data_noload_a NOBITS 0000000000000000 [[OFF:[0-9a-f]+]] 001001 #--- asm .section .text,"ax",@progbits