[lld] r235391 - [Mips] Write .reginfo section into the separate PT_MIPS_REGINFO segment
Simon Atanasyan
simon at atanasyan.com
Tue Apr 21 10:02:35 PDT 2015
Author: atanasyan
Date: Tue Apr 21 12:02:35 2015
New Revision: 235391
URL: http://llvm.org/viewvc/llvm-project?rev=235391&view=rev
Log:
[Mips] Write .reginfo section into the separate PT_MIPS_REGINFO segment
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
lld/trunk/test/elf/Mips/reginfo-02.test
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h?rev=235391&r1=235390&r2=235391&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h Tue Apr 21 12:02:35 2015
@@ -26,7 +26,7 @@ public:
const MipsReginfo ®info)
: Section<ELFT>(ctx, ".reginfo", "MipsReginfo"),
_targetLayout(targetLayout) {
- this->setOrder(MipsTargetLayout<ELFT>::ORDER_RO_NOTE);
+ this->setOrder(MipsTargetLayout<ELFT>::ORDER_MIPS_REGINFO);
this->_entSize = sizeof(Elf_RegInfo);
this->_fsize = sizeof(Elf_RegInfo);
this->_msize = sizeof(Elf_RegInfo);
@@ -42,6 +42,10 @@ public:
_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,
llvm::FileOutputBuffer &buffer) override {
uint8_t *dest = buffer.getBufferStart() + this->fileOffset();
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h?rev=235391&r1=235390&r2=235391&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h Tue Apr 21 12:02:35 2015
@@ -20,6 +20,10 @@ class MipsLinkingContext;
/// \brief TargetLayout for Mips
template <class ELFT> class MipsTargetLayout final : public TargetLayout<ELFT> {
public:
+ enum MipsSectionOrder {
+ ORDER_MIPS_REGINFO = TargetLayout<ELFT>::ORDER_RO_NOTE + 1
+ };
+
MipsTargetLayout(MipsLinkingContext &ctx)
: TargetLayout<ELFT>(ctx),
_gotSection(new (this->_allocator) MipsGOTSection<ELFT>(ctx)),
@@ -39,6 +43,16 @@ public:
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.
uint64_t getGPOffset() const { return 0x7FF0; }
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=235391&r1=235390&r2=235391&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Tue Apr 21 12:02:35 2015
@@ -73,7 +73,7 @@ public:
/// \brief convert the segment type to a String for diagnostics and printing
/// purposes
- StringRef segmentKindToStr() const;
+ virtual StringRef segmentKindToStr() const;
/// \brief Records the segmentType, that this section belongs to
void
Modified: lld/trunk/test/elf/Mips/reginfo-02.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/reginfo-02.test?rev=235391&r1=235390&r2=235391&view=diff
==============================================================================
--- lld/trunk/test/elf/Mips/reginfo-02.test (original)
+++ lld/trunk/test/elf/Mips/reginfo-02.test Tue Apr 21 12:02:35 2015
@@ -3,7 +3,7 @@
# RUN: yaml2obj -format=elf -docnum 1 %s > %t1.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: 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
# SEC: Index: 1
@@ -20,6 +20,19 @@
# SEC-NEXT: AddressAlignment: 4
# 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-NEXT: {{[0-9a-f]+}} f0000001 e0000002 d0000003 c0000004
# RAW-NEXT: {{[0-9a-f]+}} b0000005 f08f0000
More information about the llvm-commits
mailing list