llvm.org GIT mirror llvm / 3498257
Add support for the R_ARM_TARGET1 relocation, which should be given to relocations applied to all C++ constructors and destructors. This enables the linker to match concrete relocation types (absolute or relative) with whatever library or C++ support code is being linked against. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149057 91177308-0d34-0410-b5e6-96231b3b80d8 James Molloy 7 years ago
8 changed file(s) with 44 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
267267
268268 virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV);
269269
270 /// EmitXXStructor - Targets can override this to change how global constants
271 /// that are part of a C++ static/global constructor list are emitted.
272 virtual void EmitXXStructor(const Constant *CV) {
273 EmitGlobalConstant(CV);
274 }
275
270276 /// isBlockOnlyReachableByFallthough - Return true if the basic block has
271277 /// exactly one predecessor and the control transfer mechanism between
272278 /// the predecessor and this block is a fall-through.
168168 VK_ARM_GOTOFF,
169169 VK_ARM_TPOFF,
170170 VK_ARM_GOTTPOFF,
171 VK_ARM_TARGET1,
171172
172173 VK_PPC_TOC,
173174 VK_PPC_DARWIN_HA16, // ha16(symbol)
12951295 OutStreamer.SwitchSection(OutputSection);
12961296 if (OutStreamer.getCurrentSection() != OutStreamer.getPreviousSection())
12971297 EmitAlignment(Align);
1298 EmitGlobalConstant(Structors[i].second);
1298 EmitXXStructor(Structors[i].second);
12991299 }
13001300 }
13011301
5757 SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOT ||
5858 SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTOFF ||
5959 SRE.getKind() == MCSymbolRefExpr::VK_ARM_TPOFF ||
60 SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTTPOFF)
60 SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTTPOFF ||
61 SRE.getKind() == MCSymbolRefExpr::VK_ARM_TARGET1)
6162 OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
6263 else if (SRE.getKind() != MCSymbolRefExpr::VK_None &&
6364 SRE.getKind() != MCSymbolRefExpr::VK_PPC_DARWIN_HA16 &&
192193 case VK_ARM_TPOFF: return "(tpoff)";
193194 case VK_ARM_GOTTPOFF: return "(gottpoff)";
194195 case VK_ARM_TLSGD: return "(tlsgd)";
196 case VK_ARM_TARGET1: return "(target1)";
195197 case VK_PPC_TOC: return "toc";
196198 case VK_PPC_DARWIN_HA16: return "ha16";
197199 case VK_PPC_DARWIN_LO16: return "lo16";
296296 }
297297
298298 OutStreamer.EmitLabel(CurrentFnSym);
299 }
300
301 void ARMAsmPrinter::EmitXXStructor(const Constant *CV) {
302 uint64_t Size = TM.getTargetData()->getTypeAllocSize(CV->getType());
303 assert(Size && "C++ constructor pointer had zero size!");
304
305 const GlobalValue *GV = dyn_cast(CV);
306 assert(GV && "C++ constructor pointer was not a GlobalValue!");
307
308 const MCExpr *E = MCSymbolRefExpr::Create(Mang->getSymbol(GV),
309 (Subtarget->isTargetDarwin()
310 ? MCSymbolRefExpr::VK_None
311 : MCSymbolRefExpr::VK_ARM_TARGET1),
312 OutContext);
313
314 OutStreamer.EmitValue(E, Size);
299315 }
300316
301317 /// runOnMachineFunction - This uses the EmitInstruction()
7272 virtual void EmitFunctionEntryLabel();
7373 void EmitStartOfAsmFile(Module &M);
7474 void EmitEndOfAsmFile(Module &M);
75 void EmitXXStructor(const Constant *CV);
7576
7677 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
7778 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
235235 case MCSymbolRefExpr::VK_ARM_GOTOFF:
236236 Type = ELF::R_ARM_GOTOFF32;
237237 break;
238 }
238 case MCSymbolRefExpr::VK_ARM_TARGET1:
239 Type = ELF::R_ARM_TARGET1;
240 break;
241 }
239242 break;
240243 case ARM::fixup_arm_ldst_pcrel_12:
241244 case ARM::fixup_arm_pcrel_10:
0 ; RUN: llc %s -mtriple=armv7-linux-gnueabi -relocation-model=pic \
1 ; RUN: -filetype=obj -o - | elf-dump --dump-section-data | FileCheck %s
2
3
4 @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @f }]
5
6 define void @f() {
7 ret void
8 }
9
10 ; Check for a relocation of type R_ARM_TARGET1.
11 ; CHECK: ('r_type', 0x26)