Index: include/llvm/MC/MCELFStreamer.h =================================================================== --- include/llvm/MC/MCELFStreamer.h +++ include/llvm/MC/MCELFStreamer.h @@ -67,8 +67,8 @@ uint64_t Size = 0, unsigned ByteAlignment = 0) override; void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment = 0) override; - void EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc = SMLoc()) override; + void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc(), + bool IsPCRelative = false) override; void EmitFileDirective(StringRef Filename) override; Index: include/llvm/MC/MCObjectStreamer.h =================================================================== --- include/llvm/MC/MCObjectStreamer.h +++ include/llvm/MC/MCObjectStreamer.h @@ -91,8 +91,8 @@ void EmitLabel(MCSymbol *Symbol) override; void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; - void EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc = SMLoc()) override; + void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc(), + bool IsPCRelative = false) override; void EmitULEB128Value(const MCExpr *Value) override; void EmitSLEB128Value(const MCExpr *Value) override; void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override; Index: include/llvm/MC/MCStreamer.h =================================================================== --- include/llvm/MC/MCStreamer.h +++ include/llvm/MC/MCStreamer.h @@ -521,10 +521,12 @@ /// \param Size - The size of the integer (in bytes) to emit. This must /// match a native machine width. /// \param Loc - The location of the expression for error reporting. + /// \param IsPCRelative - It tells whether the value is PC relative or not. virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc = SMLoc()); + SMLoc Loc = SMLoc(), bool IsPCRelative = false); - void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc()); + void EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc(), + bool IsPCRelative = false); /// \brief Special case of EmitValue that avoids the client having /// to pass in a MCExpr for constant integers. Index: lib/MC/MCAsmStreamer.cpp =================================================================== --- lib/MC/MCAsmStreamer.cpp +++ lib/MC/MCAsmStreamer.cpp @@ -164,8 +164,8 @@ void EmitBytes(StringRef Data) override; - void EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc = SMLoc()) override; + void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc(), + bool IsPCRelative = false) override; void EmitIntValue(uint64_t Value, unsigned Size) override; void EmitULEB128Value(const MCExpr *Value) override; @@ -688,8 +688,8 @@ EmitValue(MCConstantExpr::create(Value, getContext()), Size); } -void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc) { +void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc, + bool IsPCRelative) { assert(Size <= 8 && "Invalid size"); assert(getCurrentSection().first && "Cannot emit contents before setting section!"); Index: lib/MC/MCELFStreamer.cpp =================================================================== --- lib/MC/MCELFStreamer.cpp +++ lib/MC/MCELFStreamer.cpp @@ -339,12 +339,12 @@ EmitCommonSymbol(Symbol, Size, ByteAlignment); } -void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc) { +void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc, + bool IsPCRelative) { if (isBundleLocked()) report_fatal_error("Emitting values inside a locked bundle is forbidden"); fixSymbolsInTLSFixups(Value); - MCObjectStreamer::EmitValueImpl(Value, Size, Loc); + MCObjectStreamer::EmitValueImpl(Value, Size, Loc, IsPCRelative); } void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment, Index: lib/MC/MCObjectStreamer.cpp =================================================================== --- lib/MC/MCObjectStreamer.cpp +++ lib/MC/MCObjectStreamer.cpp @@ -122,7 +122,7 @@ } void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc) { + SMLoc Loc, bool IsPCRelative) { MCStreamer::EmitValueImpl(Value, Size, Loc); MCDataFragment *DF = getOrCreateDataFragment(); flushPendingLabels(DF, DF->getContents().size()); @@ -137,7 +137,7 @@ } DF->getFixups().push_back( MCFixup::create(DF->getContents().size(), Value, - MCFixup::getKindForSize(Size, false), Loc)); + MCFixup::getKindForSize(Size, IsPCRelative), Loc)); DF->getContents().resize(DF->getContents().size() + Size, 0); } Index: lib/MC/MCStreamer.cpp =================================================================== --- lib/MC/MCStreamer.cpp +++ lib/MC/MCStreamer.cpp @@ -107,8 +107,9 @@ EmitBytes(OSE.str()); } -void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc) { - EmitValueImpl(Value, Size, Loc); +void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, SMLoc Loc, + bool IsPCRelative) { + EmitValueImpl(Value, Size, Loc, IsPCRelative); } void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, @@ -687,7 +688,8 @@ void MCStreamer::ChangeSection(MCSection *, const MCExpr *) {} void MCStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {} void MCStreamer::EmitBytes(StringRef Data) {} -void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) { +void MCStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc, + bool IsPCRelative) { visitUsedExpr(*Value); } void MCStreamer::EmitULEB128Value(const MCExpr *Value) {} Index: lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp =================================================================== --- lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp +++ lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp @@ -128,9 +128,10 @@ /// This is one of the functions used to emit data into an ELF section, so the /// AArch64 streamer overrides it to add the appropriate mapping symbol ($d) /// if necessary. - void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override { + void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc(), + bool IsPCRelative = false) override { EmitDataMappingSymbol(); - MCELFStreamer::EmitValueImpl(Value, Size, Loc); + MCELFStreamer::EmitValueImpl(Value, Size, Loc, IsPCRelative); } private: Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -507,7 +507,8 @@ /// This is one of the functions used to emit data into an ELF section, so the /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if /// necessary. - void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override { + void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc = SMLoc(), + bool IsPCRelative = false) override { if (const MCSymbolRefExpr *SRE = dyn_cast_or_null(Value)) if (SRE->getKind() == MCSymbolRefExpr::VK_ARM_SBREL && !(Size == 4)) { getContext().reportError(Loc, "relocated expression must be 32-bit"); @@ -515,7 +516,7 @@ } EmitDataMappingSymbol(); - MCELFStreamer::EmitValueImpl(Value, Size, Loc); + MCELFStreamer::EmitValueImpl(Value, Size, Loc, IsPCRelative); } void EmitAssemblerFlag(MCAssemblerFlag Flag) override { Index: lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h +++ lib/Target/Mips/MCTargetDesc/MipsELFStreamer.h @@ -60,7 +60,8 @@ /// Overriding this function allows us to dismiss all labels that are /// candidates for marking as microMIPS when .word directive is emitted. - void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override; + void EmitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc, + bool IsPCRelative = false) override; /// Emits all the option records stored up until the point it's called. void EmitMipsOptionRecords(); Index: lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp +++ lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp @@ -63,8 +63,8 @@ } void MipsELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - SMLoc Loc) { - MCELFStreamer::EmitValueImpl(Value, Size, Loc); + SMLoc Loc, bool IsPCRelative) { + MCELFStreamer::EmitValueImpl(Value, Size, Loc, IsPCRelative); Labels.clear(); }