diff --git a/llvm/include/llvm/Object/COFF.h b/llvm/include/llvm/Object/COFF.h --- a/llvm/include/llvm/Object/COFF.h +++ b/llvm/include/llvm/Object/COFF.h @@ -379,8 +379,8 @@ } bool isCommon() const { - return isExternal() && getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED && - getValue() != 0; + return (isExternal() || isSection()) && + getSectionNumber() == COFF::IMAGE_SYM_UNDEFINED && getValue() != 0; } bool isUndefined() const { diff --git a/llvm/test/Object/coff-sec-sym.test b/llvm/test/Object/coff-sec-sym.test new file mode 100644 --- /dev/null +++ b/llvm/test/Object/coff-sec-sym.test @@ -0,0 +1,20 @@ +# Check that section symbol (IMAGE_SYM_CLASS_SECTION) is listed as common symbol. + +# RUN: yaml2obj %s -o %t.obj +# RUN: llvm-nm %t.obj | FileCheck %s + +# CHECK: 00000001 C foo + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: +symbols: + - Name: foo + Value: 1 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_SECTION +...