Unified · Split
| @@ -1967,10 +1967,12 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 1966 unmodified lines | ||
| 1967 | 1967 | case TCC_OPTION_dumpversion: |
| 1968 | 1968 | printf ("%s\n", TCC_VERSION); |
| 1969 | 1969 | exit(0); |
| 1970 | + case TCC_OPTION_s: | |
| 1971 | + s->do_strip = 1; | |
| 1972 | + break; | |
| 1970 | 1973 | case TCC_OPTION_O: |
| 1971 | 1974 | case TCC_OPTION_pedantic: |
| 1972 | 1975 | case TCC_OPTION_pipe: |
| 1973 | − case TCC_OPTION_s: | |
| 1974 | 1976 | case TCC_OPTION_x: |
| 1975 | 1977 | /* ignored */ |
| 1976 | 1978 | break; |
| @@ -613,6 +613,7 @@ struct TCCState { · 612 unmodified lines | ||
| 613 | 613 | |
| 614 | 614 | /* compile with debug symbol (and use them if error during execution) */ |
| 615 | 615 | int do_debug; |
| 616 | + int do_strip; | |
| 616 | 617 | #ifdef CONFIG_TCC_BCHECK |
| 617 | 618 | /* compile with built-in memory and bounds checker */ |
| 618 | 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 | 2690 | /* Create the ELF file with name 'filename' */ |
| 2691 | 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 | 2706 | the_end: |
| 2693 | 2707 | tcc_free(s1->symtab_to_dynsym); |
| 2694 | 2708 | tcc_free(sec_order); |