diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-20 02:12:01 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-20 02:12:01 +0000 |
commit | 0a70f9b3b9b4a8cb92f187ea0563c1a2ac784e6e (patch) | |
tree | 604d2275b5eaa7fcf7ab29930dec3b9d1d1027ca /lib/MC/MCELFStreamer.cpp | |
parent | 5a8743ef85343b8399810a5b82db7ac4c6a7548c (diff) | |
download | llvm-0a70f9b3b9b4a8cb92f187ea0563c1a2ac784e6e.tar.gz llvm-0a70f9b3b9b4a8cb92f187ea0563c1a2ac784e6e.tar.bz2 llvm-0a70f9b3b9b4a8cb92f187ea0563c1a2ac784e6e.tar.xz |
Look through variables when computing relocations.
Given
bar = foo + 4
.long bar
MC would eat the 4. GNU as includes it in the relocation. The rule seems to be
that a variable that defines a symbol is used in the relocation and one that
does not define a symbol is evaluated and the result included in the relocation.
Fixing this unfortunately required some other changes:
* Since the variable is now evaluated, it would prevent the ELF writer from
noticing the weakref marker the elf streamer uses. This patch then replaces
that with a VariantKind in MCSymbolRefExpr.
* Using VariantKind then requires us to look past other VariantKind to see
.weakref bar,foo
call bar@PLT
doing this also fixes
zed = foo +2
call zed@PLT
so that is a good thing.
* Looking past VariantKind means that the relocation selection has to use
the fixup instead of the target.
This is a reboot of the previous fixes for MC. I will watch the sanitizer
buildbot and wait for a build before adding back the previous fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCELFStreamer.cpp')
-rw-r--r-- | lib/MC/MCELFStreamer.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp index 5f6a889769..d07ef9e698 100644 --- a/lib/MC/MCELFStreamer.cpp +++ b/lib/MC/MCELFStreamer.cpp @@ -99,9 +99,8 @@ void MCELFStreamer::ChangeSection(const MCSection *Section, void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) { getAssembler().getOrCreateSymbolData(*Symbol); - MCSymbolData &AliasSD = getAssembler().getOrCreateSymbolData(*Alias); - AliasSD.setFlags(AliasSD.getFlags() | ELF_Other_Weakref); - const MCExpr *Value = MCSymbolRefExpr::Create(Symbol, getContext()); + const MCExpr *Value = MCSymbolRefExpr::Create( + Symbol, MCSymbolRefExpr::VK_WEAKREF, getContext()); Alias->setVariableValue(Value); } |