diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-01 03:50:49 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-01 03:50:49 +0000 |
commit | fd0578532417ca2ac3210d4b5b0ab05cea4d1ce1 (patch) | |
tree | 9b1346527e214253dc2f879de04d14cab5e55e31 /llvm/lib/MC/MCAsmInfo.cpp | |
parent | ca87290f367a67317f34deeef83e59fe60ee386f (diff) | |
download | bcm5719-llvm-fd0578532417ca2ac3210d4b5b0ab05cea4d1ce1.tar.gz bcm5719-llvm-fd0578532417ca2ac3210d4b5b0ab05cea4d1ce1.zip |
Simplify the handling of pcrel relocations on ELF. Now we do the right thing
for all symbol differences and can drop the old EmitPCRelSymbolValue
method.
This also make getExprForFDESymbol on ELF equal to the one on MachO, and it
can be made non-virtual.
llvm-svn: 130634
Diffstat (limited to 'llvm/lib/MC/MCAsmInfo.cpp')
-rw-r--r-- | llvm/lib/MC/MCAsmInfo.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp index b685c1a264c..541dd080acc 100644 --- a/llvm/lib/MC/MCAsmInfo.cpp +++ b/llvm/lib/MC/MCAsmInfo.cpp @@ -13,9 +13,11 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/Dwarf.h" #include <cctype> #include <cstring> using namespace llvm; @@ -111,12 +113,22 @@ unsigned MCAsmInfo::getSLEB128Size(int Value) { const MCExpr * MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const { - return getExprForFDESymbol(Sym, Streamer); + return getExprForFDESymbol(Sym, Encoding, Streamer); } const MCExpr * MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const { - return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); + if (!(Encoding & dwarf::DW_EH_PE_pcrel)) + return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); + + MCContext &Context = Streamer.getContext(); + const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); + MCSymbol *PCSym = Context.CreateTempSymbol(); + Streamer.EmitLabel(PCSym); + const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context); + return MCBinaryExpr::CreateSub(Res, PC, Context); } |