diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-02-02 21:44:01 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-02-02 21:44:01 +0000 |
| commit | 255a8c8b13b1ed83f1a45e1ca37927dfc1752390 (patch) | |
| tree | 050b25d735fe1fb1942f92707732cf94fbc6d291 | |
| parent | c83cfb9dfa2f1ebab5bdc5c26642ada78b8b0ea7 (diff) | |
| download | bcm5719-llvm-255a8c8b13b1ed83f1a45e1ca37927dfc1752390.tar.gz bcm5719-llvm-255a8c8b13b1ed83f1a45e1ca37927dfc1752390.zip | |
MC/Mach-O: Set SOME_INSTRUCTIONS bit for sections.
llvm-svn: 95135
| -rw-r--r-- | llvm/include/llvm/MC/MCAssembler.h | 9 | ||||
| -rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 9 | ||||
| -rw-r--r-- | llvm/lib/MC/MCMachOStreamer.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/MC/MachO/section-flags.s | 14 |
4 files changed, 31 insertions, 5 deletions
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h index be017bf0e4c..55696b08fd6 100644 --- a/llvm/include/llvm/MC/MCAssembler.h +++ b/llvm/include/llvm/MC/MCAssembler.h @@ -348,7 +348,11 @@ private: /// Fixups - The list of fixups in this section. std::vector<Fixup> Fixups; - + + /// HasInstructions - Whether this section has had instructions emitted into + /// it. + unsigned HasInstructions : 1; + /// @} public: @@ -429,6 +433,9 @@ public: } void setFileSize(uint64_t Value) { FileSize = Value; } + bool hasInstructions() const { return HasInstructions; } + void setHasInstructions(bool Value) { HasInstructions = Value; } + /// @} }; diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 08943ebd93e..c471a02eb78 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -266,11 +266,15 @@ public: Write32(SD.getSize()); // size Write32(FileOffset); + unsigned Flags = Section.getTypeAndAttributes(); + if (SD.hasInstructions()) + Flags |= MCSectionMachO::S_ATTR_SOME_INSTRUCTIONS; + assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!"); Write32(Log2_32(SD.getAlignment())); Write32(NumRelocations ? RelocationsStart : 0); Write32(NumRelocations); - Write32(Section.getTypeAndAttributes()); + Write32(Flags); Write32(0); // reserved1 Write32(Section.getStubSize()); // reserved2 @@ -901,7 +905,8 @@ MCSectionData::MCSectionData(const MCSection &_Section, MCAssembler *A) Address(~UINT64_C(0)), Size(~UINT64_C(0)), FileSize(~UINT64_C(0)), - LastFixupLookup(~0) + LastFixupLookup(~0), + HasInstructions(false) { if (A) A->getSectionList().push_back(this); diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index 143793cde10..981eb72d14c 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -362,8 +362,8 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { if (!Emitter) llvm_unreachable("no code emitter available!"); - // FIXME: Emitting an instruction should cause S_ATTR_SOME_INSTRUCTIONS to - // be set for the current section. + CurSectionData->setHasInstructions(true); + // FIXME: Relocations! SmallString<256> Code; raw_svector_ostream VecOS(Code); diff --git a/llvm/test/MC/MachO/section-flags.s b/llvm/test/MC/MachO/section-flags.s new file mode 100644 index 00000000000..8ac1bbff755 --- /dev/null +++ b/llvm/test/MC/MachO/section-flags.s @@ -0,0 +1,14 @@ +// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump | FileCheck %s +// +// CHECK: # Section 0 +// CHECK: 'section_name', '__text +// CHECK: 'flags', 0x80000000 +// CHECK: # Section 1 +// CHECK: 'section_name', '__data +// CHECK: 'flags', 0x400 + + .text + + .data +f0: + movl $0, %eax |

