- Added autolink libc.def and libtcc1;
- Fixed find crt0.o with arg -B (MUST BE REVISED);

git-svn-id: svn://kolibrios.org@9615 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-01-11 20:39:28 +00:00
parent 4afc0dd84b
commit b50d4e8c3f
3 changed files with 26 additions and 28 deletions

View File

@ -2279,6 +2279,9 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
case TCC_OPTION_B:
/* set tcc utilities path (mainly for tcc development) */
tcc_set_lib_path(s, optarg);
#ifdef TCC_TARGET_MEOS
tcc_split_path(s, (void ***)&s->crt_paths, &s->nb_crt_paths, CONFIG_TCC_CRTPREFIX);
#endif
break;
case TCC_OPTION_l:
args_parser_add_file(s, r, TCC_FILETYPE_BINARY);

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "libtcc.h"
#include "tcc.h"
/* Define this to get some debug output during relocation processing. */
@ -1618,17 +1619,21 @@ ST_FUNC void tcc_add_bcheck(TCCState *s1)
ST_FUNC void tcc_add_runtime(TCCState *s1)
{
tcc_add_pragma_libs(s1);
/* add libc */
if (!s1->nostdlib) {
#if !defined (TCC_TARGET_MEOS)
tcc_add_library(s1, "c");
#ifdef CONFIG_USE_LIBGCC
if (!s1->static_link) {
tcc_add_file(s1, TCC_LIBGCC, TCC_FILETYPE_BINARY);
}
#endif
#if !defined(TCC_TARGET_MEOS)
tcc_add_support(s1, "libtcc1.a");
#else
if (tcc_add_library_err(s1, "c") < 0 ||
tcc_add_library_err(s1, "tcc1") < 0) {
exit(1);
}
#endif
}
@ -1636,17 +1641,13 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
libtcc1.a must be loaded before for __bound_init to be defined and
crtn.o must be loaded after to not finalize _init too early. */
tcc_add_bcheck(s1);
#if !defined (TCC_TARGET_MEOS)
if (!s1->nostdlib) {
/* add crt end if not memory output */
if (s1->output_type != TCC_OUTPUT_MEMORY)
#if defined(TCC_TARGET_MEOS)
;
// tcc_add_crt(s1, "start.o");
#else
tcc_add_crt(s1, "crtn.o");
#endif
}
#endif
}
/* add various standard linker symbols (must be done after the

View File

@ -19,10 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TCC_TARGET_KX
int undef_sym_flag=0;
#endif
typedef struct {
char magic[8];
int version;
@ -130,8 +126,6 @@ void build_reloc(me_info* me)
int sym_index = find_elf_sym(me->s1->dynsymtab_section, sym_name);
Elf32_Sym* dyn_sym;
if (sym_index == 0) {
#else
undef_sym_flag=1;
#endif
tcc_error_noabort("undefined symbol '%s'", sym_name);
continue;
@ -302,13 +296,9 @@ int tcc_output_me(TCCState* s1,const char *filename)
#ifdef TCC_TARGET_KX
kx_init(&me);
#endif
tcc_add_runtime(s1);
relocate_common_syms();
assign_addresses(&me);
#ifndef TCC_TARGET_KX
if(undef_sym_flag){
tcc_error("Linker error!");
}
#endif
if (s1->do_debug)
tcc_output_dbgme(filename, &me);
@ -317,6 +307,10 @@ int tcc_output_me(TCCState* s1,const char *filename)
me.header.params= tcc_find_symbol_me(&me,"__argv"); // <--
me.header.argv= tcc_find_symbol_me(&me,"__path"); // <--
if (!me.header.entry_point || !me.header.params || me.header.argv) {
exit(1);
}
if((f=fopen(filename,"wb"))==NULL){
tcc_error("could not create '%s': %s", filename, strerror(errno));
}