ObjectFileMachO: split CreateSections mega-function into more manageable chunks

Summary:
In an effort to understand the function's operation, I've split it into logical
pieces. Parsing of a single segment is moved to a separate function (and the
parsing state that is carried from one segment to another is explicitly
captured in the SegmentParsingContext object). I've also extracted some pieces
of code which were already standalone (validation of the segment load command,
determining the section type, determining segment permissions) into
separate functions.

Parsing of a single section within the segment should probably also be a
separate function, but I've left that for a separate patch.

This patch is intended to be NFC.

Reviewers: clayborg, davide

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D44074

llvm-svn: 326791
This commit is contained in:
Pavel Labath
2018-03-06 13:53:26 +00:00
parent d34f6843aa
commit b417eeaeb5
2 changed files with 528 additions and 519 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -185,6 +185,18 @@ protected:
size_t ParseSymtab();
typedef lldb_private::RangeArray<uint32_t, uint32_t, 8> EncryptedFileRanges;
EncryptedFileRanges GetEncryptedFileRanges();
struct SegmentParsingContext;
void ProcessDysymtabCommand(const llvm::MachO::load_command &load_cmd,
lldb::offset_t offset);
void ProcessSegmentCommand(const llvm::MachO::load_command &load_cmd,
lldb::offset_t offset, uint32_t cmd_idx,
SegmentParsingContext &context);
void SanitizeSegmentCommand(llvm::MachO::segment_command_64 &seg_cmd,
uint32_t cmd_idx);
llvm::MachO::mach_header m_header;
static const lldb_private::ConstString &GetSegmentNameTEXT();
static const lldb_private::ConstString &GetSegmentNameDATA();