[PATCH] D66097: Handle local commons for XCOFF object file writing
David Tenty via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 12 10:52:24 PDT 2019
daltenty created this revision.
daltenty added reviewers: jasonliu, sfertile, xingxue.
Herald added subscribers: llvm-commits, jsji, MaskRay, hiraditya, nemanjai.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D66097
Files:
llvm/lib/MC/MCXCOFFStreamer.cpp
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll
Index: llvm/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll
+++ llvm/test/CodeGen/PowerPC/aix-xcoff-lcomm.ll
@@ -1,6 +1,10 @@
; 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
+
@a = internal global i32 0, align 4
@b = internal global i64 0, align 8
@c = internal global i16 0, align 2
@@ -8,3 +12,33 @@
; CHECK: .lcomm a,4,a,2
; CHECK-NEXT: .lcomm b,8,b,3
; CHECK-NEXT: .lcomm c,2,c,1
+; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet.
+
+; 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: ]
Index: llvm/lib/MC/XCOFFObjectWriter.cpp
===================================================================
--- llvm/lib/MC/XCOFFObjectWriter.cpp
+++ llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -233,6 +233,12 @@
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.");
+ Add(&BSS, BSSCSects, MCSec);
+ break;
default:
report_fatal_error("Unhandled mapping of csect to section");
}
Index: llvm/lib/MC/MCXCOFFStreamer.cpp
===================================================================
--- llvm/lib/MC/MCXCOFFStreamer.cpp
+++ llvm/lib/MC/MCXCOFFStreamer.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#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"
@@ -72,7 +73,8 @@
return S;
}
-void MCXCOFFStreamer::EmitXCOFFLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
- unsigned ByteAlign) {
- llvm_unreachable("Not implemented yet.");
-}
\ No newline at end of file
+void MCXCOFFStreamer::EmitXCOFFLocalCommonSymbol(MCSymbol *Symbol,
+ uint64_t Size,
+ unsigned ByteAlignment) {
+ EmitCommonSymbol(Symbol, Size, ByteAlignment);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66097.214666.patch
Type: text/x-patch
Size: 3349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190812/51e0deda/attachment.bin>
More information about the llvm-commits
mailing list