[llvm-commits] [llvm] r95135 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp lib/MC/MCMachOStreamer.cpp test/MC/MachO/section-flags.s
Daniel Dunbar
daniel at zuster.org
Tue Feb 2 13:44:02 PST 2010
Author: ddunbar
Date: Tue Feb 2 15:44:01 2010
New Revision: 95135
URL: http://llvm.org/viewvc/llvm-project?rev=95135&view=rev
Log:
MC/Mach-O: Set SOME_INSTRUCTIONS bit for sections.
Added:
llvm/trunk/test/MC/MachO/section-flags.s
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=95135&r1=95134&r2=95135&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Tue Feb 2 15:44:01 2010
@@ -348,7 +348,11 @@
/// 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 @@
}
void setFileSize(uint64_t Value) { FileSize = Value; }
+ bool hasInstructions() const { return HasInstructions; }
+ void setHasInstructions(bool Value) { HasInstructions = Value; }
+
/// @}
};
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=95135&r1=95134&r2=95135&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Tue Feb 2 15:44:01 2010
@@ -266,11 +266,15 @@
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 @@
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);
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=95135&r1=95134&r2=95135&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Tue Feb 2 15:44:01 2010
@@ -362,8 +362,8 @@
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);
Added: llvm/trunk/test/MC/MachO/section-flags.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/section-flags.s?rev=95135&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/section-flags.s (added)
+++ llvm/trunk/test/MC/MachO/section-flags.s Tue Feb 2 15:44:01 2010
@@ -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
More information about the llvm-commits
mailing list