[ELF][MIPS] MIPS .reginfo sections handling

MIPS .reginfo section provides information on the registers used by
the code in the object file. Linker should collect this information and
write .reginfo section in the output file. This section contains a union
of used registers masks taken from input .reginfo sections and final
value of the `_gp` symbol.

For details see the "Register Information" section in Chapter 4 in the
following document:
ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf

The patch implements .reginfo sections handling with a couple missed
features: a) it does not put output .reginfo section into the separate
REGINFO segment; b) it does not merge `ri_cprmask` masks from input
section. These features will be implemented later.

Differential Revision: http://reviews.llvm.org/D15669

llvm-svn: 256119
This commit is contained in:
Simon Atanasyan
2015-12-20 10:57:34 +00:00
parent e85abf7269
commit 1d7df40711
8 changed files with 125 additions and 2 deletions

View File

@@ -75,6 +75,7 @@ private:
SpecificBumpPtrAllocator<OutputSection<ELFT>> SecAlloc;
SpecificBumpPtrAllocator<MergeOutputSection<ELFT>> MSecAlloc;
SpecificBumpPtrAllocator<EHOutputSection<ELFT>> EHSecAlloc;
SpecificBumpPtrAllocator<MipsReginfoOutputSection<ELFT>> MReginfoSecAlloc;
BumpPtrAllocator Alloc;
std::vector<OutputSectionBase<ELFT> *> OutputSections;
unsigned getNumSections() const { return OutputSections.size() + 1; }
@@ -618,6 +619,10 @@ template <class ELFT> void Writer<ELFT>::createSections() {
Sec = new (MSecAlloc.Allocate())
MergeOutputSection<ELFT>(Key.Name, Key.Type, Key.Flags);
break;
case InputSectionBase<ELFT>::MipsReginfo:
Sec = new (MReginfoSecAlloc.Allocate())
MipsReginfoOutputSection<ELFT>();
break;
}
OutputSections.push_back(Sec);
RegularSections.push_back(Sec);
@@ -635,6 +640,10 @@ template <class ELFT> void Writer<ELFT>::createSections() {
static_cast<MergeOutputSection<ELFT> *>(Sec)
->addSection(cast<MergeInputSection<ELFT>>(C));
break;
case InputSectionBase<ELFT>::MipsReginfo:
static_cast<MipsReginfoOutputSection<ELFT> *>(Sec)
->addSection(cast<MipsReginfoInputSection<ELFT>>(C));
break;
}
}
}