@@ -217,6 +217,8 @@ extern long double strtold (const char *__nptr, char **__endptr);
217
217
218
218
#if defined TCC_TARGET_PE || defined TCC_TARGET_MACHO
219
219
# define ELF_OBJ_ONLY /* create elf .o but native executables */
220
+ #else
221
+ # define TCC_TARGET_UNIX 1
220
222
#endif
221
223
222
224
/* No ten-byte long doubles on window and macos except in
@@ -919,8 +921,6 @@ struct TCCState {
919
921
/* debug state */
920
922
struct _tccdbg * dState ;
921
923
922
- /* Is there a new undefined sym since last new_undef_sym() */
923
- int new_undef_sym ;
924
924
/* extra attributes (eg. GOT/PLT value) for symtab symbols */
925
925
struct sym_attr * sym_attrs ;
926
926
int nb_sym_attrs ;
@@ -988,7 +988,7 @@ struct TCCState {
988
988
unsigned int total_output [4 ];
989
989
990
990
/* used by tcc_load_ldscript */
991
- int fd , cc ;
991
+ unsigned char * ld_p ; /* text pointer */
992
992
993
993
/* for warnings/errors for object files */
994
994
const char * current_filename ;
@@ -1001,7 +1001,9 @@ struct TCCState {
1001
1001
char * deps_outfile ; /* option -MF */
1002
1002
int argc ;
1003
1003
char * * argv ;
1004
- CString linker_arg ; /* collect -Wl options */
1004
+ /* -Wl options */
1005
+ char * * link_argv ;
1006
+ int link_argc , link_optind ;
1005
1007
};
1006
1008
1007
1009
struct filespec {
@@ -1195,7 +1197,7 @@ ST_DATA int g_debug;
1195
1197
/* public functions currently used by the tcc main function */
1196
1198
ST_FUNC char * pstrcpy (char * buf , size_t buf_size , const char * s );
1197
1199
ST_FUNC char * pstrcat (char * buf , size_t buf_size , const char * s );
1198
- ST_FUNC char * pstrncpy (char * out , const char * in , size_t num );
1200
+ ST_FUNC char * pstrncpy (char * out , size_t buf_size , const char * s , size_t num );
1199
1201
PUB_FUNC char * tcc_basename (const char * name );
1200
1202
PUB_FUNC char * tcc_fileextension (const char * name );
1201
1203
@@ -1265,7 +1267,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
1265
1267
#define AFF_TYPE_ASM 2
1266
1268
#define AFF_TYPE_ASMPP 4
1267
1269
#define AFF_TYPE_LIB 8
1268
- #define AFF_TYPE_MASK (15 | AFF_TYPE_BIN)
1270
+ #define AFF_TYPE_MASK (7 | AFF_TYPE_BIN)
1269
1271
/* values from tcc_object_type(...) */
1270
1272
#define AFF_BINTYPE_REL 1
1271
1273
#define AFF_BINTYPE_DYN 2
@@ -1274,6 +1276,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags)
1274
1276
1275
1277
/* return value of tcc_add_file_internal(): 0, -1, or FILE_NOT_FOUND */
1276
1278
#define FILE_NOT_FOUND -2
1279
+ #define FILE_NOT_RECOGNIZED -3 /* unrecognized file type */
1277
1280
1278
1281
#ifndef ELF_OBJ_ONLY
1279
1282
ST_FUNC int tcc_add_crt (TCCState * s , const char * filename );
@@ -1289,7 +1292,7 @@ ST_FUNC void tcc_add_btstub(TCCState *s1);
1289
1292
ST_FUNC void tcc_add_pragma_libs (TCCState * s1 );
1290
1293
PUB_FUNC int tcc_add_library_err (TCCState * s , const char * f );
1291
1294
PUB_FUNC void tcc_print_stats (TCCState * s , unsigned total_time );
1292
- PUB_FUNC int tcc_parse_args (TCCState * s , int * argc , char * * * argv , int optind );
1295
+ PUB_FUNC int tcc_parse_args (TCCState * s , int * argc , char * * * argv );
1293
1296
#ifdef _WIN32
1294
1297
ST_FUNC char * normalize_slashes (char * path );
1295
1298
#endif
@@ -1571,7 +1574,7 @@ ST_FUNC void tcc_add_runtime(TCCState *s1);
1571
1574
1572
1575
/* ------------ xxx-link.c ------------ */
1573
1576
1574
- #if !defined ELF_OBJ_ONLY || defined TCC_TARGET_MACHO
1577
+ #ifndef TCC_TARGET_PE
1575
1578
ST_FUNC int code_reloc (int reloc_type );
1576
1579
ST_FUNC int gotplt_entry_type (int reloc_type );
1577
1580
/* Whether to generate a GOT/PLT entry and when. NO_GOTPLT_ENTRY is first so
@@ -1583,13 +1586,11 @@ enum gotplt_entry {
1583
1586
ALWAYS_GOTPLT_ENTRY /* always generate (eg. PLTOFF relocs) */
1584
1587
};
1585
1588
#define NEED_RELOC_TYPE
1586
-
1587
1589
#if !defined TCC_TARGET_MACHO || defined TCC_IS_NATIVE
1588
1590
ST_FUNC unsigned create_plt_entry (TCCState * s1 , unsigned got_offset , struct sym_attr * attr );
1589
1591
ST_FUNC void relocate_plt (TCCState * s1 );
1590
1592
ST_FUNC void build_got_entries (TCCState * s1 , int got_sym ); /* in tccelf.c */
1591
1593
#define NEED_BUILD_GOT
1592
-
1593
1594
#endif
1594
1595
#endif
1595
1596
@@ -1809,7 +1810,7 @@ ST_FUNC int macho_load_dll(TCCState *s1, int fd, const char *filename, int lev);
1809
1810
ST_FUNC int macho_load_tbd (TCCState * s1 , int fd , const char * filename , int lev );
1810
1811
#ifdef TCC_IS_NATIVE
1811
1812
ST_FUNC void tcc_add_macos_sdkpath (TCCState * s );
1812
- ST_FUNC const char * macho_tbd_soname (const char * filename );
1813
+ ST_FUNC char * macho_tbd_soname (int fd );
1813
1814
#endif
1814
1815
#endif
1815
1816
/* ------------ tccrun.c ----------------- */
0 commit comments