mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[Solaris] emit .init_array instead of .ctors on Solaris (Sparc/x86)
Patch by Fedor Sergeev. Differential Revision: https://reviews.llvm.org/D33868 llvm-svn: 305948
This commit is contained in:
parent
1e20f37e13
commit
2909d80ad6
@ -15,6 +15,12 @@
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
void SparcELFTargetObjectFile::Initialize(MCContext &Ctx,
|
||||
const TargetMachine &TM) {
|
||||
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
|
||||
InitializeELF(TM.Options.UseInitArray);
|
||||
}
|
||||
|
||||
const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
|
||||
const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
|
||||
MachineModuleInfo *MMI, MCStreamer &Streamer) const {
|
||||
|
@ -23,6 +23,8 @@ public:
|
||||
TargetLoweringObjectFileELF()
|
||||
{}
|
||||
|
||||
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
|
||||
|
||||
const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
|
||||
unsigned Encoding,
|
||||
const TargetMachine &TM,
|
||||
|
@ -91,6 +91,8 @@ static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
|
||||
return llvm::make_unique<X86FreeBSDTargetObjectFile>();
|
||||
if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
|
||||
return llvm::make_unique<X86LinuxNaClTargetObjectFile>();
|
||||
if (TT.isOSSolaris())
|
||||
return llvm::make_unique<X86SolarisTargetObjectFile>();
|
||||
if (TT.isOSFuchsia())
|
||||
return llvm::make_unique<X86FuchsiaTargetObjectFile>();
|
||||
if (TT.isOSBinFormatELF())
|
||||
|
@ -86,6 +86,12 @@ X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,
|
||||
InitializeELF(TM.Options.UseInitArray);
|
||||
}
|
||||
|
||||
void X86SolarisTargetObjectFile::Initialize(MCContext &Ctx,
|
||||
const TargetMachine &TM) {
|
||||
TargetLoweringObjectFileELF::Initialize(Ctx, TM);
|
||||
InitializeELF(TM.Options.UseInitArray);
|
||||
}
|
||||
|
||||
const MCExpr *X86WindowsTargetObjectFile::lowerRelativeReference(
|
||||
const GlobalValue *LHS, const GlobalValue *RHS,
|
||||
const TargetMachine &TM) const {
|
||||
|
@ -66,6 +66,11 @@ namespace llvm {
|
||||
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
|
||||
};
|
||||
|
||||
/// \brief This implementation is used for Solaris on x86/x86-64.
|
||||
class X86SolarisTargetObjectFile : public X86ELFTargetObjectFile {
|
||||
void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
|
||||
};
|
||||
|
||||
/// \brief This implementation is used for Windows targets on x86 and x86-64.
|
||||
class X86WindowsTargetObjectFile : public TargetLoweringObjectFileCOFF {
|
||||
const MCExpr *
|
||||
|
29
test/CodeGen/SPARC/constructor.ll
Normal file
29
test/CodeGen/SPARC/constructor.ll
Normal file
@ -0,0 +1,29 @@
|
||||
; RUN: llc -mtriple sparc-sun-solaris2.11 -use-ctors < %s | FileCheck --check-prefix=CTOR %s
|
||||
; RUN: llc -mtriple sparc-sun-solaris2.11 < %s | FileCheck --check-prefix=INIT-ARRAY %s
|
||||
@llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { i32 15, void ()* @g, i8* @v }]
|
||||
|
||||
@v = weak_odr global i8 0
|
||||
|
||||
define void @f() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @g() {
|
||||
entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CTOR: .section .ctors.65520,#alloc,#write
|
||||
; CTOR-NEXT: .p2align 2
|
||||
; CTOR-NEXT: .word g
|
||||
; CTOR-NEXT: .section .ctors,#alloc,#write
|
||||
; CTOR-NEXT: .p2align 2
|
||||
; CTOR-NEXT: .word f
|
||||
|
||||
; INIT-ARRAY: .section .init_array.15,#alloc,#write
|
||||
; INIT-ARRAY-NEXT: .p2align 2
|
||||
; INIT-ARRAY-NEXT: .word g
|
||||
; INIT-ARRAY-NEXT: .section .init_array,#alloc,#write
|
||||
; INIT-ARRAY-NEXT: .p2align 2
|
||||
; INIT-ARRAY-NEXT: .word f
|
@ -1,7 +1,9 @@
|
||||
; RUN: llc -mtriple x86_64-pc-linux -use-ctors < %s | FileCheck --check-prefix=CTOR %s
|
||||
; RUN: llc -mtriple x86_64-unknown-freebsd -use-ctors < %s | FileCheck --check-prefix=CTOR %s
|
||||
; RUN: llc -mtriple x86_64-pc-solaris2.11 -use-ctors < %s | FileCheck --check-prefix=CTOR %s
|
||||
; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY %s
|
||||
; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck --check-prefix=INIT-ARRAY %s
|
||||
; RUN: llc -mtriple x86_64-pc-solaris2.11 < %s | FileCheck --check-prefix=INIT-ARRAY %s
|
||||
; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
|
||||
; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s --check-prefix=MCU-CTORS
|
||||
; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s --check-prefix=MCU-INIT-ARRAY
|
||||
|
Loading…
Reference in New Issue
Block a user