History

handle a -s option by executing sstrip/strip program

seyko committed 11 years ago

Commit 5cd43931 parent 089ce623 files · +18 −1Browse files

Unified · Split

3 files
  1. libtcc.c +3 −1
  2. tcc.h +1 −0
  3. tccelf.c +14 −0
libtcc.c+3−1
@@ -1967,10 +1967,12 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 1966 unmodified lines
19671967 case TCC_OPTION_dumpversion:
19681968 printf ("%s\n", TCC_VERSION);
19691969 exit(0);
1970+ case TCC_OPTION_s:
1971+ s->do_strip = 1;
1972+ break;
19701973 case TCC_OPTION_O:
19711974 case TCC_OPTION_pedantic:
19721975 case TCC_OPTION_pipe:
1973− case TCC_OPTION_s:
19741976 case TCC_OPTION_x:
19751977 /* ignored */
19761978 break;
tcc.h+1−0
@@ -613,6 +613,7 @@ struct TCCState { · 612 unmodified lines
613613
614614 /* compile with debug symbol (and use them if error during execution) */
615615 int do_debug;
616+ int do_strip;
616617 #ifdef CONFIG_TCC_BCHECK
617618 /* compile with built-in memory and bounds checker */
618619 int do_bounds_check;
tccelf.c+14−0
@@ -2689,6 +2689,20 @@ static int elf_output_file(TCCState *s1, const char *filename) · 2688 unmodified lines
26892689
26902690 /* Create the ELF file with name 'filename' */
26912691 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+ }
26922706 the_end:
26932707 tcc_free(s1->symtab_to_dynsym);
26942708 tcc_free(sec_order);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t