Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/elftoolchain/elfcopy/main.c
Show First 20 Lines • Show All 1,011 Lines • ▼ Show 20 Lines | while ((opt = getopt_long(argc, argv, "dB:gG:I:j:K:L:N:O:pR:s:SwW:xXV", | ||||
case ECP_WEAKEN_SYMBOLS: | case ECP_WEAKEN_SYMBOLS: | ||||
parse_symlist_file(ecp, optarg, SYMOP_WEAKEN); | parse_symlist_file(ecp, optarg, SYMOP_WEAKEN); | ||||
break; | break; | ||||
default: | default: | ||||
elfcopy_usage(); | elfcopy_usage(); | ||||
} | } | ||||
} | } | ||||
if (optind == argc || optind + 2 < argc) | argc -= optind; | ||||
argv += optind; | |||||
if (argc == 0 || argc > 2) | |||||
elfcopy_usage(); | elfcopy_usage(); | ||||
infile = argv[optind]; | infile = argv[0]; | ||||
outfile = NULL; | outfile = NULL; | ||||
if (optind + 1 < argc) | if (argc > 1) | ||||
outfile = argv[optind + 1]; | outfile = argv[1]; | ||||
create_file(ecp, infile, outfile); | create_file(ecp, infile, outfile); | ||||
} | } | ||||
static void | static void | ||||
mcs_main(struct elfcopy *ecp, int argc, char **argv) | mcs_main(struct elfcopy *ecp, int argc, char **argv) | ||||
{ | { | ||||
struct sec_action *sac; | struct sec_action *sac; | ||||
Show All 27 Lines | case 'V': | ||||
print_version(); | print_version(); | ||||
break; | break; | ||||
case 'h': | case 'h': | ||||
default: | default: | ||||
mcs_usage(); | mcs_usage(); | ||||
} | } | ||||
} | } | ||||
if (optind == argc) | argc -= optind; | ||||
argv += optind; | |||||
if (argc == 0) | |||||
mcs_usage(); | mcs_usage(); | ||||
/* Must specify one operation at least. */ | /* Must specify one operation at least. */ | ||||
if (!append && !compress && !delete && !print) | if (!append && !compress && !delete && !print) | ||||
mcs_usage(); | mcs_usage(); | ||||
/* | /* | ||||
* If we are going to delete, ignore other operations. This is | * If we are going to delete, ignore other operations. This is | ||||
Show All 20 Lines | mcs_main(struct elfcopy *ecp, int argc, char **argv) | ||||
STAILQ_FOREACH(sac, &ecp->v_sac, sac_list) { | STAILQ_FOREACH(sac, &ecp->v_sac, sac_list) { | ||||
sac->append = append; | sac->append = append; | ||||
sac->compress = compress; | sac->compress = compress; | ||||
sac->print = print; | sac->print = print; | ||||
sac->remove = delete; | sac->remove = delete; | ||||
sac->string = string; | sac->string = string; | ||||
} | } | ||||
for (i = optind; i < argc; i++) { | for (i = 0; i < argc; i++) { | ||||
/* If only -p is specified, output to /dev/null */ | /* If only -p is specified, output to /dev/null */ | ||||
if (print && !append && !compress && !delete) | if (print && !append && !compress && !delete) | ||||
create_file(ecp, argv[i], "/dev/null"); | create_file(ecp, argv[i], "/dev/null"); | ||||
else | else | ||||
create_file(ecp, argv[i], NULL); | create_file(ecp, argv[i], NULL); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | case ECP_STRIP_UNNEEDED: | ||||
ecp->strip = STRIP_UNNEEDED; | ecp->strip = STRIP_UNNEEDED; | ||||
break; | break; | ||||
case 'h': | case 'h': | ||||
default: | default: | ||||
strip_usage(); | strip_usage(); | ||||
} | } | ||||
} | } | ||||
argc -= optind; | |||||
argv += optind; | |||||
if (ecp->strip == 0 && | if (ecp->strip == 0 && | ||||
((ecp->flags & DISCARD_LOCAL) == 0) && | ((ecp->flags & DISCARD_LOCAL) == 0) && | ||||
((ecp->flags & DISCARD_LLABEL) == 0) && | ((ecp->flags & DISCARD_LLABEL) == 0) && | ||||
lookup_symop_list(ecp, NULL, SYMOP_STRIP) == NULL) | lookup_symop_list(ecp, NULL, SYMOP_STRIP) == NULL) | ||||
ecp->strip = STRIP_ALL; | ecp->strip = STRIP_ALL; | ||||
if (optind == argc) | if (argc == 0) | ||||
strip_usage(); | strip_usage(); | ||||
/* | /* | ||||
* Only accept a single input file if an output file had been | * Only accept a single input file if an output file had been | ||||
* specified. | * specified. | ||||
*/ | */ | ||||
if (outfile != NULL && argc != (optind + 1)) | if (outfile != NULL && argc != 1) | ||||
strip_usage(); | strip_usage(); | ||||
for (i = optind; i < argc; i++) | for (i = 0; i < argc; i++) | ||||
create_file(ecp, argv[i], outfile); | create_file(ecp, argv[i], outfile); | ||||
} | } | ||||
static void | static void | ||||
parse_sec_flags(struct sec_action *sac, char *s) | parse_sec_flags(struct sec_action *sac, char *s) | ||||
{ | { | ||||
const char *flag; | const char *flag; | ||||
int found, i; | int found, i; | ||||
▲ Show 20 Lines • Show All 405 Lines • Show Last 20 Lines |