mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Fix .comm and .lcomm on COFF.
These should not use COMDATs. GNU as uses .bss for .lcomm and section 0 for .comm. Given static int a; int b; MSVC puts both in .bss. This patch then puts both .comm and .lcomm on .bss. With this change we agree with gas on .lcomm, are much closer on .comm and clang-cl matches msvc on the above example. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195654 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
68bef45439
commit
c7daeb3098
@ -140,28 +140,12 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||
unsigned ByteAlignment, bool External) {
|
||||
assert(!Symbol->isInSection() && "Symbol must not already have a section!");
|
||||
|
||||
std::string SectionName(".bss$linkonce");
|
||||
SectionName.append(Symbol->getName().begin(), Symbol->getName().end());
|
||||
|
||||
MCSymbolData &SymbolData = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
|
||||
unsigned Characteristics =
|
||||
COFF::IMAGE_SCN_LNK_COMDAT |
|
||||
COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
|
||||
COFF::IMAGE_SCN_MEM_READ |
|
||||
COFF::IMAGE_SCN_MEM_WRITE;
|
||||
|
||||
int Selection = COFF::IMAGE_COMDAT_SELECT_LARGEST;
|
||||
|
||||
const MCSection *Section = MCStreamer::getContext().getCOFFSection(
|
||||
SectionName, Characteristics, SectionKind::getBSS(), Symbol->getName(),
|
||||
Selection);
|
||||
|
||||
const MCSectionCOFF *Section = getSectionBSS();
|
||||
MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section);
|
||||
|
||||
if (SectionData.getAlignment() < ByteAlignment)
|
||||
SectionData.setAlignment(ByteAlignment);
|
||||
|
||||
MCSymbolData &SymbolData = getAssembler().getOrCreateSymbolData(*Symbol);
|
||||
SymbolData.setExternal(External);
|
||||
|
||||
AssignSection(Symbol, Section);
|
||||
|
25
test/MC/COFF/comm.s
Normal file
25
test/MC/COFF/comm.s
Normal file
@ -0,0 +1,25 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | llvm-readobj -t | FileCheck %s
|
||||
|
||||
.lcomm _a,4,4
|
||||
.comm _b, 4, 2
|
||||
|
||||
|
||||
// CHECK: Symbol {
|
||||
// CHECK: Name: _a
|
||||
// CHECK-NEXT: Value:
|
||||
// CHECK-NEXT: Section: .bss
|
||||
// CHECK-NEXT: BaseType: Null
|
||||
// CHECK-NEXT: ComplexType: Null
|
||||
// CHECK-NEXT: StorageClass: Static
|
||||
// CHECK-NEXT: AuxSymbolCount: 0
|
||||
// CHECK-NEXT: }
|
||||
|
||||
// CHECK: Symbol {
|
||||
// CHECK: Name: _b
|
||||
// CHECK-NEXT: Value: 4
|
||||
// CHECK-NEXT: Section: .bss
|
||||
// CHECK-NEXT: BaseType: Null
|
||||
// CHECK-NEXT: ComplexType: Null
|
||||
// CHECK-NEXT: StorageClass: External
|
||||
// CHECK-NEXT: AuxSymbolCount: 0
|
||||
// CHECK-NEXT: }
|
Loading…
x
Reference in New Issue
Block a user