[llvm-commits] [llvm] r170349 - in /llvm/trunk: include/llvm/Object/MachOFormat.h lib/MC/MCParser/DarwinAsmParser.cpp lib/Object/MachOObjectFile.cpp test/Object/Inputs/macho-text-sections.macho-x86_64 test/Object/X86/macho-text-sections.test
Tim Northover
Tim.Northover at arm.com
Mon Dec 17 09:59:33 PST 2012
Author: tnorthover
Date: Mon Dec 17 11:59:32 2012
New Revision: 170349
URL: http://llvm.org/viewvc/llvm-project?rev=170349&view=rev
Log:
Teach MachO which sections contain code
Added:
llvm/trunk/test/Object/Inputs/macho-text-sections.macho-x86_64 (with props)
llvm/trunk/test/Object/X86/macho-text-sections.test (with props)
Modified:
llvm/trunk/include/llvm/Object/MachOFormat.h
llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
Modified: llvm/trunk/include/llvm/Object/MachOFormat.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachOFormat.h?rev=170349&r1=170348&r2=170349&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachOFormat.h (original)
+++ llvm/trunk/include/llvm/Object/MachOFormat.h Mon Dec 17 11:59:32 2012
@@ -237,6 +237,10 @@
/// @name Section Data
/// @{
+ enum SectionFlags {
+ SF_PureInstructions = 0x80000000
+ };
+
struct Section {
char Name[16];
char SegmentName[16];
Modified: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp?rev=170349&r1=170348&r2=170349&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp Mon Dec 17 11:59:32 2012
@@ -314,7 +314,7 @@
Lex();
// FIXME: Arch specific.
- bool isText = StringRef(Segment) == "__TEXT"; // FIXME: Hack.
+ bool isText = TAA & MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS;
getStreamer().SwitchSection(getContext().getMachOSection(
Segment, Section, TAA, StubSize,
isText ? SectionKind::getText()
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=170349&r1=170348&r2=170349&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon Dec 17 11:59:32 2012
@@ -559,11 +559,11 @@
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
InMemoryStruct<macho::Section64> Sect;
getSection64(DRI, Sect);
- Result = !strcmp(Sect->Name, "__text");
+ Result = Sect->Flags & macho::SF_PureInstructions;
} else {
InMemoryStruct<macho::Section> Sect;
getSection(DRI, Sect);
- Result = !strcmp(Sect->Name, "__text");
+ Result = Sect->Flags & macho::SF_PureInstructions;
}
return object_error::success;
}
Added: llvm/trunk/test/Object/Inputs/macho-text-sections.macho-x86_64
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/macho-text-sections.macho-x86_64?rev=170349&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/macho-text-sections.macho-x86_64 (added) and llvm/trunk/test/Object/Inputs/macho-text-sections.macho-x86_64 Mon Dec 17 11:59:32 2012 differ
Propchange: llvm/trunk/test/Object/Inputs/macho-text-sections.macho-x86_64
------------------------------------------------------------------------------
svn:eol-style = native
Added: llvm/trunk/test/Object/X86/macho-text-sections.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/X86/macho-text-sections.test?rev=170349&view=auto
==============================================================================
--- llvm/trunk/test/Object/X86/macho-text-sections.test (added)
+++ llvm/trunk/test/Object/X86/macho-text-sections.test Mon Dec 17 11:59:32 2012
@@ -0,0 +1,3 @@
+RUN: llvm-objdump -disassemble %p/../Inputs/macho-text-sections.macho-x86_64 | FileCheck %s
+
+CHECK: Disassembly of section __notext,__notext
Propchange: llvm/trunk/test/Object/X86/macho-text-sections.test
------------------------------------------------------------------------------
svn:eol-style = native
More information about the llvm-commits
mailing list