示例#1
0
int main(int argc, char *argv[]) {
	if (argc < 3) {
		print_usage();
		return 1;
	}

	if (argv[1] == std::string("--fixup"))
		fixup_elf(argc, argv);
	else
		generate_stubs(argc, argv);

	return 0;
}
示例#2
0
文件: mkshlib.c 项目: JamesLinus/vsta
int
main(int argc, char **argv)
{
	FILE *fp;
	char *keyword, *p, buf[128];
	int x, nfile = 0;

	page_size = getpagesize();
	for (x = 1; x < argc; ++x) {
		/*
		 * Switches
		 */
		if (argv[x][0] == '-') {
			switch (argv[x][1]) {
			case 'v':		/* Verbose/tracing */
				vflag = 1;
				break;
			case 's':		/* Generate stubs */
				stubs = 1;
				break;
			case 'l':		/* Generate shlib */
				shlib = 1;
				break;
			default:
				usage();
			}
			continue;
		}

		/*
		 * Must choose switches first
		 */
		if (!stubs && !shlib) {
			usage();
		}

		/*
		 * Access database file
		 */
		nfile += 1;
		curfile = argv[x];
		fp = fopen(curfile, "r");
		if (fp == NULL) {
			perror(curfile);
			exit(1);
		}

		/*
		 * Process operations while there are lines in file
		 */
		while (fgets(buf, sizeof(buf), fp)) {
			/*
			 * Break out word at start of line from
			 * arguments.  Convert \n termination to \0.
			 */
			keyword = p = buf;
			p[strlen(p) - 1] = '\0';
			while (*p && (*p != '\n') && !isspace(*p)) {
				++p;
			}

			/*
			 * Null-terminate the starting word
			 */
			if (*p) {
				*p++ = '\0';
			}
			while (*p && isspace(*p))
				++p;

			/*
			 * Continue on comments
			 */
			if (!keyword[0] || (keyword[0] == '#')) {
				continue;
			}

			/*
			 * Decode keyword, call out to appropriate function
			 */
			if (!strcmp(keyword, "library")) {
				start_library(p);
			} else {
				add_entry(keyword, *p ? p : 0);
			}
		}
		fclose(fp);

		add_entry(NULL, NULL);	/* Sentinels */
		obj_sym(NULL);

		/*
		 * A couple sanity checks
		 */
		check_lost("Objects no longer in library",
			db_syms, obj_syms, NULL);
		check_lost("Entry points new to library",
			obj_syms, db_syms, db_hide);

		/*
		 * End of file.  Start building actual files.
		 */
		if (stubs) {
			generate_stubs();
		}
		if (shlib) {
			generate_shlib();
		}

		/*
		 * Done with this library
		 */
		end_library();
	}

	/*
	 * Complain if we didn't process even one file
	 */
	if (nfile == 0) {
		usage();
	}

	return(0);
}