Skip to content

Commit

Permalink
Sync with upstream r240 and r241
Browse files Browse the repository at this point in the history
  • Loading branch information
reverser committed Apr 23, 2015
1 parent 24e273d commit 0e8ff9e
Show file tree
Hide file tree
Showing 18 changed files with 605 additions and 623 deletions.
30 changes: 15 additions & 15 deletions ArchiveLayout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (MVNode *)createSignatureNode:(MVNode *)parent
NSRange range = NSMakeRange(location,0);
NSString * lastReadHex;

NSString * signature = [self read_string:range fixlen:8 lastReadHex:&lastReadHex];
NSString * signature = [dataController read_string:range fixlen:8 lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Signature"
Expand All @@ -92,38 +92,38 @@ - (MVNode *)createHeaderNode:(MVNode *)parent
NSRange range = NSMakeRange(location,0);
NSString * lastReadHex;

NSString * name = [self read_string:range fixlen:16 lastReadHex:&lastReadHex];
NSString * name = [dataController read_string:range fixlen:16 lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Name"
:name];

NSString * time_str = [self read_string:range fixlen:12 lastReadHex:&lastReadHex];
NSString * time_str = [dataController read_string:range fixlen:12 lastReadHex:&lastReadHex];
time_t time = (time_t)[time_str longLongValue];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Time Stamp"
:[NSString stringWithFormat:@"%s", ctime(&time)]];

NSString * user_id_str = [self read_string:range fixlen:6 lastReadHex:&lastReadHex];
NSString * user_id_str = [dataController read_string:range fixlen:6 lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"UserID"
:[NSString stringWithFormat:@"%u",[user_id_str intValue]]];

NSString * group_id_str = [self read_string:range fixlen:6 lastReadHex:&lastReadHex];
NSString * group_id_str = [dataController read_string:range fixlen:6 lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"GroupID"
:[NSString stringWithFormat:@"%u",[group_id_str intValue]]];

NSString * mode_str = [self read_string:range fixlen:8 lastReadHex:&lastReadHex];
NSString * mode_str = [dataController read_string:range fixlen:8 lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Mode"
:[NSString stringWithFormat:@"%u",[mode_str intValue]]];

