From 6668eb3c40b267b4fd58e1fa7bfe88d8da25ea8f Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Wed, 22 Apr 2015 08:09:38 +0000 Subject: [PATCH] [Mips] Assign .MIPS.options section to the PT_LOAD segment llvm-svn: 235488 --- lld/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h | 4 +++- lld/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h | 5 ++++- lld/test/elf/Mips/mips-options-02.test | 1 - lld/test/elf/Mips/mips-options-gp0.test | 6 +++--- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h b/lld/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h index 9d30407..3b51345 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h @@ -76,7 +76,7 @@ public: const MipsReginfo ®info) : Section(ctx, ".MIPS.options", "MipsOptions"), _targetLayout(targetLayout) { - this->setOrder(MipsTargetLayout::ORDER_RO_NOTE); + this->setOrder(MipsTargetLayout::ORDER_MIPS_OPTIONS); this->_entSize = 1; this->_alignment = 8; this->_fsize = llvm::RoundUpToAlignment( @@ -98,6 +98,8 @@ public: _reginfo.ri_cprmask[3] = reginfo._cpRegMask[3]; } + bool hasOutputSegment() const override { return true; } + void write(ELFWriter *writer, TargetLayout &layout, llvm::FileOutputBuffer &buffer) override { uint8_t *dest = buffer.getBufferStart() + this->fileOffset(); diff --git a/lld/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h b/lld/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h index 36e74c2..735b98f 100644 --- a/lld/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h +++ b/lld/lib/ReaderWriter/ELF/Mips/MipsTargetLayout.h @@ -21,7 +21,8 @@ class MipsLinkingContext; template class MipsTargetLayout final : public TargetLayout { public: enum MipsSectionOrder { - ORDER_MIPS_REGINFO = TargetLayout::ORDER_RO_NOTE + 1 + ORDER_MIPS_REGINFO = TargetLayout::ORDER_RO_NOTE + 1, + ORDER_MIPS_OPTIONS }; MipsTargetLayout(MipsLinkingContext &ctx) @@ -48,6 +49,8 @@ public: switch (section->order()) { case ORDER_MIPS_REGINFO: return llvm::ELF::PT_MIPS_REGINFO; + case ORDER_MIPS_OPTIONS: + return llvm::ELF::PT_LOAD; default: return TargetLayout::getSegmentType(section); } diff --git a/lld/test/elf/Mips/mips-options-02.test b/lld/test/elf/Mips/mips-options-02.test index 8aa6e6e..bb01952d 100644 --- a/lld/test/elf/Mips/mips-options-02.test +++ b/lld/test/elf/Mips/mips-options-02.test @@ -39,7 +39,6 @@ # PHDR: Type: PT_LOAD # PHDR-NOT: Type: PT_LOAD # PHDR: Type: PT_DYNAMIC -# PHDR: Type: PT_NOTE # t1.o --- diff --git a/lld/test/elf/Mips/mips-options-gp0.test b/lld/test/elf/Mips/mips-options-gp0.test index c512393..905b184 100644 --- a/lld/test/elf/Mips/mips-options-gp0.test +++ b/lld/test/elf/Mips/mips-options-gp0.test @@ -6,7 +6,7 @@ # RUN: llvm-objdump -s %t.so | FileCheck -check-prefix=SEC %s # SYM: Name: L1 -# SYM-NEXT: Value: 0x194 +# SYM-NEXT: Value: 0x15C # SYM-NEXT: Size: 4 # SYM-NEXT: Binding: Local (0x0) # SYM-NEXT: Type: Function (0x2) @@ -21,9 +21,9 @@ # SYM-NEXT: Other: 0 # SYM-NEXT: Section: Absolute (0xFFF1) -# 0xffff81a4 == 0x0 (addend) + 0x0194 (L1) + 0x1000 (GP0) - 0x8ff0 (_gp) +# 0xffff816c == 0x0 (addend) + 0x015C (L1) + 0x1000 (GP0) - 0x8ff0 (_gp) # SEC: Contents of section .rodata: -# SEC-NEXT: {{[0-9a-f]+}} a481ffff 00000000 00000000 00000000 +# SEC-NEXT: {{[0-9a-f]+}} 6c81ffff 00000000 00000000 00000000 !ELF FileHeader: -- 2.7.4