[Mips] Write .reginfo section into the separate PT_MIPS_REGINFO segment

llvm-svn: 235391
This commit is contained in:
Simon Atanasyan 2015-04-21 17:02:35 +00:00
parent d64f8a5188
commit fcb19e19d0
4 changed files with 34 additions and 3 deletions

View File

@ -26,7 +26,7 @@ public:
const MipsReginfo &reginfo) const MipsReginfo &reginfo)
: Section<ELFT>(ctx, ".reginfo", "MipsReginfo"), : Section<ELFT>(ctx, ".reginfo", "MipsReginfo"),
_targetLayout(targetLayout) { _targetLayout(targetLayout) {
this->setOrder(MipsTargetLayout<ELFT>::ORDER_RO_NOTE); this->setOrder(MipsTargetLayout<ELFT>::ORDER_MIPS_REGINFO);
this->_entSize = sizeof(Elf_RegInfo); this->_entSize = sizeof(Elf_RegInfo);
this->_fsize = sizeof(Elf_RegInfo); this->_fsize = sizeof(Elf_RegInfo);
this->_msize = sizeof(Elf_RegInfo); this->_msize = sizeof(Elf_RegInfo);
@ -42,6 +42,10 @@ public:
_reginfo.ri_cprmask[3] = reginfo._cpRegMask[3]; _reginfo.ri_cprmask[3] = reginfo._cpRegMask[3];
} }
StringRef segmentKindToStr() const override { return "REGINFO"; }
bool hasOutputSegment() const override { return true; }
void write(ELFWriter *writer, TargetLayout<ELFT> &layout, void write(ELFWriter *writer, TargetLayout<ELFT> &layout,
llvm::FileOutputBuffer &buffer) override { llvm::FileOutputBuffer &buffer) override {
uint8_t *dest = buffer.getBufferStart() + this->fileOffset(); uint8_t *dest = buffer.getBufferStart() + this->fileOffset();

View File

@ -20,6 +20,10 @@ class MipsLinkingContext;
/// \brief TargetLayout for Mips /// \brief TargetLayout for Mips
template <class ELFT> class MipsTargetLayout final : public TargetLayout<ELFT> { template <class ELFT> class MipsTargetLayout final : public TargetLayout<ELFT> {
public: public:
enum MipsSectionOrder {
ORDER_MIPS_REGINFO = TargetLayout<ELFT>::ORDER_RO_NOTE + 1
};
MipsTargetLayout(MipsLinkingContext &ctx) MipsTargetLayout(MipsLinkingContext &ctx)
: TargetLayout<ELFT>(ctx), : TargetLayout<ELFT>(ctx),
_gotSection(new (this->_allocator) MipsGOTSection<ELFT>(ctx)), _gotSection(new (this->_allocator) MipsGOTSection<ELFT>(ctx)),
@ -39,6 +43,16 @@ public:
return TargetLayout<ELFT>::createSection(name, type, permissions, order); return TargetLayout<ELFT>::createSection(name, type, permissions, order);
} }
typename TargetLayout<ELFT>::SegmentType
getSegmentType(Section<ELFT> *section) const override {
switch (section->order()) {
case ORDER_MIPS_REGINFO:
return llvm::ELF::PT_MIPS_REGINFO;
default:
return TargetLayout<ELFT>::getSegmentType(section);
}
}
/// \brief GP offset relative to .got section. /// \brief GP offset relative to .got section.
uint64_t getGPOffset() const { return 0x7FF0; } uint64_t getGPOffset() const { return 0x7FF0; }

View File

@ -73,7 +73,7 @@ public:
/// \brief convert the segment type to a String for diagnostics and printing /// \brief convert the segment type to a String for diagnostics and printing
/// purposes /// purposes
StringRef segmentKindToStr() const; virtual StringRef segmentKindToStr() const;
/// \brief Records the segmentType, that this section belongs to /// \brief Records the segmentType, that this section belongs to
void void

View File

@ -3,7 +3,7 @@
# RUN: yaml2obj -format=elf -docnum 1 %s > %t1.o # RUN: yaml2obj -format=elf -docnum 1 %s > %t1.o
# RUN: yaml2obj -format=elf -docnum 2 %s > %t2.o # RUN: yaml2obj -format=elf -docnum 2 %s > %t2.o
# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t1.o %t2.o # RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t1.o %t2.o
# RUN: llvm-readobj -s %t.so | FileCheck -check-prefix=SEC %s # RUN: llvm-readobj -program-headers -s %t.so | FileCheck -check-prefix=SEC %s
# RUN: llvm-objdump -s -t %t.so | FileCheck -check-prefix=RAW %s # RUN: llvm-objdump -s -t %t.so | FileCheck -check-prefix=RAW %s
# SEC: Index: 1 # SEC: Index: 1
@ -20,6 +20,19 @@
# SEC-NEXT: AddressAlignment: 4 # SEC-NEXT: AddressAlignment: 4
# SEC-NEXT: EntrySize: 24 # SEC-NEXT: EntrySize: 24
# SEC: ProgramHeader {
# SEC: Type: PT_MIPS_REGINFO (0x70000000)
# SEC-NEXT: Offset: 0x{{[0-9A-F]+}}
# SEC-NEXT: VirtualAddress: 0x{{[0-9A-F]+}}
# SEC-NEXT: PhysicalAddress: 0x{{[0-9A-F]+}}
# SEC-NEXT: FileSize: 24
# SEC-NEXT: MemSize: 24
# SEC-NEXT: Flags [ (0x4)
# SEC-NEXT: PF_R (0x4)
# SEC-NEXT: ]
# SEC-NEXT: Alignment: 4
# SEC-NEXT: }
# RAW: Contents of section .reginfo: # RAW: Contents of section .reginfo:
# RAW-NEXT: {{[0-9a-f]+}} f0000001 e0000002 d0000003 c0000004 # RAW-NEXT: {{[0-9a-f]+}} f0000001 e0000002 d0000003 c0000004
# RAW-NEXT: {{[0-9a-f]+}} b0000005 f08f0000 # RAW-NEXT: {{[0-9a-f]+}} b0000005 f08f0000