* ldmain.c (main): Initialize link_info.init_function and

link_info.fini_function.
	* lexsup.c (OPTION_INIT): New macro.
	(OPTION_FINI): Likewise.
	(ld_options): Add descriptions for them.
	(parse_args): Handle them.
This commit is contained in:
Mark Mitchell 1999-06-23 11:09:30 +00:00
parent f0c2e336c8
commit 3dbf70a218
4 changed files with 44 additions and 1 deletions

View File

@ -1,3 +1,12 @@
1999-06-22 Mark Mitchell <mark@codesourcery.com>
* ldmain.c (main): Initialize link_info.init_function and
link_info.fini_function.
* lexsup.c (OPTION_INIT): New macro.
(OPTION_FINI): Likewise.
(ld_options): Add descriptions for them.
(parse_args): Handle them.
1999-06-23 Ian Lance Taylor <ian@zembu.com>
* ldlang.c (section_already_linked): Only discard link once

View File

@ -404,6 +404,14 @@ purpose: the @code{-b}, @code{--format}, @code{--oformat} options, the
environment variable. The @sc{gnu} linker will ignore the @code{-F}
option when not creating an ELF shared object.
@cindex finalization function
@kindex -fini
@item -fini @var{name}
When creating an ELF executable or shared object, call NAME when the
executable or shared object is unloaded, by setting DT_FINI to the
address of the function. By default, the linker uses @code{_fini} as
the function to call.
@kindex -g
@item -g
Ignored. Provided for compatibility with other tools.
@ -434,6 +442,14 @@ field rather than the using the file name given to the linker.
@item -i
Perform an incremental link (same as option @samp{-r}).
@cindex initialization function
@kindex -init
@item -init @var{name}
When creating an ELF executable or shared object, call NAME when the
executable or shared object is loaded, by setting DT_INIT to the address
of the function. By default, the linker uses @code{_init} as the
function to call.
@cindex archive files, from cmd line
@kindex -l@var{archive}
@kindex --library=@var{archive}

View File

@ -231,7 +231,11 @@ main (argc, argv)
link_info.notice_hash = NULL;
link_info.wrap_hash = NULL;
link_info.mpc860c0 = 0;
/* SVR4 linkers seem to set DT_INIT and DT_FINI based on magic _init
and _fini symbols. We are compatible. */
link_info.init_function = "_init";
link_info.fini_function = "_fini";
ldfile_add_arch ("");
config.make_executable = true;

View File

@ -120,6 +120,8 @@ int parsing_defsym = 0;
#define OPTION_NO_CHECK_SECTIONS (OPTION_CHECK_SECTIONS + 1)
#define OPTION_MPC860C0 (OPTION_NO_CHECK_SECTIONS + 1)
#define OPTION_NO_UNDEFINED (OPTION_MPC860C0 + 1)
#define OPTION_INIT (OPTION_NO_UNDEFINED + 1)
#define OPTION_FINI (OPTION_INIT + 1)
/* The long options. This structure is used for both the option
parsing and the help text. */
@ -270,6 +272,8 @@ static const struct ld_option ld_options[] =
'\0', N_("PROGRAM"), N_("Set the dynamic linker to use"), TWO_DASHES },
{ {"embedded-relocs", no_argument, NULL, OPTION_EMBEDDED_RELOCS},
'\0', NULL, N_("Generate embedded relocs"), TWO_DASHES},
{ {"fini", required_argument, NULL, OPTION_FINI},
'\0', N_("SYMBOL"), N_("Call SYMBOL at unload-time"), ONE_DASH },
{ {"force-exe-suffix", no_argument, NULL, OPTION_FORCE_EXE_SUFFIX},
'\0', NULL, N_("Force generation of file with .exe suffix"), TWO_DASHES},
{ {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
@ -280,6 +284,8 @@ static const struct ld_option ld_options[] =
TWO_DASHES },
{ {"help", no_argument, NULL, OPTION_HELP},
'\0', NULL, N_("Print option help"), TWO_DASHES },
{ {"init", required_argument, NULL, OPTION_INIT},
'\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
{ {"Map", required_argument, NULL, OPTION_MAP},
'\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
{ {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
@ -988,6 +994,14 @@ the GNU General Public License. This program has absolutely no warranty.\n"));
}
command_line.relax = true;
break;
case OPTION_INIT:
link_info.init_function = optarg;
break;
case OPTION_FINI:
link_info.fini_function = optarg;
break;
}
}