llvm.org GIT mirror llvm / 87dff1d
AArch64: use linker-private symbols for globals in MachO. We don't use section-relative relocations on AArch64, so all symbols must be at least visible to the linker (i.e. properly global or l_whatever, but not L_whatever). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303118 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 3 years ago
4 changed file(s) with 30 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6969 const MCExpr *PC = MCSymbolRefExpr::create(PCSym, getContext());
7070 return MCBinaryExpr::createSub(Res, PC, getContext());
7171 }
72
73 void AArch64_MachoTargetObjectFile::getNameWithPrefix(
74 SmallVectorImpl &OutName, const GlobalValue *GV,
75 const TargetMachine &TM) const {
76 // AArch64 does not use section-relative relocations so any global symbol must
77 // be accessed via at least a linker-private symbol.
78 getMangler().getNameWithPrefix(OutName, GV, /* CannotUsePrivateLabel */ true);
79 }
3939 const MCValue &MV, int64_t Offset,
4040 MachineModuleInfo *MMI,
4141 MCStreamer &Streamer) const override;
42
43 void getNameWithPrefix(SmallVectorImpl &OutName, const GlobalValue *GV,
44 const TargetMachine &TM) const override;
4245 };
4346
4447 } // end namespace llvm
55 ; CHECK-NEXT: stp x29, x30, [sp, #16]
66 ; CHECK-NEXT: add x29, sp, #16
77 ; CHECK-NEXT: stur wzr, [x29, #-4]
8 ; CHECK: adrp x0, L_.str@PAGE
9 ; CHECK: add x0, x0, L_.str@PAGEOFF
8 ; CHECK: adrp x0, l_.str@PAGE
9 ; CHECK: add x0, x0, l_.str@PAGEOFF
1010 ; CHECK-NEXT: bl _puts
1111 ; CHECK-NEXT: ldp x29, x30, [sp, #16]
1212 ; CHECK-NEXT: add sp, sp, #32
0 ; RUN: llc -mtriple=arm64-apple-ios %s -o - | FileCheck %s
1
2 ; All global symbols must be at-most linker-private for AArch64 because we don't
3 ; use section-relative relocations in MachO.
4
5 define i8* @private_sym() {
6 ; CHECK-LABEL: private_sym:
7 ; CHECK: adrp [[HIBITS:x[0-9]+]], l_var@PAGE
8 ; CHECK: add x0, [[HIBITS]], l_var@PAGEOFF
9
10 ret i8* getelementptr([2 x i8], [2 x i8]* @var, i32 0, i32 0)
11 }
12
13 ; CHECK: .section __TEXT,__cstring
14 ; CHECK: l_var:
15 ; CHECK: .asciz "\002"
16 @var = private unnamed_addr constant [2 x i8] [i8 2, i8 0]