annotate lib/Target/X86/X86TargetObjectFile.cpp @ 147:c2174574ed3a

LLVM 10
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Aug 2019 16:55:33 +0900
parents 3a76565eade5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 //===-- X86TargetObjectFile.cpp - X86 Object Info -------------------------===//
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
147
c2174574ed3a LLVM 10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
c2174574ed3a LLVM 10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
c2174574ed3a LLVM 10
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 134
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 //
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 #include "X86TargetObjectFile.h"
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
10 #include "llvm/ADT/StringExtras.h"
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
11 #include "llvm/BinaryFormat/COFF.h"
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
12 #include "llvm/BinaryFormat/Dwarf.h"
134
3a76565eade5 update 5.0.1
mir3636
parents: 121
diff changeset
13 #include "llvm/CodeGen/TargetLowering.h"
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
14 #include "llvm/IR/Mangler.h"
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15 #include "llvm/IR/Operator.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 #include "llvm/MC/MCContext.h"
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 #include "llvm/MC/MCExpr.h"
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
18 #include "llvm/MC/MCSectionCOFF.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 #include "llvm/MC/MCSectionELF.h"
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
20 #include "llvm/MC/MCValue.h"
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 using namespace llvm;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 using namespace dwarf;
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
25 const MCExpr *X86_64MachoTargetObjectFile::getTTypeGlobalReference(
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
26 const GlobalValue *GV, unsigned Encoding, const TargetMachine &TM,
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
27 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 // On Darwin/X86-64, we can reference dwarf symbols with foo@GOTPCREL+4, which
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 // is an indirect pc-relative reference.
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
31 if ((Encoding & DW_EH_PE_indirect) && (Encoding & DW_EH_PE_pcrel)) {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
32 const MCSymbol *Sym = TM.getSymbol(GV);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 const MCExpr *Res =
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
34 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
35 const MCExpr *Four = MCConstantExpr::create(4, getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
36 return MCBinaryExpr::createAdd(Res, Four, getContext());
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
39 return TargetLoweringObjectFileMachO::getTTypeGlobalReference(
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
40 GV, Encoding, TM, MMI, Streamer);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
43 MCSymbol *X86_64MachoTargetObjectFile::getCFIPersonalitySymbol(
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
44 const GlobalValue *GV, const TargetMachine &TM,
77
54457678186b LLVM 3.6
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
45 MachineModuleInfo *MMI) const {
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
46 return TM.getSymbol(GV);
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
49 const MCExpr *X86_64MachoTargetObjectFile::getIndirectSymViaGOTPCRel(
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
50 const MCSymbol *Sym, const MCValue &MV, int64_t Offset,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
51 MachineModuleInfo *MMI, MCStreamer &Streamer) const {
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
52 // On Darwin/X86-64, we need to use foo@GOTPCREL+4 to access the got entry
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
53 // from a data section. In case there's an additional offset, then use
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
54 // foo@GOTPCREL+4+<offset>.
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
55 unsigned FinalOff = Offset+MV.getConstant()+4;
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
56 const MCExpr *Res =
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
57 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
58 const MCExpr *Off = MCConstantExpr::create(FinalOff, getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
59 return MCBinaryExpr::createAdd(Res, Off, getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
60 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
61
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
62 const MCExpr *X86ELFTargetObjectFile::getDebugThreadLocalSymbol(
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
63 const MCSymbol *Sym) const {
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
64 return MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext());
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
65 }
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
66
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 void
120
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
68 X86FreeBSDTargetObjectFile::Initialize(MCContext &Ctx,
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
69 const TargetMachine &TM) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
70 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
71 InitializeELF(TM.Options.UseInitArray);
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
72 }
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
73
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
74 void
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
75 X86FuchsiaTargetObjectFile::Initialize(MCContext &Ctx,
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
76 const TargetMachine &TM) {
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
77 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
78 InitializeELF(TM.Options.UseInitArray);
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
79 }
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
80
1172e4bd9c6f update 4.0.0
mir3636
parents: 95
diff changeset
81 void
95
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
82 X86LinuxNaClTargetObjectFile::Initialize(MCContext &Ctx,
afa8332a0e37 LLVM 3.8
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents: 77
diff changeset
83 const TargetMachine &TM) {
0
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 InitializeELF(TM.Options.UseInitArray);
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 }
95c75e76d11b LLVM 3.4
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff changeset
87
121
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
88 void X86SolarisTargetObjectFile::Initialize(MCContext &Ctx,
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
89 const TargetMachine &TM) {
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
90 TargetLoweringObjectFileELF::Initialize(Ctx, TM);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
91 InitializeELF(TM.Options.UseInitArray);
803732b1fca8 LLVM 5.0
kono
parents: 120
diff changeset
92 }