forked from KolibriOS/kolibrios
ktcc:
- 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:
parent
4afc0dd84b
commit
b50d4e8c3f
@ -113,7 +113,7 @@ static void tcc_set_lib_path_w32(TCCState *s)
|
|||||||
{
|
{
|
||||||
char path[1024], *p;
|
char path[1024], *p;
|
||||||
GetModuleFileNameA(tcc_module, path, sizeof path);
|
GetModuleFileNameA(tcc_module, path, sizeof path);
|
||||||
#ifdef TCC_TARGET_KX
|
#ifdef TCC_TARGET_KX
|
||||||
kx_fix_root_directory(path, sizeof path);
|
kx_fix_root_directory(path, sizeof path);
|
||||||
normalize_slashes(strlwr(path));
|
normalize_slashes(strlwr(path));
|
||||||
#else
|
#else
|
||||||
@ -155,13 +155,13 @@ BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
|
|||||||
#if defined TCC_TARGET_MEOS
|
#if defined TCC_TARGET_MEOS
|
||||||
/* on Kolibri host, we suppose the lib and includes are at the location of 'tcc' /lib, /include */
|
/* on Kolibri host, we suppose the lib and includes are at the location of 'tcc' /lib, /include */
|
||||||
static void tcc_set_lib_path_kos(TCCState *s)
|
static void tcc_set_lib_path_kos(TCCState *s)
|
||||||
{
|
{
|
||||||
char** argv0 = (char**)0x20; // path in kolibri header
|
char** argv0 = (char**)0x20; // path in kolibri header
|
||||||
char path[1024], *p;
|
char path[1024], *p;
|
||||||
strncpy(path, *argv0, sizeof path);
|
strncpy(path, *argv0, sizeof path);
|
||||||
#ifdef TCC_TARGET_KX
|
#ifdef TCC_TARGET_KX
|
||||||
kx_fix_root_directory(path, sizeof path);
|
kx_fix_root_directory(path, sizeof path);
|
||||||
#else
|
#else
|
||||||
p = tcc_basename(path);
|
p = tcc_basename(path);
|
||||||
if (p > path) p--;
|
if (p > path) p--;
|
||||||
*p = 0;
|
*p = 0;
|
||||||
@ -174,8 +174,8 @@ static void tcc_set_lib_path_linux(TCCState *s)
|
|||||||
{
|
{
|
||||||
char buff[4096+1];
|
char buff[4096+1];
|
||||||
readlink("/proc/self/exe", buff, 4096);
|
readlink("/proc/self/exe", buff, 4096);
|
||||||
#ifdef TCC_TARGET_KX
|
#ifdef TCC_TARGET_KX
|
||||||
kx_fix_root_directory(buff, sizeof buff);
|
kx_fix_root_directory(buff, sizeof buff);
|
||||||
const char *path = buff;
|
const char *path = buff;
|
||||||
#else
|
#else
|
||||||
const char *path = dirname(buff);
|
const char *path = dirname(buff);
|
||||||
@ -2279,6 +2279,9 @@ ST_FUNC int tcc_parse_args1(TCCState *s, int argc, char **argv)
|
|||||||
case TCC_OPTION_B:
|
case TCC_OPTION_B:
|
||||||
/* set tcc utilities path (mainly for tcc development) */
|
/* set tcc utilities path (mainly for tcc development) */
|
||||||
tcc_set_lib_path(s, optarg);
|
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;
|
break;
|
||||||
case TCC_OPTION_l:
|
case TCC_OPTION_l:
|
||||||
args_parser_add_file(s, r, TCC_FILETYPE_BINARY);
|
args_parser_add_file(s, r, TCC_FILETYPE_BINARY);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "libtcc.h"
|
||||||
#include "tcc.h"
|
#include "tcc.h"
|
||||||
|
|
||||||
/* Define this to get some debug output during relocation processing. */
|
/* 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)
|
ST_FUNC void tcc_add_runtime(TCCState *s1)
|
||||||
{
|
{
|
||||||
tcc_add_pragma_libs(s1);
|
tcc_add_pragma_libs(s1);
|
||||||
|
|
||||||
/* add libc */
|
/* add libc */
|
||||||
if (!s1->nostdlib) {
|
if (!s1->nostdlib) {
|
||||||
|
#if !defined (TCC_TARGET_MEOS)
|
||||||
tcc_add_library(s1, "c");
|
tcc_add_library(s1, "c");
|
||||||
#ifdef CONFIG_USE_LIBGCC
|
#ifdef CONFIG_USE_LIBGCC
|
||||||
if (!s1->static_link) {
|
if (!s1->static_link) {
|
||||||
tcc_add_file(s1, TCC_LIBGCC, TCC_FILETYPE_BINARY);
|
tcc_add_file(s1, TCC_LIBGCC, TCC_FILETYPE_BINARY);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(TCC_TARGET_MEOS)
|
|
||||||
tcc_add_support(s1, "libtcc1.a");
|
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
|
#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
|
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. */
|
crtn.o must be loaded after to not finalize _init too early. */
|
||||||
tcc_add_bcheck(s1);
|
tcc_add_bcheck(s1);
|
||||||
|
#if !defined (TCC_TARGET_MEOS)
|
||||||
if (!s1->nostdlib) {
|
if (!s1->nostdlib) {
|
||||||
/* add crt end if not memory output */
|
/* add crt end if not memory output */
|
||||||
if (s1->output_type != TCC_OUTPUT_MEMORY)
|
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");
|
tcc_add_crt(s1, "crtn.o");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add various standard linker symbols (must be done after the
|
/* add various standard linker symbols (must be done after the
|
||||||
|
@ -19,10 +19,6 @@
|
|||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TCC_TARGET_KX
|
|
||||||
int undef_sym_flag=0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char magic[8];
|
char magic[8];
|
||||||
int version;
|
int version;
|
||||||
@ -130,8 +126,6 @@ void build_reloc(me_info* me)
|
|||||||
int sym_index = find_elf_sym(me->s1->dynsymtab_section, sym_name);
|
int sym_index = find_elf_sym(me->s1->dynsymtab_section, sym_name);
|
||||||
Elf32_Sym* dyn_sym;
|
Elf32_Sym* dyn_sym;
|
||||||
if (sym_index == 0) {
|
if (sym_index == 0) {
|
||||||
#else
|
|
||||||
undef_sym_flag=1;
|
|
||||||
#endif
|
#endif
|
||||||
tcc_error_noabort("undefined symbol '%s'", sym_name);
|
tcc_error_noabort("undefined symbol '%s'", sym_name);
|
||||||
continue;
|
continue;
|
||||||
@ -302,13 +296,9 @@ int tcc_output_me(TCCState* s1,const char *filename)
|
|||||||
#ifdef TCC_TARGET_KX
|
#ifdef TCC_TARGET_KX
|
||||||
kx_init(&me);
|
kx_init(&me);
|
||||||
#endif
|
#endif
|
||||||
|
tcc_add_runtime(s1);
|
||||||
relocate_common_syms();
|
relocate_common_syms();
|
||||||
assign_addresses(&me);
|
assign_addresses(&me);
|
||||||
#ifndef TCC_TARGET_KX
|
|
||||||
if(undef_sym_flag){
|
|
||||||
tcc_error("Linker error!");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (s1->do_debug)
|
if (s1->do_debug)
|
||||||
tcc_output_dbgme(filename, &me);
|
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.params= tcc_find_symbol_me(&me,"__argv"); // <--
|
||||||
me.header.argv= tcc_find_symbol_me(&me,"__path"); // <--
|
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){
|
if((f=fopen(filename,"wb"))==NULL){
|
||||||
tcc_error("could not create '%s': %s", filename, strerror(errno));
|
tcc_error("could not create '%s': %s", filename, strerror(errno));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user