/// 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:
}
void setFileSize(uint64_t Value) { FileSize = Value; }
+ bool hasInstructions() const { return HasInstructions; }
+ void setHasInstructions(bool Value) { HasInstructions = Value; }
+
/// @}
};
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
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);
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);
--- /dev/null
+// 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