llvm.org GIT mirror llvm / e1ec617
MC/Mach-O: Set SOME_INSTRUCTIONS bit for sections. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95135 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 9 years ago
4 changed file(s) with 31 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
347347
348348 /// Fixups - The list of fixups in this section.
349349 std::vector Fixups;
350
350
351 /// HasInstructions - Whether this section has had instructions emitted into
352 /// it.
353 unsigned HasInstructions : 1;
354
351355 /// @}
352356
353357 public:
427431 return FileSize;
428432 }
429433 void setFileSize(uint64_t Value) { FileSize = Value; }
434
435 bool hasInstructions() const { return HasInstructions; }
436 void setHasInstructions(bool Value) { HasInstructions = Value; }
430437
431438 /// @}
432439 };
265265 Write32(SD.getSize()); // size
266266 Write32(FileOffset);
267267
268 unsigned Flags = Section.getTypeAndAttributes();
269 if (SD.hasInstructions())
270 Flags |= MCSectionMachO::S_ATTR_SOME_INSTRUCTIONS;
271
268272 assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!");
269273 Write32(Log2_32(SD.getAlignment()));
270274 Write32(NumRelocations ? RelocationsStart : 0);
271275 Write32(NumRelocations);
272 Write32(Section.getTypeAndAttributes());
276 Write32(Flags);
273277 Write32(0); // reserved1
274278 Write32(Section.getStubSize()); // reserved2
275279
900904 Address(~UINT64_C(0)),
901905 Size(~UINT64_C(0)),
902906 FileSize(~UINT64_C(0)),
903 LastFixupLookup(~0)
907 LastFixupLookup(~0),
908 HasInstructions(false)
904909 {
905910 if (A)
906911 A->getSectionList().push_back(this);
361361 if (!Emitter)
362362 llvm_unreachable("no code emitter available!");
363363
364 // FIXME: Emitting an instruction should cause S_ATTR_SOME_INSTRUCTIONS to
365 // be set for the current section.
364 CurSectionData->setHasInstructions(true);
365
366366 // FIXME: Relocations!
367367 SmallString<256> Code;
368368 raw_svector_ostream VecOS(Code);
0 // RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | macho-dump | FileCheck %s
1 //
2 // CHECK: # Section 0
3 // CHECK: 'section_name', '__text
4 // CHECK: 'flags', 0x80000000
5 // CHECK: # Section 1
6 // CHECK: 'section_name', '__data
7 // CHECK: 'flags', 0x400
8
9 .text
10
11 .data
12 f0:
13 movl $0, %eax