mirror of
https://github.com/frida/tinycc
synced 2024-11-28 02:29:38 +03:00
Add -soname linker option (Marc Andre Tanner)
This commit is contained in:
parent
88b3cb570e
commit
9bcc0b970b
13
tcc.c
13
tcc.c
@ -476,6 +476,9 @@ struct TCCState {
|
|||||||
/* if true, static linking is performed */
|
/* if true, static linking is performed */
|
||||||
int static_link;
|
int static_link;
|
||||||
|
|
||||||
|
/* soname as specified on the command line (-soname) */
|
||||||
|
const char *soname;
|
||||||
|
|
||||||
/* if true, all symbols are exported */
|
/* if true, all symbols are exported */
|
||||||
int rdynamic;
|
int rdynamic;
|
||||||
|
|
||||||
@ -10560,8 +10563,8 @@ void help(void)
|
|||||||
{
|
{
|
||||||
printf("tcc version " TCC_VERSION " - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\n"
|
printf("tcc version " TCC_VERSION " - Tiny C Compiler - Copyright (C) 2001-2006 Fabrice Bellard\n"
|
||||||
"usage: tcc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n"
|
"usage: tcc [-v] [-c] [-o outfile] [-Bdir] [-bench] [-Idir] [-Dsym[=val]] [-Usym]\n"
|
||||||
" [-Wwarn] [-g] [-b] [-bt N] [-Ldir] [-llib] [-shared] [-static]\n"
|
" [-Wwarn] [-g] [-b] [-bt N] [-Ldir] [-llib] [-shared] [-soname name]\n"
|
||||||
" [infile1 infile2...] [-run infile args...]\n"
|
" [-static] [infile1 infile2...] [-run infile args...]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"General options:\n"
|
"General options:\n"
|
||||||
" -v display current version\n"
|
" -v display current version\n"
|
||||||
@ -10582,6 +10585,7 @@ void help(void)
|
|||||||
" -Ldir add library path 'dir'\n"
|
" -Ldir add library path 'dir'\n"
|
||||||
" -llib link with dynamic or static library 'lib'\n"
|
" -llib link with dynamic or static library 'lib'\n"
|
||||||
" -shared generate a shared library\n"
|
" -shared generate a shared library\n"
|
||||||
|
" -soname set name for shared library to be used at runtime\n"
|
||||||
" -static static linking\n"
|
" -static static linking\n"
|
||||||
" -rdynamic export all global symbols to dynamic linker\n"
|
" -rdynamic export all global symbols to dynamic linker\n"
|
||||||
" -r generate (relocatable) object file\n"
|
" -r generate (relocatable) object file\n"
|
||||||
@ -10618,6 +10622,7 @@ enum {
|
|||||||
TCC_OPTION_c,
|
TCC_OPTION_c,
|
||||||
TCC_OPTION_static,
|
TCC_OPTION_static,
|
||||||
TCC_OPTION_shared,
|
TCC_OPTION_shared,
|
||||||
|
TCC_OPTION_soname,
|
||||||
TCC_OPTION_o,
|
TCC_OPTION_o,
|
||||||
TCC_OPTION_r,
|
TCC_OPTION_r,
|
||||||
TCC_OPTION_Wl,
|
TCC_OPTION_Wl,
|
||||||
@ -10654,6 +10659,7 @@ static const TCCOption tcc_options[] = {
|
|||||||
{ "c", TCC_OPTION_c, 0 },
|
{ "c", TCC_OPTION_c, 0 },
|
||||||
{ "static", TCC_OPTION_static, 0 },
|
{ "static", TCC_OPTION_static, 0 },
|
||||||
{ "shared", TCC_OPTION_shared, 0 },
|
{ "shared", TCC_OPTION_shared, 0 },
|
||||||
|
{ "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
|
||||||
{ "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
|
{ "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
|
||||||
{ "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
{ "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||||
{ "rdynamic", TCC_OPTION_rdynamic, 0 },
|
{ "rdynamic", TCC_OPTION_rdynamic, 0 },
|
||||||
@ -10825,6 +10831,9 @@ int parse_args(TCCState *s, int argc, char **argv)
|
|||||||
case TCC_OPTION_shared:
|
case TCC_OPTION_shared:
|
||||||
output_type = TCC_OUTPUT_DLL;
|
output_type = TCC_OUTPUT_DLL;
|
||||||
break;
|
break;
|
||||||
|
case TCC_OPTION_soname:
|
||||||
|
s->soname = optarg;
|
||||||
|
break;
|
||||||
case TCC_OPTION_o:
|
case TCC_OPTION_o:
|
||||||
multiple_files = 1;
|
multiple_files = 1;
|
||||||
outfile = optarg;
|
outfile = optarg;
|
||||||
|
61
tccelf.c
61
tccelf.c
@ -1314,8 +1314,11 @@ int tcc_output_file(TCCState *s1, const char *filename)
|
|||||||
}
|
}
|
||||||
/* XXX: currently, since we do not handle PIC code, we
|
/* XXX: currently, since we do not handle PIC code, we
|
||||||
must relocate the readonly segments */
|
must relocate the readonly segments */
|
||||||
if (file_type == TCC_OUTPUT_DLL)
|
if (file_type == TCC_OUTPUT_DLL) {
|
||||||
|
if (s1->soname)
|
||||||
|
put_dt(dynamic, DT_SONAME, put_elf_str(dynstr, s1->soname));
|
||||||
put_dt(dynamic, DT_TEXTREL, 0);
|
put_dt(dynamic, DT_TEXTREL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* add necessary space for other entries */
|
/* add necessary space for other entries */
|
||||||
saved_dynamic_data_offset = dynamic->data_offset;
|
saved_dynamic_data_offset = dynamic->data_offset;
|
||||||
@ -2286,8 +2289,60 @@ static int ld_next(TCCState *s1, char *name, int name_size)
|
|||||||
goto parse_name;
|
goto parse_name;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'a' ... 'z':
|
/* case 'a' ... 'z': */
|
||||||
case 'A' ... 'Z':
|
case 'a':
|
||||||
|
case 'b':
|
||||||
|
case 'c':
|
||||||
|
case 'd':
|
||||||
|
case 'e':
|
||||||
|
case 'f':
|
||||||
|
case 'g':
|
||||||
|
case 'h':
|
||||||
|
case 'i':
|
||||||
|
case 'j':
|
||||||
|
case 'k':
|
||||||
|
case 'l':
|
||||||
|
case 'm':
|
||||||
|
case 'n':
|
||||||
|
case 'o':
|
||||||
|
case 'p':
|
||||||
|
case 'q':
|
||||||
|
case 'r':
|
||||||
|
case 's':
|
||||||
|
case 't':
|
||||||
|
case 'u':
|
||||||
|
case 'v':
|
||||||
|
case 'w':
|
||||||
|
case 'x':
|
||||||
|
case 'y':
|
||||||
|
case 'z':
|
||||||
|
/* case 'A' ... 'z': */
|
||||||
|
case 'A':
|
||||||
|
case 'B':
|
||||||
|
case 'C':
|
||||||
|
case 'D':
|
||||||
|
case 'E':
|
||||||
|
case 'F':
|
||||||
|
case 'G':
|
||||||
|
case 'H':
|
||||||
|
case 'I':
|
||||||
|
case 'J':
|
||||||
|
case 'K':
|
||||||
|
case 'L':
|
||||||
|
case 'M':
|
||||||
|
case 'N':
|
||||||
|
case 'O':
|
||||||
|
case 'P':
|
||||||
|
case 'Q':
|
||||||
|
case 'R':
|
||||||
|
case 'S':
|
||||||
|
case 'T':
|
||||||
|
case 'U':
|
||||||
|
case 'V':
|
||||||
|
case 'W':
|
||||||
|
case 'X':
|
||||||
|
case 'Y':
|
||||||
|
case 'Z':
|
||||||
case '_':
|
case '_':
|
||||||
case '\\':
|
case '\\':
|
||||||
case '.':
|
case '.':
|
||||||
|
Loading…
Reference in New Issue
Block a user