summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-04-20 12:44:06 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-04-20 12:44:06 +0000
commit29c8270916547beeec7c3ba94fd58118a771b29a (patch)
tree6e241b0fd8cfec9879de9ee28490f2c2a56e8e86
parentffa272ebbb7217c846ac2a92ff3f04be382ae854 (diff)
downloadbcm5719-llvm-29c8270916547beeec7c3ba94fd58118a771b29a.tar.gz
bcm5719-llvm-29c8270916547beeec7c3ba94fd58118a771b29a.zip
Look past locals in comdats.
We have to avoid converting a reference to a global into a reference to a local, but it is fine to look past a local. Patch by Vasileios Kalintiris. I just moved the comment and added thet test. llvm-svn: 235300
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp17
-rw-r--r--llvm/test/MC/ELF/relocation.s2
2 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 1646fe59ce4..2dd5afcb40e 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1683,22 +1683,21 @@ bool ELFObjectWriter::isWeak(const MCSymbolData &SD) const {
if (::isWeak(SD))
return true;
- const MCSymbol &Sym = SD.getSymbol();
- if (!Sym.isInSection())
- return false;
-
- const auto &Sec = cast<MCSectionELF>(Sym.getSection());
- if (!Sec.getGroup())
- return false;
-
// It is invalid to replace a reference to a global in a comdat
// with a reference to a local since out of comdat references
// to a local are forbidden.
// We could try to return false for more cases, like the reference
// being in the same comdat or Sym being an alias to another global,
// but it is not clear if it is worth the effort.
- return true;
+ if (MCELF::GetBinding(SD) != ELF::STB_GLOBAL)
+ return false;
+ const MCSymbol &Sym = SD.getSymbol();
+ if (!Sym.isInSection())
+ return false;
+
+ const auto &Sec = cast<MCSectionELF>(Sym.getSection());
+ return Sec.getGroup();
}
MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW,
diff --git a/llvm/test/MC/ELF/relocation.s b/llvm/test/MC/ELF/relocation.s
index cd0cc45fc00..2841612f2e1 100644
--- a/llvm/test/MC/ELF/relocation.s
+++ b/llvm/test/MC/ELF/relocation.s
@@ -7,6 +7,7 @@
.globl pr23272
pr23272:
pr23272_2:
+pr23272_3 = pr23272_2
.text
bar:
@@ -52,6 +53,7 @@ bar:
.long foo@plt
.quad pr23272_2 - pr23272
+ .quad pr23272_3 - pr23272
// CHECK: Section {
// CHECK: Name: .rela.text
// CHECK: Relocations [
OpenPOWER on IntegriCloud