From cf32bb8812583583f526ee0faf8c8f7d7799210c Mon Sep 17 00:00:00 2001 From: grischka Date: Sat, 1 Oct 2016 19:56:25 +0200 Subject: [PATCH] Revert "--whole-archive support" - would parse linker args in two different places - would mess up "tcc -v ..." output: tcc -v test.c -> test.c +> test.c - would use function "tcc_load_alacarte()" to do the contrary of what its name suggests. This reverts commit 19a169ceb896f78205bc23b847938c58f14d1dda. --- libtcc.c | 14 +------------- libtcc.h | 2 -- tcc-doc.texi | 8 -------- tcc.c | 18 ++---------------- tcc.h | 1 - tccelf.c | 3 --- 6 files changed, 3 insertions(+), 43 deletions(-) diff --git a/libtcc.c b/libtcc.c index d631a430..de8b1f64 100644 --- a/libtcc.c +++ b/libtcc.c @@ -1419,11 +1419,9 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags, ret = tcc_load_ldscript(s1); #endif if (ret < 0) - tcc_error_noabort("%s: unrecognized file type (error=%d)", filename, ret); + tcc_error_noabort("unrecognized file type"); the_end: - if (s1->verbose) - printf("+> %s\n", filename); tcc_close(); return ret; } @@ -2321,16 +2319,6 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv) s->rdynamic = 1; break; case TCC_OPTION_Wl: - if (optarg && *optarg == '-') { - int offs = 0; - if (!strncmp("-no", optarg+1, 3)) - offs += 3; - if (!strcmp("-whole-archive", optarg+1 + offs)) { - args_parser_add_file(s, "", (offs == 0) ? TCC_FILETYPE_AR_WHOLE_ON : - TCC_FILETYPE_AR_WHOLE_OFF); - break; - } - } if (pas->linker_arg.size) --pas->linker_arg.size, cstr_ccat(&pas->linker_arg, ','); cstr_cat(&pas->linker_arg, optarg, 0); diff --git a/libtcc.h b/libtcc.h index 8f39d195..97b85872 100644 --- a/libtcc.h +++ b/libtcc.h @@ -53,8 +53,6 @@ LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename, int filetype); #define TCC_FILETYPE_C 2 #define TCC_FILETYPE_ASM 3 #define TCC_FILETYPE_ASM_PP 4 -#define TCC_FILETYPE_AR_WHOLE_OFF 5 -#define TCC_FILETYPE_AR_WHOLE_ON 6 /* compile a string containing a C source. Return -1 if error. */ LIBTCCAPI int tcc_compile_string(TCCState *s, const char *buf); diff --git a/tcc-doc.texi b/tcc-doc.texi index fb7a79b6..1dc6f80a 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -317,14 +317,6 @@ Generate an object file combining all input files. @item -Wl,-rpath=path Put custom search path for dynamic libraries into executable. -@item -Wl,--whole-archive -Add a whole archive, not just the symbols of the archive that would -satisfy undefined symbols in the program. - -@item -Wl,--no-whole-archive -Turn off the effect of the --whole-archive option for subsequent archive -files. - @item -Wl,--oformat=fmt Use @var{fmt} as output format. The supported output formats are: @table @code diff --git a/tcc.c b/tcc.c index 5e0a64a1..b340d9bd 100644 --- a/tcc.c +++ b/tcc.c @@ -247,13 +247,6 @@ static int64_t getclock_us(void) #endif } -static void set_whole_archive(TCCState* s, int on) -{ - s->whole_archive = on; - if (1 == s->verbose) - printf("%cwhole-archive>\n", s->whole_archive? '+' : '-'); -} - int main(int argc, char **argv) { TCCState *s; @@ -308,14 +301,6 @@ int main(int argc, char **argv) for(i = ret = 0; i < s->nb_files && ret == 0; i++) { int filetype = *(unsigned char *)s->files[i]; const char *filename = s->files[i] + 1; - if (filetype == TCC_FILETYPE_AR_WHOLE_ON || - filetype == TCC_FILETYPE_AR_WHOLE_OFF) - { - set_whole_archive(s, filetype == TCC_FILETYPE_AR_WHOLE_ON); - continue; - } - if (1 == s->verbose) - printf("-> %s\n", filename); if (filename[0] == '-' && filename[1] == 'l') { if (tcc_add_library(s, filename + 2) < 0) { /* don't fail on -lm as it's harmless to skip math lib */ @@ -325,6 +310,8 @@ int main(int argc, char **argv) } } } else { + if (1 == s->verbose) + printf("-> %s\n", filename); if (!s->outfile) s->outfile = default_outputfile(s, filename); if (tcc_add_file(s, filename, filetype) < 0) @@ -348,7 +335,6 @@ int main(int argc, char **argv) } } } - set_whole_archive(s, 0); if (0 == ret) { if (s->output_type == TCC_OUTPUT_MEMORY) { diff --git a/tcc.h b/tcc.h index 9b292ebd..f14c8842 100644 --- a/tcc.h +++ b/tcc.h @@ -692,7 +692,6 @@ struct TCCState { int rdynamic; /* if true, all symbols are exported */ int symbolic; /* if true, resolve symbols in the current module first */ int alacarte_link; /* if true, only link in referenced objects from archive */ - int whole_archive; /* if true, link in a whole *.a even when alacarte_link */ char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */ char *soname; /* as specified on the command line (-soname) */ diff --git a/tccelf.c b/tccelf.c index ace75be3..c4f08334 100644 --- a/tccelf.c +++ b/tccelf.c @@ -3076,7 +3076,6 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) if(sym_index) { sym = &((ElfW(Sym) *)symtab_section->data)[sym_index]; if(sym->st_shndx == SHN_UNDEF) { - load_obj: off = get_be32(ar_index + i * 4) + sizeof(ArchiveHeader); ++bound; lseek(fd, off, SEEK_SET); @@ -3086,8 +3085,6 @@ static int tcc_load_alacarte(TCCState *s1, int fd, int size) goto the_end; } } - } else if (s1->whole_archive) { - goto load_obj; } } } while(bound);