NSString * size_str = [self read_string:range fixlen:8 lastReadHex:&lastReadHex];
NSString * size_str = [dataController read_string:range fixlen:8 lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Size"
Expand All @@ -134,11 +134,11 @@ - (MVNode *)createHeaderNode:(MVNode *)parent
NSMutableString * padding = [[NSMutableString alloc] initWithCapacity:2];
for(;;)
{
[padding appendString:[self read_string:range fixlen:1 lastReadHex:&lastReadHex]];
[padding appendString:[dataController read_string:range fixlen:1 lastReadHex:&lastReadHex]];
[mutableLastReadHex appendString:lastReadHex];
if (*(CSTRING(padding) + [padding length] - 1) != ' ')
{
[padding appendString:[self read_string:range fixlen:1 lastReadHex:&lastReadHex]];
[padding appendString:[dataController read_string:range fixlen:1 lastReadHex:&lastReadHex]];
[mutableLastReadHex appendString:lastReadHex];
break;
}
Expand All @@ -152,7 +152,7 @@ - (MVNode *)createHeaderNode:(MVNode *)parent
if (NSEqualRanges([name rangeOfString:@"#1/"], NSMakeRange(0,3)))
{
uint32_t len = [[name substringFromIndex:3] intValue];
NSString * long_name = [self read_string:range fixlen:len lastReadHex:&lastReadHex];
NSString * long_name = [dataController read_string:range fixlen:len lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Long Name"
Expand Down Expand Up @@ -184,7 +184,7 @@ - (MVNode *)createMemberNode:(MVNode *)parent
NSRange range = NSMakeRange(location,0);
NSString * lastReadHex;

uint32_t size = [self read_uint32:range lastReadHex:&lastReadHex];
uint32_t size = [dataController read_uint32:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Size"
Expand All @@ -197,7 +197,7 @@ - (MVNode *)createMemberNode:(MVNode *)parent

while (size > 0)
{
uint32_t strx = [self read_uint32:range lastReadHex:&lastReadHex];
uint32_t strx = [dataController read_uint32:range lastReadHex:&lastReadHex];

// accumulate search info
NSUInteger bookmark = node.details.rowCount;
Expand All @@ -208,7 +208,7 @@ - (MVNode *)createMemberNode:(MVNode *)parent
:@"Symbol"
:symbolName];

uint32_t off = [self read_uint32:range lastReadHex:&lastReadHex];
uint32_t off = [dataController read_uint32:range lastReadHex:&lastReadHex];

MVObjectInfo * objectInfo = [objectInfoMap objectForKey:[NSNumber numberWithUnsignedLong:off + imageOffset]];

Expand Down Expand Up @@ -250,10 +250,10 @@ - (void)doMainTasks
// skip symbol and string table for now
uint32_t symtabOffset = NSMaxRange(symtabHeaderNode.dataRange);
NSRange range = NSMakeRange(symtabOffset,0);
uint32_t symtabSize = [self read_uint32:range lastReadHex:&lastReadHex] + sizeof(uint32_t);
uint32_t symtabSize = [dataController read_uint32:range lastReadHex:&lastReadHex] + sizeof(uint32_t);
uint32_t strtabOffset = symtabOffset + symtabSize;
range = NSMakeRange(strtabOffset,0);
uint32_t strtabSize = [self read_uint32:range lastReadHex:&lastReadHex] + sizeof(uint32_t);
uint32_t strtabSize = [dataController read_uint32:range lastReadHex:&lastReadHex] + sizeof(uint32_t);

// read headers

Expand Down
2 changes: 1 addition & 1 deletion DataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ struct MVNodeSaver
MVNodeSaver(MVNodeSaver const &);
MVNodeSaver & operator=(MVNodeSaver const &);

MVNode * m_node;
MVNode * __weak m_node;
};


16 changes: 15 additions & 1 deletion DataController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,18 @@ @implementation MVDataController

@synthesize fileName, fileData, realData, layouts, rootNode, selectedNode, treeLock;

//-----------------------------------------------------------------------------
/*
- (void)dealloc
{
NSLog(@"********MVDataController deallocated: %@", self);
for (MVLayout * layout in layouts)
{
NSLog(@"%@ Retain count is %ld", layout, CFGetRetainCount((__bridge CFTypeRef)layout));
}
}
*/

//-----------------------------------------------------------------------------
-(id)init
{
Expand Down Expand Up @@ -1237,6 +1249,7 @@ -(id) initWithPath:(NSString *)path
#ifndef MV_NO_ARCHIVER
saverThread = [[NSThread alloc] initWithTarget:self selector:@selector(doSave) object:nil];
[saverThread start];
NSLog(@"********MVArchiver started: %@", self);
#endif
}
return self;
Expand Down Expand Up @@ -1264,6 +1277,7 @@ -(void) resume
-(void) halt
{
[saverThread cancel];
NSLog(@"********MVArchiver halted: %@", self);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -1333,7 +1347,7 @@ -(void) doSave
//return;
//[NSThread exit];
}
// do not wait for new rows if the saver has benn cancelled
// do not wait for new rows if the saver has been cancelled
// just flush out the existing ones
continue;
}
Expand Down
44 changes: 22 additions & 22 deletions DyldInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (MVNode *)createRebaseNode:(MVNode *)parent

while (NSMaxRange(range) < location + length && isDone == NO)
{
uint8_t byte = [self read_int8:range lastReadHex:&lastReadHex];
uint8_t byte = [dataController read_int8:range lastReadHex:&lastReadHex];
uint8_t opcode = byte & REBASE_OPCODE_MASK;
uint8_t immediate = byte & REBASE_IMMEDIATE_MASK;

Expand Down Expand Up @@ -163,7 +163,7 @@ - (MVNode *)createRebaseNode:(MVNode *)parent
:@"REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB"
:[NSString stringWithFormat:@"segment (%u)", segmentIndex]];

uint64_t offset = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t offset = [dataController read_uleb128:range lastReadHex:&lastReadHex];

[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand All @@ -188,7 +188,7 @@ - (MVNode *)createRebaseNode:(MVNode *)parent
:@"REBASE_OPCODE_ADD_ADDR_ULEB"
:@""];

uint64_t offset = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t offset = [dataController read_uleb128:range lastReadHex:&lastReadHex];

[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand Down Expand Up @@ -240,7 +240,7 @@ - (MVNode *)createRebaseNode:(MVNode *)parent

uint32_t startNextRebase = NSMaxRange(range);

uint64_t count = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t count = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
Expand All @@ -267,7 +267,7 @@ - (MVNode *)createRebaseNode:(MVNode *)parent

uint32_t startNextRebase = NSMaxRange(range);

uint64_t offset = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t offset = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
Expand All @@ -291,13 +291,13 @@ - (MVNode *)createRebaseNode:(MVNode *)parent

uint32_t startNextRebase = NSMaxRange(range);

uint64_t count = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t count = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
:[NSString stringWithFormat:@"count (%qu)",count]];

uint64_t skip = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t skip = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
Expand Down Expand Up @@ -458,7 +458,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent

while (NSMaxRange(range) < location + length && isDone == NO)
{
uint8_t byte = [self read_int8:range lastReadHex:&lastReadHex];
uint8_t byte = [dataController read_int8:range lastReadHex:&lastReadHex];
uint8_t opcode = byte & BIND_OPCODE_MASK;
uint8_t immediate = byte & BIND_IMMEDIATE_MASK;

Expand Down Expand Up @@ -494,7 +494,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent
:@"BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB"
:@""];

libOrdinal = [self read_uleb128:range lastReadHex:&lastReadHex];
libOrdinal = [dataController read_uleb128:range lastReadHex:&lastReadHex];

[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand Down Expand Up @@ -528,7 +528,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent
:@"BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM"
:[NSString stringWithFormat:@"flags (%u)",((uint32_t)-1 & symbolFlags)]];

symbolName = [self read_string:range lastReadHex:&lastReadHex];
symbolName = [dataController read_string:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"string"
Expand All @@ -552,7 +552,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent
:@"BIND_OPCODE_SET_ADDEND_SLEB"
:@""];

addend = [self read_sleb128:range lastReadHex:&lastReadHex];
addend = [dataController read_sleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"sleb128"
Expand All @@ -568,7 +568,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent
:@"BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB"
:[NSString stringWithFormat:@"segment (%u)",segmentIndex]];

uint64_t val = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t val = [dataController read_uleb128:range lastReadHex:&lastReadHex];

[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand All @@ -593,7 +593,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent
:@"BIND_OPCODE_ADD_ADDR_ULEB"
:@""];

uint64_t val = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t val = [dataController read_uleb128:range lastReadHex:&lastReadHex];

[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand Down Expand Up @@ -638,7 +638,7 @@ - (MVNode *)createBindingNode:(MVNode *)parent

uint32_t startNextBind = NSMaxRange(range);

uint64_t val = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t val = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
Expand Down Expand Up @@ -700,13 +700,13 @@ - (MVNode *)createBindingNode:(MVNode *)parent

uint32_t startNextBind = NSMaxRange(range);

uint64_t count = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t count = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
:[NSString stringWithFormat:@"count (%qu)",count]];

uint64_t skip = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t skip = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details appendRow:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"uleb128"
Expand Down Expand Up @@ -797,7 +797,7 @@ - (void)printSymbols:(NSString *)prefix
NSRange range = NSMakeRange(location + skip,0);
NSString * lastReadHex;

uint8_t terminalSize = [self read_uint8:range lastReadHex:&lastReadHex];
uint8_t terminalSize = [dataController read_uint8:range lastReadHex:&lastReadHex];
[node.details insertRowWithOffset:range.location
:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand All @@ -808,7 +808,7 @@ - (void)printSymbols:(NSString *)prefix
{
uint32_t terminalLocation = NSMaxRange(range);

uint64_t flags = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t flags = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details insertRowWithOffset:range.location
:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand All @@ -821,7 +821,7 @@ - (void)printSymbols:(NSString *)prefix
if (flags & EXPORT_SYMBOL_FLAGS_REEXPORT) [node.details insertRowWithOffset:range.location:@"":@"":@"08":@"EXPORT_SYMBOL_FLAGS_REEXPORT"];
if (flags & EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER) [node.details insertRowWithOffset:range.location:@"":@"":@"10":@"EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER"];

uint64_t offset = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t offset = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details insertRowWithOffset:range.location
:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand All @@ -839,7 +839,7 @@ - (void)printSymbols:(NSString *)prefix
range = NSMakeRange(terminalLocation, terminalSize);
}

uint8_t childCount = [self read_uint8:range lastReadHex:&lastReadHex];
uint8_t childCount = [dataController read_uint8:range lastReadHex:&lastReadHex];
[node.details insertRowWithOffset:range.location
:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand All @@ -856,14 +856,14 @@ - (void)printSymbols:(NSString *)prefix
{
exportLocation = NSMaxRange(range);

NSString * label = [self read_string:range lastReadHex:&lastReadHex];
NSString * label = [dataController read_string:range lastReadHex:&lastReadHex];
[node.details insertRowWithOffset:range.location
:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
:@"Node Label"
:[NSString stringWithFormat:@"\"%@\"",label]];

uint64_t skip = [self read_uleb128:range lastReadHex:&lastReadHex];
uint64_t skip = [dataController read_uleb128:range lastReadHex:&lastReadHex];
[node.details insertRowWithOffset:range.location
:[NSString stringWithFormat:@"%.8lX", range.location]
:lastReadHex
Expand Down
Loading

0 comments on commit 0e8ff9e

Please sign in to comment.