[darwinbuild-changes] [189] trunk/darwinxref/plugins/register.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 01:56:16 PDT 2006


Revision: 189
          http://trac.macosforge.org/projects/darwinbuild/changeset/189
Author:   ssen
Date:     2006-10-04 01:56:16 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
Have the Mach-O introspection code consider LC_LOAD_DYLINKER
load commands as a "lib" dependency, because it kind of is,
and is better than hard-coding a dependency on dyld

Also, in -stdin mode, we don't really care about checksums,
and they just slow us down. If we start caring about checksums,
create a new command-line option.

Modified Paths:
--------------
    trunk/darwinxref/plugins/register.c

Modified: trunk/darwinxref/plugins/register.c
===================================================================
--- trunk/darwinxref/plugins/register.c	2005-08-24 02:17:42 UTC (rev 188)
+++ trunk/darwinxref/plugins/register.c	2006-10-04 08:56:16 UTC (rev 189)
@@ -188,6 +188,7 @@
 	int i;
 	for (i = 0; i < mh->ncmds; ++i) {
 		struct dylib_command lc;
+		struct dylinker_command lcdyld;
 		int res = read(fd, &lc, sizeof(struct load_command));
 		if (res < sizeof(struct load_command)) { return 0; }
 
@@ -216,6 +217,32 @@
 			free(str);
 			
 			lseek(fd, save - sizeof(struct dylib_command) + lc.cmdsize, SEEK_SET);
+			
+		} else if (cmd == LC_LOAD_DYLINKER) {
+		  lcdyld.cmd = lc.cmd;
+		  lcdyld.cmdsize = lc.cmdsize;
+			res = read(fd, &lcdyld.name, sizeof(union lc_str));
+			if (res < sizeof(union lc_str)) { return 0; }
+
+			if (swap) swap_dylinker_command(&lcdyld, NXHostByteOrder());
+
+			off_t save = lseek(fd, 0, SEEK_CUR);
+			off_t offset = lcdyld.name.offset - sizeof(struct dylinker_command);
+
+			if (offset > 0) { lseek(fd, offset, SEEK_CUR); }
+			int strsize = lcdyld.cmdsize - sizeof(struct dylinker_command);
+
+			char* str = malloc(strsize+1);
+			res = read(fd, str, strsize);
+			if (res < sizeof(strsize)) { return 0; }
+			str[strsize] = 0; // NUL-terminate
+						
+			res = SQL("INSERT INTO unresolved_dependencies (build,project,type,dependency) VALUES (%Q,%Q,%Q,%Q)",
+			build, project, "lib", str);
+			
+			free(str);
+			
+			lseek(fd, save - sizeof(struct dylinker_command) + lcdyld.cmdsize, SEEK_SET);
 		} else {
 			uint32_t cmdsize = swap ? NXSwapLong(lc.cmdsize) : lc.cmdsize;
 			lseek(fd, cmdsize - sizeof(struct load_command), SEEK_CUR);
@@ -440,8 +467,10 @@
 				return -1;
 			}
 			res = register_libraries(fd, build, project);
+			/* For -stdin mode, we don't calculate checksums
 			lseek(fd, (off_t)0, SEEK_SET);
 			checksum = calculate_digest(fd);
+			*/
 			close(fd);
 		}
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/16f13310/attachment.html


More information about the darwinbuild-changes mailing list