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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219829 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-10-15 18:55:30 +00:00
parent 1338612c55
commit ad04f5db82
8 changed files with 160 additions and 52 deletions

View File

@@ -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;