@@ -36,6 +36,8 @@ class SystemZELFObjectWriter : public MCELFObjectTargetWriter {
36
36
const MCFixup &Fixup, bool IsPCRel) const override ;
37
37
bool needsRelocateWithSymbol (const MCValue &Val, const MCSymbol &Sym,
38
38
unsigned Type) const override ;
39
+ unsigned getAbsoluteReloc (SMLoc Loc, unsigned Kind) const ;
40
+ unsigned getPCRelReloc (SMLoc Loc, unsigned Kind) const ;
39
41
};
40
42
41
43
} // end anonymous namespace
@@ -45,7 +47,8 @@ SystemZELFObjectWriter::SystemZELFObjectWriter(uint8_t OSABI)
45
47
/* HasRelocationAddend_=*/ true ) {}
46
48
47
49
// Return the relocation type for an absolute value of MCFixupKind Kind.
48
- static unsigned getAbsoluteReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
50
+ unsigned SystemZELFObjectWriter::getAbsoluteReloc (SMLoc Loc,
51
+ unsigned Kind) const {
49
52
switch (Kind) {
50
53
case FK_Data_1:
51
54
case SystemZ::FK_390_U8Imm:
@@ -66,12 +69,12 @@ static unsigned getAbsoluteReloc(MCContext &Ctx, SMLoc Loc, unsigned Kind) {
66
69
case FK_Data_8:
67
70
return ELF::R_390_64;
68
71
}
69
- Ctx. reportError (Loc, " Unsupported absolute address" );
72
+ reportError (Loc, " Unsupported absolute address" );
70
73
return 0 ;
71
74
}
72
75
73
76
// Return the relocation type for a PC-relative value of MCFixupKind Kind.
74
- static unsigned getPCRelReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
77
+ unsigned SystemZELFObjectWriter:: getPCRelReloc (SMLoc Loc, unsigned Kind) const {
75
78
switch (Kind) {
76
79
case FK_Data_2:
77
80
case SystemZ::FK_390_U16Imm:
@@ -92,61 +95,7 @@ static unsigned getPCRelReloc(MCContext &Ctx, SMLoc Loc, unsigned Kind) {
92
95
case SystemZ::FK_390_PC32DBL:
93
96
return ELF::R_390_PC32DBL;
94
97
}
95
- Ctx.reportError (Loc, " Unsupported PC-relative address" );
96
- return 0 ;
97
- }
98
-
99
- // Return the R_390_TLS_LE* relocation type for MCFixupKind Kind.
100
- static unsigned getTLSLEReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
101
- switch (Kind) {
102
- case FK_Data_4: return ELF::R_390_TLS_LE32;
103
- case FK_Data_8: return ELF::R_390_TLS_LE64;
104
- }
105
- Ctx.reportError (Loc, " Unsupported thread-local address (local-exec)" );
106
- return 0 ;
107
- }
108
-
109
- // Return the R_390_TLS_LDO* relocation type for MCFixupKind Kind.
110
- static unsigned getTLSLDOReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
111
- switch (Kind) {
112
- case FK_Data_4: return ELF::R_390_TLS_LDO32;
113
- case FK_Data_8: return ELF::R_390_TLS_LDO64;
114
- }
115
- Ctx.reportError (Loc, " Unsupported thread-local address (local-dynamic)" );
116
- return 0 ;
117
- }
118
-
119
- // Return the R_390_TLS_LDM* relocation type for MCFixupKind Kind.
120
- static unsigned getTLSLDMReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
121
- switch (Kind) {
122
- case FK_Data_4: return ELF::R_390_TLS_LDM32;
123
- case FK_Data_8: return ELF::R_390_TLS_LDM64;
124
- case SystemZ::FK_390_TLS_CALL: return ELF::R_390_TLS_LDCALL;
125
- }
126
- Ctx.reportError (Loc, " Unsupported thread-local address (local-dynamic)" );
127
- return 0 ;
128
- }
129
-
130
- // Return the R_390_TLS_GD* relocation type for MCFixupKind Kind.
131
- static unsigned getTLSGDReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
132
- switch (Kind) {
133
- case FK_Data_4: return ELF::R_390_TLS_GD32;
134
- case FK_Data_8: return ELF::R_390_TLS_GD64;
135
- case SystemZ::FK_390_TLS_CALL: return ELF::R_390_TLS_GDCALL;
136
- }
137
- Ctx.reportError (Loc, " Unsupported thread-local address (general-dynamic)" );
138
- return 0 ;
139
- }
140
-
141
- // Return the PLT relocation counterpart of MCFixupKind Kind.
142
- static unsigned getPLTReloc (MCContext &Ctx, SMLoc Loc, unsigned Kind) {
143
- switch (Kind) {
144
- case SystemZ::FK_390_PC12DBL: return ELF::R_390_PLT12DBL;
145
- case SystemZ::FK_390_PC16DBL: return ELF::R_390_PLT16DBL;
146
- case SystemZ::FK_390_PC24DBL: return ELF::R_390_PLT24DBL;
147
- case SystemZ::FK_390_PC32DBL: return ELF::R_390_PLT32DBL;
148
- }
149
- Ctx.reportError (Loc, " Unsupported PC-relative PLT address" );
98
+ reportError (Loc, " Unsupported PC-relative address" );
150
99
return 0 ;
151
100
}
152
101
@@ -174,41 +123,85 @@ unsigned SystemZELFObjectWriter::getRelocType(MCContext &Ctx,
174
123
switch (Specifier) {
175
124
case SystemZMCExpr::VK_None:
176
125
if (IsPCRel)
177
- return getPCRelReloc (Ctx, Loc, Kind);
178
- return getAbsoluteReloc (Ctx, Loc, Kind);
126
+ return getPCRelReloc (Loc, Kind);
127
+ return getAbsoluteReloc (Loc, Kind);
179
128
180
129
case SystemZMCExpr::VK_NTPOFF:
181
130
assert (!IsPCRel && " NTPOFF shouldn't be PC-relative" );
182
- return getTLSLEReloc (Ctx, Loc, Kind);
131
+ switch (Kind) {
132
+ case FK_Data_4:
133
+ return ELF::R_390_TLS_LE32;
134
+ case FK_Data_8:
135
+ return ELF::R_390_TLS_LE64;
136
+ }
137
+ reportError (Loc, " Unsupported thread-local address (local-exec)" );
138
+ return 0 ;
183
139
184
140
case SystemZMCExpr::VK_INDNTPOFF:
185
141
if (IsPCRel && Kind == SystemZ::FK_390_PC32DBL)
186
142
return ELF::R_390_TLS_IEENT;
187
- Ctx.reportError (Loc, " Only PC-relative INDNTPOFF accesses are supported for now" );
143
+ reportError (Loc,
144
+ " Only PC-relative INDNTPOFF accesses are supported for now" );
188
145
return 0 ;
189
146
190
147
case SystemZMCExpr::VK_DTPOFF:
191
148
assert (!IsPCRel && " DTPOFF shouldn't be PC-relative" );
192
- return getTLSLDOReloc (Ctx, Loc, Kind);
149
+ switch (Kind) {
150
+ case FK_Data_4:
151
+ return ELF::R_390_TLS_LDO32;
152
+ case FK_Data_8:
153
+ return ELF::R_390_TLS_LDO64;
154
+ }
155
+ reportError (Loc, " Unsupported thread-local address (local-dynamic)" );
156
+ return 0 ;
193
157
194
158
case SystemZMCExpr::VK_TLSLDM:
195
159
assert (!IsPCRel && " TLSLDM shouldn't be PC-relative" );
196
- return getTLSLDMReloc (Ctx, Loc, Kind);
160
+ switch (Kind) {
161
+ case FK_Data_4:
162
+ return ELF::R_390_TLS_LDM32;
163
+ case FK_Data_8:
164
+ return ELF::R_390_TLS_LDM64;
165
+ case SystemZ::FK_390_TLS_CALL:
166
+ return ELF::R_390_TLS_LDCALL;
167
+ }
168
+ reportError (Loc, " Unsupported thread-local address (local-dynamic)" );
169
+ return 0 ;
197
170
198
171
case SystemZMCExpr::VK_TLSGD:
199
172
assert (!IsPCRel && " TLSGD shouldn't be PC-relative" );
200
- return getTLSGDReloc (Ctx, Loc, Kind);
173
+ switch (Kind) {
174
+ case FK_Data_4:
175
+ return ELF::R_390_TLS_GD32;
176
+ case FK_Data_8:
177
+ return ELF::R_390_TLS_GD64;
178
+ case SystemZ::FK_390_TLS_CALL:
179
+ return ELF::R_390_TLS_GDCALL;
180
+ }
181
+ reportError (Loc, " Unsupported thread-local address (general-dynamic)" );
182
+ return 0 ;
201
183
202
184
case SystemZMCExpr::VK_GOT:
203
185
case SystemZMCExpr::VK_GOTENT:
204
186
if (IsPCRel && Kind == SystemZ::FK_390_PC32DBL)
205
187
return ELF::R_390_GOTENT;
206
- Ctx. reportError (Loc, " Only PC-relative GOT accesses are supported for now" );
188
+ reportError (Loc, " Only PC-relative GOT accesses are supported for now" );
207
189
return 0 ;
208
190
209
191
case SystemZMCExpr::VK_PLT:
210
192
assert (IsPCRel && " @PLT shouldn't be PC-relative" );
211
- return getPLTReloc (Ctx, Loc, Kind);
193
+ switch (Kind) {
194
+ case SystemZ::FK_390_PC12DBL:
195
+ return ELF::R_390_PLT12DBL;
196
+ case SystemZ::FK_390_PC16DBL:
197
+ return ELF::R_390_PLT16DBL;
198
+ case SystemZ::FK_390_PC24DBL:
199
+ return ELF::R_390_PLT24DBL;
200
+ case SystemZ::FK_390_PC32DBL:
201
+ return ELF::R_390_PLT32DBL;
202
+ }
203
+ reportError (Loc, " Unsupported PC-relative PLT address" );
204
+ return 0 ;
212
205
213
206
default :
214
207
llvm_unreachable (" Modifier not supported" );
0 commit comments