diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-15 18:55:30 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-15 18:55:30 +0000 |
commit | a74b5e682361e336f56cc3fdbeb05c8183c089e1 (patch) | |
tree | 11e01d2e892ddc6be7638d29e6d4cf28da48edfa /llvm/lib/MC/MCContext.cpp | |
parent | b0c5b8f22879ad8445962d60b3d479b10b4d9d56 (diff) | |
download | bcm5719-llvm-a74b5e682361e336f56cc3fdbeb05c8183c089e1.tar.gz bcm5719-llvm-a74b5e682361e336f56cc3fdbeb05c8183c089e1.zip |
Correctly handle references to section symbols.
When processing assembly like
.long .text
we were creating a new undefined symbol .text. GAS on the other hand would
handle that as a reference to the .text section.
This patch implements that by creating the section symbols earlier so that
they are visible during asm parsing.
The patch also updates llvm-readobj to print the symbol number in the relocation
dump so that the test can differentiate between two sections with the same name.
llvm-svn: 219829
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 9d8a57e55f6..3ac8d658873 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -113,6 +113,23 @@ MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) { return Sym; } +MCSymbol *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) { + MCSymbol *&Sym = SectionSymbols[&Section]; + if (Sym) + return Sym; + + StringRef Name = Section.getSectionName(); + StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name); + NameEntry->setValue(true); + Sym = new (*this) MCSymbol(NameEntry->getKey(), /*isTemporary*/ false); + + StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name); + if (!Entry.getValue()) + Entry.setValue(Sym); + + return Sym; +} + MCSymbol *MCContext::CreateSymbol(StringRef Name) { // Determine whether this is an assembler temporary or normal label, if used. bool isTemporary = false; |