Пример #1
0
int 
main(int argc, char *argv[])
{
	int ch;
	char *ep;

	if (argc == 1)
		usage();

	progname = argv[0];

	while ((ch = getopt(argc, argv, "m:n:o:O:p:s:tw")) != -1) {
		switch (ch) {
		case 'm':
			SetMapfileName(optarg);
			break;
		case 'n':
			SetSymfileName(optarg);
			break;
		case 'o':
			out_Setname(optarg);
			break;
		case 'O':
			out_SetOverlayname(optarg);
			options |= OPT_OVERLAY;
			break;
		case 'p':
			fillchar = strtoul(optarg, &ep, 0);
			if (optarg[0] == '\0' || *ep != '\0') {
				errx(1, "Invalid argument for option 'p'");
			}
			if (fillchar < 0 || fillchar > 0xFF) {
				fprintf(stderr, "Argument for option 'p' must be between 0 and 0xFF");
				exit(1);
			}
			break;
		case 's':
			options |= OPT_SMART_C_LINK;
			smartlinkstartsymbol = optarg;
			break;
		case 't':
			options |= OPT_SMALL;
			break;
		case 'w':
			/* Set to set WRAM as a single continuous block as on DMG.
			All WRAM sections must be WRAM0 as bankable WRAM sections do
			not exist in this mode. A WRAMX section will raise an error. */
			options |= OPT_CONTWRAM;
			break;
		default:
			usage();
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

	if (argc == 0)
		usage();

	for (int i = 0; i < argc; ++i)
		obj_Readfile(argv[i]);

	AddNeededModules();
	AssignSections();
	CreateSymbolTable();
	Patch();
	Output();
	CloseMapfile();

	return (0);
}
Пример #2
0
int main(int argc, char *argv[])
{
	int ch;
	char *ep;

	if (argc == 1)
		print_usage();

	while ((ch = getopt(argc, argv, "dl:m:n:O:o:p:s:tVw")) != -1) {
		switch (ch) {
		case 'l':
			SetLinkerscriptName(optarg);
			break;
		case 'm':
			SetMapfileName(optarg);
			break;
		case 'n':
			SetSymfileName(optarg);
			break;
		case 'o':
			out_Setname(optarg);
			break;
		case 'O':
			out_SetOverlayname(optarg);
			options |= OPT_OVERLAY;
			break;
		case 'p':
			fillchar = strtoul(optarg, &ep, 0);
			if (optarg[0] == '\0' || *ep != '\0')
				errx(1, "Invalid argument for option 'p'");
			if (fillchar < 0 || fillchar > 0xFF)
				errx(1, "Argument for option 'p' must be between 0 and 0xFF");
			break;
		case 's':
			options |= OPT_SMART_C_LINK;
			smartlinkstartsymbol = optarg;
			break;
		case 't':
			options |= OPT_TINY;
			break;
		case 'd':
			/*
			 * Set to set WRAM as a single continuous block as on
			 * DMG. All WRAM sections must be WRAM0 as bankable WRAM
			 * sections do not exist in this mode. A WRAMX section
			 * will raise an error. VRAM bank 1 can't be used if
			 * this option is enabled either.
			 *
			 * This option implies OPT_CONTWRAM.
			 */
			options |= OPT_DMG_MODE;
			/* FALLTHROUGH */
		case 'w':
			/*
			 * Set to set WRAM as a single continuous block as on
			 * DMG. All WRAM sections must be WRAM0 as bankable WRAM
			 * sections do not exist in this mode. A WRAMX section
			 * will raise an error.
			 */
			options |= OPT_CONTWRAM;
			break;
		case 'V':
			printf("rgblink %s\n", get_package_version_string());
			exit(0);
		default:
			print_usage();
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

	if (argc == 0)
		print_usage();

	for (int32_t i = 0; i < argc; ++i)
		obj_Readfile(argv[i]);

	AddNeededModules();
	AssignSections();
	CreateSymbolTable();
	Patch();
	Output();
	CloseMapfile();

	return 0;
}
int	main( int argc, char *argv[] )
{
	SLONG	argn=0;

	argc-=1;
	argn+=1;

	if( argc==0 )
		PrintUsage();

	while( *argv[argn]=='-' )
	{
		char opt;
		argc-=1;
		switch( opt=argv[argn++][1] )
		{
			case '?':
			case 'h':
				PrintUsage();
				break;
			case 'm':
				SetMapfileName( argv[argn-1]+2 );
				break;
			case 'n':
				SetSymfileName( argv[argn-1]+2 );
				break;
			case 't':
				switch( opt=argv[argn-1][2] )
				{
					case 'g':
						outputtype=OUTPUT_GBROM;
						break;
					case 's':
						outputtype=OUTPUT_GBROM;
						options|=OPT_SMALL;
						break;
					case 'p':
						outputtype=OUTPUT_PSION2;
						break;
					default:
						sprintf( temptext, "Unknown option 't%c'\n", opt );
						fatalerror( temptext );
						break;
				}
				break;
			case 'z':
				if( strlen(argv[argn-1]+2)<=2 )
				{
					if( strcmp(argv[argn-1]+2,"?")==0 )
					{
						fillchar=-1;
					}
					else
					{
						int	result;

						result=sscanf( argv[argn-1]+2, "%x", &fillchar );
						if( !((result==EOF) || (result==1)) )
						{
							fatalerror("Invalid argument for option 'z'\n" );
						}
					}
				}
				else
				{
					fatalerror("Invalid argument for option 'z'\n" );
				}
				break;
			case 's':
				options|=OPT_SMART_C_LINK;
				strcpy( smartlinkstartsymbol, argv[argn-1]+2 );
				break;
			case 'i':
				g_identifyBanks = 1 ;
				break ;

			default:
				sprintf( temptext, "Unknown option '%c'\n", opt );
				fatalerror( temptext );
				break;
		}
	}

	if( argc==1 )
	{
		ProcessLinkfile( argv[argn++] );
		AddNeededModules();
		AssignSections();
		CreateSymbolTable();
		Patch();
		Output();
		CloseMapfile();
	}
	else
		PrintUsage();

	return( 0 );
}
Пример #4
0
int 
main(int argc, char *argv[])
{
	int ch;
	char *ep;

	if (argc == 1)
		usage();

	while ((ch = getopt(argc, argv, "l:m:n:o:p:s:t")) != -1) {
		switch (ch) {
		case 'l':
			lib_Readfile(optarg);
			break;
		case 'm':
			SetMapfileName(optarg);
			break;
		case 'n':
			SetSymfileName(optarg);
			break;
		case 'o':
			out_Setname(optarg);
			break;
		case 'p':
			fillchar = strtoul(optarg, &ep, 0);
			if (optarg[0] == '\0' || *ep != '\0') {
				fprintf(stderr, "Invalid argument for option 'p'\n");
				exit(1);
			}
			if (fillchar < 0 || fillchar > 0xFF) {
				fprintf(stderr, "Argument for option 'p' must be between 0 and 0xFF");
				exit(1);
			}
			break;
		case 's':
			options |= OPT_SMART_C_LINK;
			strcpy(smartlinkstartsymbol, optarg);
			break;
		case 't':
			options |= OPT_SMALL;
			break;
		default:
			usage();
			/* NOTREACHED */
		}
	}
	argc -= optind;
	argv += optind;

	if (argc == 0)
		usage();

	for (int i = 0; i < argc; ++i)
		obj_Readfile(argv[i]);

	AddNeededModules();
	AssignSections();
	CreateSymbolTable();
	Patch();
	Output();
	CloseMapfile();

	return (0);
}