llvm.org GIT mirror llvm / 87e6561
Make NaCl's use of .init_array for static constructors match Linux Summary: The generic ELF TargetObjectFile defaults to .ctors, but Linux's defaults to .init_array by calling InitializeELF with the value of UseInitArray from TargetMachine. Make NaCl's behavior match. Reviewers: jvoung Differential Revision: http://reviews.llvm.org/D8240 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231934 91177308-0d34-0410-b5e6-96231b3b80d8 Derek Schuff 5 years ago
4 changed file(s) with 15 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3636 return make_unique();
3737 }
3838
39 if (TT.isOSLinux())
40 return make_unique();
39 if (TT.isOSLinux() || TT.isOSNaCl())
40 return make_unique();
4141 if (TT.isOSBinFormatELF())
4242 return make_unique();
4343 if (TT.isKnownWindowsMSVCEnvironment())
6565 }
6666
6767 void
68 X86LinuxTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
68 X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,
69 const TargetMachine &TM) {
6970 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
7071 InitializeELF(TM.Options.UseInitArray);
7172 }
4343 const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override;
4444 };
4545
46 /// X86LinuxTargetObjectFile - This implementation is used for linux x86
47 /// and x86-64.
48 class X86LinuxTargetObjectFile : public X86ELFTargetObjectFile {
46 /// X86LinuxNaClTargetObjectFile - This implementation is used for linux and
47 /// Native Client on x86 and x86-64.
48 class X86LinuxNaClTargetObjectFile : public X86ELFTargetObjectFile {
4949 void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
5050 };
5151
0 ; RUN: llc -mtriple x86_64-pc-linux -use-ctors < %s | FileCheck --check-prefix=CTOR %s
11 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY %s
2 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
23 @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 }]
34
45 @v = weak_odr global i8 0
2627 ; INIT-ARRAY-NEXT: .section .init_array,"aw",@init_array
2728 ; INIT-ARRAY-NEXT: .align 8
2829 ; INIT-ARRAY-NEXT: .quad f
30
31 ; NACL: .section .init_array.15,"aGw",@init_array,v,comdat
32 ; NACL-NEXT: .align 4
33 ; NACL-NEXT: .long g
34 ; NACL-NEXT: .section .init_array,"aw",@init_array
35 ; NACL-NEXT: .align 4
36 ; NACL-NEXT: .long f