diff --git a/llvm/lib/MC/MCXCOFFStreamer.cpp b/llvm/lib/MC/MCXCOFFStreamer.cpp --- a/llvm/lib/MC/MCXCOFFStreamer.cpp +++ b/llvm/lib/MC/MCXCOFFStreamer.cpp @@ -10,12 +10,13 @@ // //===----------------------------------------------------------------------===// +#include "llvm/MC/MCXCOFFStreamer.h" #include "llvm/BinaryFormat/XCOFF.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSymbolXCOFF.h" -#include "llvm/MC/MCXCOFFStreamer.h" #include "llvm/Support/TargetRegistry.h" using namespace llvm; @@ -37,6 +38,10 @@ Symbol->setStorageClass(XCOFF::C_EXT); Symbol->setExternal(true); break; + case MCSA_LGlobal: + Symbol->setStorageClass(XCOFF::C_HIDEXT); + Symbol->setExternal(true); + break; default: report_fatal_error("Not implemented yet."); } diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -355,6 +355,11 @@ if (XSym == ContainingCsect->getQualNameSymbol()) continue; + // If the symbol is a label, don't put it in the symbol table is it's not + // supposed to be external. + if (!XSym->isExternal()) + continue; + assert(SectionMap.find(ContainingCsect) != SectionMap.end() && "Expected containing csect to exist in map"); diff --git a/llvm/test/CodeGen/PowerPC/aix-internal.ll b/llvm/test/CodeGen/PowerPC/aix-internal.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/PowerPC/aix-internal.ll @@ -0,0 +1,37 @@ +; RUN: llc -mtriple powerpc-ibm-aix -verify-machineinstrs -mcpu=pwr4 \ +; RUN: -filetype=obj -o %t.o < %s +; RUN: llvm-readobj --syms %t.o | FileCheck %s +; RUN: not --crash llc -mtriple powerpc64-ibm-aix -verify-machineinstrs -mcpu=pwr4 \ +; RUN: -filetype=obj -o %t.o < %s 2>&1 | FileCheck --check-prefix=64-CHECK %s + +define internal i32 @foo() { + ret i32 1 +} + +; CHECK: Symbol { +; CHECK: Name: .foo +; CHECK-NEXT: Value (RelocatableAddress): +; CHECK-NEXT: Section: .text +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) + +; CHECK: Symbol { +; CHECK-NEXT: Index: [[#INDX:]] +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Value (RelocatableAddress): +; CHECK-NEXT: Section: .data +; CHECK-NEXT: Type: 0x0 +; CHECK-NEXT: StorageClass: C_HIDEXT (0x6B) +; CHECK-NEXT: CSECT Auxiliary Entry { +; CHECK-NEXT: Index: [[#INDX+1]] +; CHECK-NEXT: SectionLen: 12 +; CHECK-NEXT: ParameterHashIndex: +; CHECK-NEXT: TypeChkSectNum: +; CHECK-NEXT: SymbolAlignmentLog2: +; CHECK-NEXT: SymbolType: XTY_SD (0x1) +; CHECK-NEXT: StorageMappingClass: XMC_DS (0xA) + +; Make sure no label is emitted. +; CHECK-NOT: Name: foo + +;64-CHECK: LLVM ERROR: 64-bit XCOFF object files are not supported yet.