[llvm-commits] [llvm] r80144 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp lib/MC/MCMachOStreamer.cpp test/MC/MachO/sections.s
Daniel Dunbar
daniel at zuster.org
Wed Aug 26 14:22:22 PDT 2009
Author: ddunbar
Date: Wed Aug 26 16:22:22 2009
New Revision: 80144
URL: http://llvm.org/viewvc/llvm-project?rev=80144&view=rev
Log:
llvm-mc/Mach-O: Set .subsections_via_symbols flag properly.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/test/MC/MachO/sections.s
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=80144&r1=80143&r2=80144&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Wed Aug 26 16:22:22 2009
@@ -496,6 +496,8 @@
std::vector<IndirectSymbolData> IndirectSymbols;
+ unsigned SubsectionsViaSymbols : 1;
+
private:
/// LayoutSection - Assign offsets and sizes to the fragments in the section
/// \arg SD, and update the section size. The section file offset should
@@ -521,6 +523,14 @@
/// Finish - Do final processing and write the object to the output stream.
void Finish();
+ // FIXME: This does not belong here.
+ bool getSubsectionsViaSymbols() const {
+ return SubsectionsViaSymbols;
+ }
+ void setSubsectionsViaSymbols(bool Value) {
+ SubsectionsViaSymbols = Value;
+ }
+
/// @name Section List Access
/// @{
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=80144&r1=80143&r2=80144&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Wed Aug 26 16:22:22 2009
@@ -48,6 +48,10 @@
HFT_Object = 0x1
};
+ enum HeaderFlags {
+ HF_SubsectionsViaSymbols = 0x2000
+ };
+
enum LoadCommandType {
LCT_Segment = 0x1,
LCT_Symtab = 0x2,
@@ -167,7 +171,13 @@
/// @}
- 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 @@
// 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 @@
}
// 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 @@
/* *** */
-MCAssembler::MCAssembler(raw_ostream &_OS) : OS(_OS) {}
+MCAssembler::MCAssembler(raw_ostream &_OS)
+ : OS(_OS),
+ SubsectionsViaSymbols(false)
+{
+}
MCAssembler::~MCAssembler() {
}
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=80144&r1=80143&r2=80144&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Wed Aug 26 16:22:22 2009
@@ -159,7 +159,14 @@
}
void MCMachOStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
- llvm_unreachable("FIXME: Not yet implemented!");
+ switch (Flag) {
+ default:
+ llvm_unreachable("FIXME: Not yet implemented!");
+
+ case SubsectionsViaSymbols:
+ Assembler.setSubsectionsViaSymbols(true);
+ break;
+ }
}
void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol,
Modified: llvm/trunk/test/MC/MachO/sections.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/sections.s?rev=80144&r1=80143&r2=80144&view=diff
==============================================================================
--- llvm/trunk/test/MC/MachO/sections.s (original)
+++ llvm/trunk/test/MC/MachO/sections.s Wed Aug 26 16:22:22 2009
@@ -42,13 +42,14 @@
.objc_selector_strs
-
+ .subsections_via_symbols
+
// CHECK: ('cputype', 7)
// CHECK: ('cpusubtype', 3)
// CHECK: ('filetype', 1)
// CHECK: ('num_load_commands', 1)
// CHECK: ('load_commands_size', 2436)
-// CHECK: ('flag', 0)
+// CHECK: ('flag', 8192)
// CHECK: ('load_commands', [
// CHECK: # Load Command 0
// CHECK: (('command', 1)
More information about the llvm-commits
mailing list