Unified · Split
| @@ -1967,10 +1967,12 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 1966 unmodified lines | |||
| 1967 | case TCC_OPTION_dumpversion: | 1967 | case TCC_OPTION_dumpversion: |
| 1968 | printf ("%s\n", TCC_VERSION); | 1968 | printf ("%s\n", TCC_VERSION); |
| 1969 | exit(0); | 1969 | exit(0); |
| 1970 | case TCC_OPTION_s: | ||
| 1971 | s->do_strip = 1; | ||
| 1972 | break; | ||
| 1970 | case TCC_OPTION_O: | 1973 | case TCC_OPTION_O: |
| 1971 | case TCC_OPTION_pedantic: | 1974 | case TCC_OPTION_pedantic: |
| 1972 | case TCC_OPTION_pipe: | 1975 | case TCC_OPTION_pipe: |
| 1973 | case TCC_OPTION_s: | ||
| 1974 | case TCC_OPTION_x: | 1976 | case TCC_OPTION_x: |
| 1975 | /* ignored */ | 1977 | /* ignored */ |
| 1976 | break; | 1978 | break; |
| @@ -613,6 +613,7 @@ struct TCCState { · 612 unmodified lines | |||
| 613 | 613 | ||
| 614 | /* compile with debug symbol (and use them if error during execution) */ | 614 | /* compile with debug symbol (and use them if error during execution) */ |
| 615 | int do_debug; | 615 | int do_debug; |
| 616 | int do_strip; | ||
| 616 | #ifdef CONFIG_TCC_BCHECK | 617 | #ifdef CONFIG_TCC_BCHECK |
| 617 | /* compile with built-in memory and bounds checker */ | 618 | /* compile with built-in memory and bounds checker */ |
| 618 | int do_bounds_check; | 619 | int do_bounds_check; |
| @@ -2689,6 +2689,20 @@ static int elf_output_file(TCCState *s1, const char *filename) · 2688 unmodified lines | |||
| 2689 | 2689 | ||
| 2690 | /* Create the ELF file with name 'filename' */ | 2690 | /* Create the ELF file with name 'filename' */ |
| 2691 | ret = tcc_write_elf_file(s1, filename, phnum, phdr, file_offset, sec_order); | 2691 | ret = tcc_write_elf_file(s1, filename, phnum, phdr, file_offset, sec_order); |
| 2692 | if (s1->do_strip) { | ||
| 2693 | const char *strip = "sstrip "; // super strip utility from ELFkickers | ||
| 2694 | const char *null = " 2> /dev/null"; | ||
| 2695 | int len = strlen(strip) + strlen(filename) + strlen(null) + 1; | ||
| 2696 | { | ||
| 2697 | int rc; | ||
| 2698 | char buf[len]; | ||
| 2699 | sprintf(buf, "%s%s%s", strip, filename, null); | ||
| 2700 | rc = system(buf); | ||
| 2701 | if (rc) { | ||
| 2702 | system(buf+1); // call a strip utility from binutils | ||
| 2703 | } | ||
| 2704 | } | ||
| 2705 | } | ||
| 2692 | the_end: | 2706 | the_end: |
| 2693 | tcc_free(s1->symtab_to_dynsym); | 2707 | tcc_free(s1->symtab_to_dynsym); |
| 2694 | tcc_free(sec_order); | 2708 | tcc_free(sec_order); |