mirror of
https://github.com/frida/tinycc
synced 2024-12-24 14:06:48 +03:00
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 19a169ceb8
.
This commit is contained in:
parent
e238e6521b
commit
cf32bb8812
14
libtcc.c
14
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);
|
||||
|
2
libtcc.h
2
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);
|
||||
|
@ -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
|
||||
|
18
tcc.c
18
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) {
|
||||
|
1
tcc.h
1
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) */
|
||||
|
3
tccelf.c
3
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);
|
||||
|
Loading…
Reference in New Issue
Block a user