aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-26 21:22:22 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-26 21:22:22 +0000
commit6009db486e7fba448ccb28dff676c012efade8f0 (patch)
tree9907579eccc1c43efe3ad4508f9a718fb869340a /lib/MC/MCAssembler.cpp
parent8464f072350d7f8fc12180f0f2071fe2d08c928d (diff)
llvm-mc/Mach-O: Set .subsections_via_symbols flag properly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80144 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r--lib/MC/MCAssembler.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 1f62b06052..9efdfe359b 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -48,6 +48,10 @@ class MachObjectWriter {
HFT_Object = 0x1
};
+ enum HeaderFlags {
+ HF_SubsectionsViaSymbols = 0x2000
+ };
+
enum LoadCommandType {
LCT_Segment = 0x1,
LCT_Symtab = 0x2,
@@ -167,7 +171,13 @@ public:
/// @}
- void WriteHeader32(unsigned NumLoadCommands, unsigned LoadCommandsSize) {
+ void WriteHeader32(unsigned NumLoadCommands, unsigned LoadCommandsSize,
+ bool SubsectionsViaSymbols) {
+ uint32_t Flags = 0;
+
+ if (SubsectionsViaSymbols)
+ Flags |= HF_SubsectionsViaSymbols;
+
// struct mach_header (28 bytes)
uint64_t Start = OS.tell();
@@ -177,16 +187,13 @@ public:
// FIXME: Support cputype.
Write32(TargetMachOWriterInfo::HDR_CPU_TYPE_I386);
-
// FIXME: Support cpusubtype.
Write32(TargetMachOWriterInfo::HDR_CPU_SUBTYPE_I386_ALL);
-
Write32(HFT_Object);
-
- // Object files have a single load command, the segment.
- Write32(NumLoadCommands);
+ Write32(NumLoadCommands); // Object files have a single load command, the
+ // segment.
Write32(LoadCommandsSize);
- Write32(0); // Flags
+ Write32(Flags);
assert(OS.tell() - Start == Header32Size);
}
@@ -674,7 +681,8 @@ public:
}
// Write the prolog, starting with the header and load command...
- WriteHeader32(NumLoadCommands, LoadCommandsSize);
+ WriteHeader32(NumLoadCommands, LoadCommandsSize,
+ Asm.getSubsectionsViaSymbols());
WriteSegmentLoadCommand32(NumSections, SectionDataStart, SectionDataSize);
// ... and then the section headers.
@@ -864,7 +872,11 @@ MCSymbolData::MCSymbolData(MCSymbol &_Symbol, MCFragment *_Fragment,
/* *** */
-MCAssembler::MCAssembler(raw_ostream &_OS) : OS(_OS) {}
+MCAssembler::MCAssembler(raw_ostream &_OS)
+ : OS(_OS),
+ SubsectionsViaSymbols(false)
+{
+}
MCAssembler::~MCAssembler() {
}