@@ -91,10 +91,7 @@ const MCFixup *RISCVMCExpr::getPCRelHiFixup(const MCFragment **DFOut) const {
9191bool RISCVMCExpr::evaluateAsRelocatableImpl (MCValue &Res,
9292 const MCAssembler *Asm,
9393 const MCFixup *Fixup) const {
94- // Explicitly drop the layout and assembler to prevent any symbolic folding in
95- // the expression handling. This is required to preserve symbolic difference
96- // expressions to emit the paired relocations.
97- if (!getSubExpr ()->evaluateAsRelocatable (Res, nullptr , nullptr ))
94+ if (!getSubExpr ()->evaluateAsRelocatable (Res, Asm, Fixup))
9895 return false ;
9996
10097 Res =
@@ -169,49 +166,6 @@ StringRef RISCVMCExpr::getVariantKindName(VariantKind Kind) {
169166 llvm_unreachable (" Invalid ELF symbol kind" );
170167}
171168
172- static void fixELFSymbolsInTLSFixupsImpl (const MCExpr *Expr, MCAssembler &Asm) {
173- switch (Expr->getKind ()) {
174- case MCExpr::Target:
175- llvm_unreachable (" Can't handle nested target expression" );
176- break ;
177- case MCExpr::Constant:
178- break ;
179-
180- case MCExpr::Binary: {
181- const MCBinaryExpr *BE = cast<MCBinaryExpr>(Expr);
182- fixELFSymbolsInTLSFixupsImpl (BE->getLHS (), Asm);
183- fixELFSymbolsInTLSFixupsImpl (BE->getRHS (), Asm);
184- break ;
185- }
186-
187- case MCExpr::SymbolRef: {
188- // We're known to be under a TLS fixup, so any symbol should be
189- // modified. There should be only one.
190- const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
191- cast<MCSymbolELF>(SymRef.getSymbol ()).setType (ELF::STT_TLS);
192- break ;
193- }
194-
195- case MCExpr::Unary:
196- fixELFSymbolsInTLSFixupsImpl (cast<MCUnaryExpr>(Expr)->getSubExpr (), Asm);
197- break ;
198- }
199- }
200-
201- void RISCVMCExpr::fixELFSymbolsInTLSFixups (MCAssembler &Asm) const {
202- switch (getKind ()) {
203- default :
204- return ;
205- case VK_RISCV_TPREL_HI:
206- case VK_RISCV_TLS_GOT_HI:
207- case VK_RISCV_TLS_GD_HI:
208- case VK_RISCV_TLSDESC_HI:
209- break ;
210- }
211-
212- fixELFSymbolsInTLSFixupsImpl (getSubExpr (), Asm);
213- }
214-
215169bool RISCVMCExpr::evaluateAsConstant (int64_t &Res) const {
216170 MCValue Value;
217171 if (Kind != VK_RISCV_LO && Kind != VK_RISCV_HI)
0 commit comments