llvm.org GIT mirror llvm / 7c6b474
[Solaris] emit .init_array instead of .ctors on Solaris (Sparc/x86) Patch by Fedor Sergeev. Differential Revision: https://reviews.llvm.org/D33868 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305948 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 3 years ago
7 changed file(s) with 52 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
1313 #include "llvm/Target/TargetLowering.h"
1414
1515 using namespace llvm;
16
17 void SparcELFTargetObjectFile::Initialize(MCContext &Ctx,
18 const TargetMachine &TM) {
19 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
20 InitializeELF(TM.Options.UseInitArray);
21 }
1622
1723 const MCExpr *SparcELFTargetObjectFile::getTTypeGlobalReference(
1824 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
2222 TargetLoweringObjectFileELF()
2323 {}
2424
25 void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
26
2527 const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
2628 unsigned Encoding,
2729 const TargetMachine &TM,
9090 return llvm::make_unique();
9191 if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
9292 return llvm::make_unique();
93 if (TT.isOSSolaris())
94 return llvm::make_unique();
9395 if (TT.isOSFuchsia())
9496 return llvm::make_unique();
9597 if (TT.isOSBinFormatELF())
8181 void
8282 X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,
8383 const TargetMachine &TM) {
84 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
85 InitializeELF(TM.Options.UseInitArray);
86 }
87
88 void X86SolarisTargetObjectFile::Initialize(MCContext &Ctx,
89 const TargetMachine &TM) {
8490 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
8591 InitializeELF(TM.Options.UseInitArray);
8692 }
6565 void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
6666 };
6767
68 /// \brief This implementation is used for Solaris on x86/x86-64.
69 class X86SolarisTargetObjectFile : public X86ELFTargetObjectFile {
70 void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
71 };
72
6873 /// \brief This implementation is used for Windows targets on x86 and x86-64.
6974 class X86WindowsTargetObjectFile : public TargetLoweringObjectFileCOFF {
7075 const MCExpr *
0 ; RUN: llc -mtriple sparc-sun-solaris2.11 -use-ctors < %s | FileCheck --check-prefix=CTOR %s
1 ; RUN: llc -mtriple sparc-sun-solaris2.11 < %s | FileCheck --check-prefix=INIT-ARRAY %s
2 @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 }]
3
4 @v = weak_odr global i8 0
5
6 define void @f() {
7 entry:
8 ret void
9 }
10
11 define void @g() {
12 entry:
13 ret void
14 }
15
16 ; CTOR: .section .ctors.65520,#alloc,#write
17 ; CTOR-NEXT: .p2align 2
18 ; CTOR-NEXT: .word g
19 ; CTOR-NEXT: .section .ctors,#alloc,#write
20 ; CTOR-NEXT: .p2align 2
21 ; CTOR-NEXT: .word f
22
23 ; INIT-ARRAY: .section .init_array.15,#alloc,#write
24 ; INIT-ARRAY-NEXT: .p2align 2
25 ; INIT-ARRAY-NEXT: .word g
26 ; INIT-ARRAY-NEXT: .section .init_array,#alloc,#write
27 ; INIT-ARRAY-NEXT: .p2align 2
28 ; INIT-ARRAY-NEXT: .word f
0 ; RUN: llc -mtriple x86_64-pc-linux -use-ctors < %s | FileCheck --check-prefix=CTOR %s
11 ; RUN: llc -mtriple x86_64-unknown-freebsd -use-ctors < %s | FileCheck --check-prefix=CTOR %s
2 ; RUN: llc -mtriple x86_64-pc-solaris2.11 -use-ctors < %s | FileCheck --check-prefix=CTOR %s
23 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY %s
34 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck --check-prefix=INIT-ARRAY %s
5 ; RUN: llc -mtriple x86_64-pc-solaris2.11 < %s | FileCheck --check-prefix=INIT-ARRAY %s
46 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
57 ; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s --check-prefix=MCU-CTORS
68 ; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s --check-prefix=MCU-INIT-ARRAY