mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-04 06:30:10 +08:00
handle a -s option by executing sstrip/strip program
This commit is contained in:
parent
089ce6235c
commit
5cd4393a54
4
libtcc.c
4
libtcc.c
@ -1967,10 +1967,12 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv)
|
||||
case TCC_OPTION_dumpversion:
|
||||
printf ("%s\n", TCC_VERSION);
|
||||
exit(0);
|
||||
case TCC_OPTION_s:
|
||||
s->do_strip = 1;
|
||||
break;
|
||||
case TCC_OPTION_O:
|
||||
case TCC_OPTION_pedantic:
|
||||
case TCC_OPTION_pipe:
|
||||
case TCC_OPTION_s:
|
||||
case TCC_OPTION_x:
|
||||
/* ignored */
|
||||
break;
|
||||
|
1
tcc.h
1
tcc.h
@ -613,6 +613,7 @@ struct TCCState {
|
||||
|
||||
/* compile with debug symbol (and use them if error during execution) */
|
||||
int do_debug;
|
||||
int do_strip;
|
||||
#ifdef CONFIG_TCC_BCHECK
|
||||
/* compile with built-in memory and bounds checker */
|
||||
int do_bounds_check;
|
||||
|
14
tccelf.c
14
tccelf.c
@ -2689,6 +2689,20 @@ static int elf_output_file(TCCState *s1, const char *filename)
|
||||
|
||||
/* Create the ELF file with name 'filename' */
|
||||
ret = tcc_write_elf_file(s1, filename, phnum, phdr, file_offset, sec_order);
|
||||
if (s1->do_strip) {
|
||||
const char *strip = "sstrip "; // super strip utility from ELFkickers
|
||||
const char *null = " 2> /dev/null";
|
||||
int len = strlen(strip) + strlen(filename) + strlen(null) + 1;
|
||||
{
|
||||
int rc;
|
||||
char buf[len];
|
||||
sprintf(buf, "%s%s%s", strip, filename, null);
|
||||
rc = system(buf);
|
||||
if (rc) {
|
||||
system(buf+1); // call a strip utility from binutils
|
||||
}
|
||||
}
|
||||
}
|
||||
the_end:
|
||||
tcc_free(s1->symtab_to_dynsym);
|
||||
tcc_free(sec_order);
|
||||
|
Loading…
Reference in New Issue
Block a user