mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 18:24:23 +00:00
Teach MachO which sections contain code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170349 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -237,6 +237,10 @@ namespace macho {
|
|||||||
/// @name Section Data
|
/// @name Section Data
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
enum SectionFlags {
|
||||||
|
SF_PureInstructions = 0x80000000
|
||||||
|
};
|
||||||
|
|
||||||
struct Section {
|
struct Section {
|
||||||
char Name[16];
|
char Name[16];
|
||||||
char SegmentName[16];
|
char SegmentName[16];
|
||||||
|
@ -314,7 +314,7 @@ bool DarwinAsmParser::ParseSectionSwitch(const char *Segment,
|
|||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
// FIXME: Arch specific.
|
// FIXME: Arch specific.
|
||||||
bool isText = StringRef(Segment) == "__TEXT"; // FIXME: Hack.
|
bool isText = TAA & MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS;
|
||||||
getStreamer().SwitchSection(getContext().getMachOSection(
|
getStreamer().SwitchSection(getContext().getMachOSection(
|
||||||
Segment, Section, TAA, StubSize,
|
Segment, Section, TAA, StubSize,
|
||||||
isText ? SectionKind::getText()
|
isText ? SectionKind::getText()
|
||||||
|
@ -559,11 +559,11 @@ error_code MachOObjectFile::isSectionText(DataRefImpl DRI,
|
|||||||
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
if (is64BitLoadCommand(MachOObj.get(), DRI)) {
|
||||||
InMemoryStruct<macho::Section64> Sect;
|
InMemoryStruct<macho::Section64> Sect;
|
||||||
getSection64(DRI, Sect);
|
getSection64(DRI, Sect);
|
||||||
Result = !strcmp(Sect->Name, "__text");
|
Result = Sect->Flags & macho::SF_PureInstructions;
|
||||||
} else {
|
} else {
|
||||||
InMemoryStruct<macho::Section> Sect;
|
InMemoryStruct<macho::Section> Sect;
|
||||||
getSection(DRI, Sect);
|
getSection(DRI, Sect);
|
||||||
Result = !strcmp(Sect->Name, "__text");
|
Result = Sect->Flags & macho::SF_PureInstructions;
|
||||||
}
|
}
|
||||||
return object_error::success;
|
return object_error::success;
|
||||||
}
|
}
|
||||||
|
BIN
test/Object/Inputs/macho-text-sections.macho-x86_64
Normal file
BIN
test/Object/Inputs/macho-text-sections.macho-x86_64
Normal file
Binary file not shown.
3
test/Object/X86/macho-text-sections.test
Normal file
3
test/Object/X86/macho-text-sections.test
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
RUN: llvm-objdump -disassemble %p/../Inputs/macho-text-sections.macho-x86_64 | FileCheck %s
|
||||||
|
|
||||||
|
CHECK: Disassembly of section __notext,__notext
|
Reference in New Issue
Block a user