diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2017-02-02 21:26:06 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2017-02-02 21:26:06 +0000 |
commit | 13a79bbfe583e1d8cc85d241b580907260065eb8 (patch) | |
tree | 538d692317f9990cae5ae6bb23bc23fd3c5803ef /llvm/lib/MC/MCSymbolELF.cpp | |
parent | bb8dcc6aec4071c114ed4205f01c9163dbd1bf00 (diff) | |
download | bcm5719-llvm-13a79bbfe583e1d8cc85d241b580907260065eb8.tar.gz bcm5719-llvm-13a79bbfe583e1d8cc85d241b580907260065eb8.zip |
Change how we handle section symbols on ELF.
On ELF every section can have a corresponding section symbol. When in
an assembly file we have
.quad .text
the '.text' refers to that symbol.
The way we used to handle them is to leave .text an undefined symbol
until the very end when the object writer would map them to the
actual section symbol.
The problem with that is that anything before the end would see an
undefined symbol. This could result in bad diagnostics
(test/MC/AArch64/label-arithmetic-diags-elf.s), or incorrect results
when using the asm streamer (est/MC/Mips/expansion-jal-sym-pic.s).
Fixing this will also allow using the section symbol earlier for
setting sh_link of SHF_METADATA sections.
This patch includes a few hacks to avoid changing our behaviour when
handling conflicts between section symbols and other symbols. I
reported pr31850 to track that.
llvm-svn: 293936
Diffstat (limited to 'llvm/lib/MC/MCSymbolELF.cpp')
-rw-r--r-- | llvm/lib/MC/MCSymbolELF.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCSymbolELF.cpp b/llvm/lib/MC/MCSymbolELF.cpp index ec7ef447ff8..ffa8260d434 100644 --- a/llvm/lib/MC/MCSymbolELF.cpp +++ b/llvm/lib/MC/MCSymbolELF.cpp @@ -42,6 +42,8 @@ enum { void MCSymbolELF::setBinding(unsigned Binding) const { setIsBindingSet(); + if (getType() == ELF::STT_SECTION && Binding != ELF::STB_LOCAL) + setType(ELF::STT_NOTYPE); unsigned Val; switch (Binding) { default: @@ -93,6 +95,8 @@ unsigned MCSymbolELF::getBinding() const { void MCSymbolELF::setType(unsigned Type) const { unsigned Val; + if (Type == ELF::STT_SECTION && getBinding() != ELF::STB_LOCAL) + return; switch (Type) { default: llvm_unreachable("Unsupported Binding"); |