Let the user change the dynamic linker used by ELF code.

* ld.h (args_type): Add new field interpreter.
	* lexsup.c (parse_args): Add dynamic-linker to longopts, and
	handle it.
	* ldmain.c (main): Initialize command_line.interpreter to NULL.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Get
	the ELF backend to return the .interp section.  If
	command_line.interpreter is not NULL, set the contents of .interp
	to it.
	* ld.texinfo: Mention -dynamic-linker.
This commit is contained in:
Ian Lance Taylor
1994-06-15 20:46:43 +00:00
parent 57569ce8d1
commit 7fb9ca5fc2
4 changed files with 33 additions and 2 deletions

View File

@ -1,5 +1,19 @@
Wed Jun 15 01:54:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) Wed Jun 15 01:54:54 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
Let the user change the dynamic linker used by ELF code.
* ld.h (args_type): Add new field interpreter.
* lexsup.c (parse_args): Add dynamic-linker to longopts, and
handle it.
* ldmain.c (main): Initialize command_line.interpreter to NULL.
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Get
the ELF backend to return the .interp section. If
command_line.interpreter is not NULL, set the contents of .interp
to it.
* ld.texinfo: Mention -dynamic-linker.
* config/sun4sol2.mt (eelf32_sparc.c): Depend upon elf32.em, not
generic.em.
* lexsup.c (parse_args): Sort out the option macros and change the * lexsup.c (parse_args): Sort out the option macros and change the
definitions to make it easier to add a new option. definitions to make it easier to add a new option.

View File

@ -59,6 +59,8 @@ gld${EMULATION_NAME}_before_parse()
static void static void
gld${EMULATION_NAME}_before_allocation () gld${EMULATION_NAME}_before_allocation ()
{ {
asection *sinterp;
/* If we are going to make any variable assignments, we need to let /* If we are going to make any variable assignments, we need to let
the ELF backend know about them in case the variables are the ELF backend know about them in case the variables are
referred to by dynamic objects. */ referred to by dynamic objects. */
@ -66,8 +68,17 @@ gld${EMULATION_NAME}_before_allocation ()
/* Let the ELF backend work out the sizes of any sections required /* Let the ELF backend work out the sizes of any sections required
by dynamic linking. */ by dynamic linking. */
if (! bfd_elf32_size_dynamic_sections (output_bfd, &link_info)) if (! bfd_elf32_size_dynamic_sections (output_bfd, &link_info,
&sinterp))
einfo ("%P%F: failed to set dynamic section sizes: %E\n"); einfo ("%P%F: failed to set dynamic section sizes: %E\n");
/* Let the user override the dynamic linker we are using. */
if (command_line.interpreter != NULL
&& sinterp != NULL)
{
sinterp->contents = (bfd_byte *) command_line.interpreter;
sinterp->_raw_size = strlen (command_line.interpreter) + 1;
}
} }
/* This is called by the before_allocation routine via /* This is called by the before_allocation routine via

View File

@ -162,6 +162,7 @@ main (argc, argv)
config.build_constructors = true; config.build_constructors = true;
config.dynamic_link = false; config.dynamic_link = false;
command_line.force_common_definition = false; command_line.force_common_definition = false;
command_line.interpreter = NULL;
link_info.callbacks = &link_callbacks; link_info.callbacks = &link_callbacks;
link_info.relocateable = false; link_info.relocateable = false;

View File

@ -57,7 +57,8 @@ parse_args (argc, argv)
#define OPTION_CALL_SHARED 150 #define OPTION_CALL_SHARED 150
#define OPTION_DEFSYM (OPTION_CALL_SHARED + 1) #define OPTION_DEFSYM (OPTION_CALL_SHARED + 1)
#define OPTION_EB (OPTION_DEFSYM + 1) #define OPTION_DYNAMIC_LINKER (OPTION_DEFSYM + 1)
#define OPTION_EB (OPTION_DYNAMIC_LINKER + 1)
#define OPTION_EL (OPTION_EB + 1) #define OPTION_EL (OPTION_EB + 1)
#define OPTION_HELP (OPTION_EL + 1) #define OPTION_HELP (OPTION_EL + 1)
#define OPTION_IGNORE (OPTION_HELP + 1) #define OPTION_IGNORE (OPTION_HELP + 1)
@ -85,6 +86,7 @@ parse_args (argc, argv)
{"dn", no_argument, NULL, OPTION_NON_SHARED}, {"dn", no_argument, NULL, OPTION_NON_SHARED},
{"dp", no_argument, NULL, 'd'}, {"dp", no_argument, NULL, 'd'},
{"dy", no_argument, NULL, OPTION_CALL_SHARED}, {"dy", no_argument, NULL, OPTION_CALL_SHARED},
{"dynamic-linker", required_argument, NULL, OPTION_DYNAMIC_LINKER},
{"EB", no_argument, NULL, OPTION_EB}, {"EB", no_argument, NULL, OPTION_EB},
{"EL", no_argument, NULL, OPTION_EL}, {"EL", no_argument, NULL, OPTION_EL},
{"format", required_argument, NULL, 'b'}, {"format", required_argument, NULL, 'b'},
@ -160,6 +162,9 @@ parse_args (argc, argv)
parser_input = input_defsym; parser_input = input_defsym;
yyparse (); yyparse ();
break; break;
case OPTION_DYNAMIC_LINKER:
command_line.interpreter = optarg;
break;
case OPTION_EB: case OPTION_EB:
/* FIXME: This is currently ignored. It means /* FIXME: This is currently ignored. It means
``produce a big-endian object file''. It could ``produce a big-endian object file''. It could