mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-25 14:24:19 +08:00
Add -Wl,-I and -Wl,-dynamic-linker options
Compatible with ld.bfd, gold, lld and mold. Also, document existing behaviour of LD_SO environment variable
This commit is contained in:
parent
f8bd136d19
commit
ec60d28e0f
7
libtcc.c
7
libtcc.c
@ -1428,6 +1428,13 @@ static int tcc_set_linker(TCCState *s, const char *option)
|
|||||||
s->rdynamic = 1;
|
s->rdynamic = 1;
|
||||||
} else if (link_option(option, "rpath=", &p)) {
|
} else if (link_option(option, "rpath=", &p)) {
|
||||||
copy_linker_arg(&s->rpath, p, ':');
|
copy_linker_arg(&s->rpath, p, ':');
|
||||||
|
} else if (link_option(option, "dynamic-linker=", &p)
|
||||||
|
|| link_option(option, "I=", &p)) {
|
||||||
|
copy_linker_arg(&s->elfint, p, 0);
|
||||||
|
} else if (strncmp("-I/", option, 3) == 0
|
||||||
|
|| strncmp("-I.", option, 3) == 0) {
|
||||||
|
p = option;
|
||||||
|
copy_linker_arg(&s->elfint, option + 2, 0);
|
||||||
} else if (link_option(option, "enable-new-dtags", &p)) {
|
} else if (link_option(option, "enable-new-dtags", &p)) {
|
||||||
s->enable_new_dtags = 1;
|
s->enable_new_dtags = 1;
|
||||||
} else if (link_option(option, "section-alignment=", &p)) {
|
} else if (link_option(option, "section-alignment=", &p)) {
|
||||||
|
|||||||
@ -360,6 +360,11 @@ Generate an object file combining all input files.
|
|||||||
@item -Wl,-rpath=path
|
@item -Wl,-rpath=path
|
||||||
Put custom search path for dynamic libraries into executable.
|
Put custom search path for dynamic libraries into executable.
|
||||||
|
|
||||||
|
@item -Wl,-Ipath
|
||||||
|
@item -Wl,--dynamic-linker=path
|
||||||
|
Set the ELF interpreter (dynamic linker). This defaults to the value of the
|
||||||
|
environment variable @env{LD_SO} if set, or a compiled-in default.
|
||||||
|
|
||||||
@item -Wl,--enable-new-dtags
|
@item -Wl,--enable-new-dtags
|
||||||
When putting a custom search path for dynamic libraries into the executable,
|
When putting a custom search path for dynamic libraries into the executable,
|
||||||
create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH.
|
create the new ELF dynamic tag DT_RUNPATH instead of the old legacy DT_RPATH.
|
||||||
|
|||||||
2
tcc.c
2
tcc.c
@ -152,6 +152,8 @@ static const char help2[] =
|
|||||||
" -soname= set DT_SONAME elf tag\n"
|
" -soname= set DT_SONAME elf tag\n"
|
||||||
#if defined(TCC_TARGET_MACHO)
|
#if defined(TCC_TARGET_MACHO)
|
||||||
" -install_name= set DT_SONAME elf tag (soname macOS alias)\n"
|
" -install_name= set DT_SONAME elf tag (soname macOS alias)\n"
|
||||||
|
#else
|
||||||
|
" -Ipath, -dynamic-linker=path set ELF interpreter to path"
|
||||||
#endif
|
#endif
|
||||||
" -Bsymbolic set DT_SYMBOLIC elf tag\n"
|
" -Bsymbolic set DT_SYMBOLIC elf tag\n"
|
||||||
" -oformat=[elf32/64-* binary] set executable output format\n"
|
" -oformat=[elf32/64-* binary] set executable output format\n"
|
||||||
|
|||||||
1
tcc.h
1
tcc.h
@ -802,6 +802,7 @@ struct TCCState {
|
|||||||
char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
|
char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
|
||||||
char *soname; /* as specified on the command line (-soname) */
|
char *soname; /* as specified on the command line (-soname) */
|
||||||
char *rpath; /* as specified on the command line (-Wl,-rpath=) */
|
char *rpath; /* as specified on the command line (-Wl,-rpath=) */
|
||||||
|
char *elfint; /* -Wl,-I on command line, LD_SO in environment, or DEFAULT_ELFINTERP(this) */
|
||||||
char *elf_entryname; /* "_start" unless set */
|
char *elf_entryname; /* "_start" unless set */
|
||||||
char *init_symbol; /* symbols to call at load-time (not used currently) */
|
char *init_symbol; /* symbols to call at load-time (not used currently) */
|
||||||
char *fini_symbol; /* symbols to call at unload-time (not used currently) */
|
char *fini_symbol; /* symbols to call at unload-time (not used currently) */
|
||||||
|
|||||||
4
tccelf.c
4
tccelf.c
@ -2850,7 +2850,9 @@ static int elf_output_file(TCCState *s1, const char *filename)
|
|||||||
if (file_type & TCC_OUTPUT_EXE) {
|
if (file_type & TCC_OUTPUT_EXE) {
|
||||||
char *ptr;
|
char *ptr;
|
||||||
/* allow override the dynamic loader */
|
/* allow override the dynamic loader */
|
||||||
const char *elfint = getenv("LD_SO");
|
const char *elfint = s1->elfint;
|
||||||
|
if (elfint == NULL)
|
||||||
|
elfint = getenv("LD_SO");
|
||||||
if (elfint == NULL)
|
if (elfint == NULL)
|
||||||
elfint = DEFAULT_ELFINTERP(s1);
|
elfint = DEFAULT_ELFINTERP(s1);
|
||||||
/* add interpreter section only if executable */
|
/* add interpreter section only if executable */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user