[llvm] r370070 - Handle local commons for XCOFF object file writing
Jason Liu via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 27 08:14:46 PDT 2019
Author: jasonliu
Date: Tue Aug 27 08:14:45 2019
New Revision: 370070
URL: http://llvm.org/viewvc/llvm-project?rev=370070&view=rev
Log:
Handle local commons for XCOFF object file writing
Summary:
Adds support for emitting common local global symbols to an XCOFF object file.
Local commons are emitted into the .bss section with a storage class of
C_HIDEXT.
Patch by: daltenty
Reviewers: sfertile, hubert.reinterpretcast
Differential Revision: https://reviews.llvm.org/D66097
Modified:
llvm/trunk/lib/MC/MCXCOFFStreamer.cpp
llvm/trunk/lib/MC/XCOFFObjectWriter.cpp
llvm/trunk/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll
Modified: llvm/trunk/lib/MC/MCXCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCXCOFFStreamer.cpp?rev=370070&r1=370069&r2=370070&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCXCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCXCOFFStreamer.cpp Tue Aug 27 08:14:45 2019
@@ -10,11 +10,12 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/MC/MCXCOFFStreamer.h"
+#include "llvm/BinaryFormat/XCOFF.h"
#include "llvm/MC/MCAsmBackend.h"
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSymbolXCOFF.h"
+#include "llvm/MC/MCXCOFFStreamer.h"
#include "llvm/Support/TargetRegistry.h"
using namespace llvm;
@@ -72,7 +73,8 @@ MCStreamer *llvm::createXCOFFStreamer(MC
return S;
}
-void MCXCOFFStreamer::EmitXCOFFLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlign) {
- report_fatal_error("Emission of local commons not implemented yet.");
+void MCXCOFFStreamer::EmitXCOFFLocalCommonSymbol(MCSymbol *Symbol,
+ uint64_t Size,
+ unsigned ByteAlignment) {
+ EmitCommonSymbol(Symbol, Size, ByteAlignment);
}
Modified: llvm/trunk/lib/MC/XCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/XCOFFObjectWriter.cpp?rev=370070&r1=370069&r2=370070&view=diff
==============================================================================
--- llvm/trunk/lib/MC/XCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/XCOFFObjectWriter.cpp Tue Aug 27 08:14:45 2019
@@ -235,6 +235,13 @@ void XCOFFObjectWriter::executePostLayou
break;
}
report_fatal_error("Unhandled mapping of read-write csect to section.");
+ case XCOFF::XMC_BS:
+ assert(XCOFF::XTY_CM == MCSec->getCSectType() &&
+ "Mapping invalid csect. CSECT with bss storage class must be "
+ "common type.");
+ BSSCsects.emplace_back(MCSec);
+ WrapperMap[MCSec] = &BSSCsects.back();
+ break;
default:
report_fatal_error("Unhandled mapping of csect to section.");
}
Modified: llvm/trunk/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll?rev=370070&r1=370069&r2=370070&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll Tue Aug 27 08:14:45 2019
@@ -1,6 +1,14 @@
; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s
+; RUN: llvm-readobj --section-headers --file-header %t.o | \
+; RUN: FileCheck --check-prefix=OBJ %s
+
+; RUN: not llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj < %s 2>&1 | \
+; RUN: FileCheck --check-prefix=OBJ64 %s
+; OBJ64: LLVM ERROR: 64-bit XCOFF object files are not supported yet.
+
@a = internal global i32 0, align 4
@b = internal global i64 0, align 8
@c = internal global i16 0, align 2
@@ -8,3 +16,32 @@
; CHECK: .lcomm a,4,a,2
; CHECK-NEXT: .lcomm b,8,b,3
; CHECK-NEXT: .lcomm c,2,c,1
+
+; OBJ: File: {{.*}}aix-xcoff-lcomm.ll.tmp.o
+; OBJ-NEXT: Format: aixcoff-rs6000
+; OBJ-NEXT: Arch: powerpc
+; OBJ-NEXT: AddressSize: 32bit
+; OBJ-NEXT: FileHeader {
+; OBJ-NEXT: Magic: 0x1DF
+; OBJ-NEXT: NumberOfSections: 1
+; OBJ-NEXT: TimeStamp:
+; OBJ-NEXT: SymbolTableOffset: 0x3C
+; OBJ-NEXT: SymbolTableEntries: 6
+; OBJ-NEXT: OptionalHeaderSize: 0x0
+; OBJ-NEXT: Flags: 0x0
+; OBJ-NEXT: }
+; OBJ-NEXT: Sections [
+; OBJ-NEXT: Section {
+; OBJ-NEXT: Index: 1
+; OBJ-NEXT: Name: .bss
+; OBJ-NEXT: PhysicalAddress: 0x0
+; OBJ-NEXT: VirtualAddress: 0x0
+; OBJ-NEXT: Size: 0x14
+; OBJ-NEXT: RawDataOffset: 0x0
+; OBJ-NEXT: RelocationPointer: 0x0
+; OBJ-NEXT: LineNumberPointer: 0x0
+; OBJ-NEXT: NumberOfRelocations: 0
+; OBJ-NEXT: NumberOfLineNumbers: 0
+; OBJ-NEXT: Type: STYP_BSS (0x80)
+; OBJ-NEXT: }
+; OBJ-NEXT: ]
More information about the llvm-commits
mailing list