* emultempl/elf32.em (gld${EMULATION_NAME}_finish): Only emit this

function when LDEMUL_FINISH isn't set to the same name.  Don't
	call ${LDEMUL_FINISH}.
	(ld_${EMULATION_NAME}_emulation): Call $LDEMUL_FINISH if defined.
	* emultempl/armelf.em (arm_elf_finish): Call
	gld${EMULATION_NAME}_finish.
	* emultempl/hppaelf.em (hppaelf_finish): Rename to
	gld${EMULATION_NAME}_finish.  Call bfd_elf32_discard_info and
	hppaelf_layout_sections_again if necessary.
	(need_laying_out): New var.
	(hppaelf_layaout_sections_again): Rename to
	hppaelf_layout_sections_again.  Clear need_laying_out.
	(PARSE_AND_LIST_OPTIONS): Format text.
This commit is contained in:
Alan Modra 2001-11-15 12:44:03 +00:00
parent c86380b586
commit c56feb2b8c
4 changed files with 54 additions and 18 deletions

View file

@ -1,3 +1,19 @@
2001-11-15 Alan Modra <amodra@bigpond.net.au>
* emultempl/elf32.em (gld${EMULATION_NAME}_finish): Only emit this
function when LDEMUL_FINISH isn't set to the same name. Don't
call ${LDEMUL_FINISH}.
(ld_${EMULATION_NAME}_emulation): Call $LDEMUL_FINISH if defined.
* emultempl/armelf.em (arm_elf_finish): Call
gld${EMULATION_NAME}_finish.
* emultempl/hppaelf.em (hppaelf_finish): Rename to
gld${EMULATION_NAME}_finish. Call bfd_elf32_discard_info and
hppaelf_layout_sections_again if necessary.
(need_laying_out): New var.
(hppaelf_layaout_sections_again): Rename to
hppaelf_layout_sections_again. Clear need_laying_out.
(PARSE_AND_LIST_OPTIONS): Format text.
2001-11-14 H.J. Lu <hjl@gnu.org> 2001-11-14 H.J. Lu <hjl@gnu.org>
* emultempl/armelf.em (arm_elf_finish): Renamed from * emultempl/armelf.em (arm_elf_finish): Renamed from

View file

@ -104,6 +104,9 @@ arm_elf_finish ()
{ {
struct bfd_link_hash_entry * h; struct bfd_link_hash_entry * h;
/* Call the elf32.em routine. */
gld${EMULATION_NAME}_finish ();
if (thumb_entry_symbol == NULL) if (thumb_entry_symbol == NULL)
return; return;

View file

@ -1320,12 +1320,15 @@ gld${EMULATION_NAME}_place_orphan (file, s)
return true; return true;
} }
EOF
fi
if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then
cat >>e${EMULATION_NAME}.c <<EOF
static void static void
gld${EMULATION_NAME}_finish () gld${EMULATION_NAME}_finish ()
{ {
${LDEMUL_FINISH+${LDEMUL_FINISH} ();}
if (bfd_elf${ELFSIZE}_discard_info (&link_info)) if (bfd_elf${ELFSIZE}_discard_info (&link_info))
{ {
/* Resize the sections. */ /* Resize the sections. */
@ -1639,7 +1642,7 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script}, ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
"${EMULATION_NAME}", "${EMULATION_NAME}",
"${OUTPUT_FORMAT}", "${OUTPUT_FORMAT}",
gld${EMULATION_NAME}_finish, ${LDEMUL_FINISH-gld${EMULATION_NAME}_finish},
${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL}, ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive}, ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan}, ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},

View file

@ -31,8 +31,8 @@ static void hppaelf_after_parse PARAMS((void));
static void hppaelf_create_output_section_statements PARAMS ((void)); static void hppaelf_create_output_section_statements PARAMS ((void));
static asection *hppaelf_add_stub_section static asection *hppaelf_add_stub_section
PARAMS ((const char *, asection *)); PARAMS ((const char *, asection *));
static void hppaelf_layaout_sections_again PARAMS ((void)); static void hppaelf_layout_sections_again PARAMS ((void));
static void hppaelf_finish PARAMS ((void)); static void gld${EMULATION_NAME}_finish PARAMS ((void));
/* Fake input file for stubs. */ /* Fake input file for stubs. */
@ -43,6 +43,9 @@ static lang_input_statement_type *stub_file;
stubs. */ stubs. */
static int multi_subspace = 0; static int multi_subspace = 0;
/* Whether we need to call hppa_layout_sections_again. */
static int need_laying_out = 0;
/* Maximum size of a group of input sections that can be handled by /* Maximum size of a group of input sections that can be handled by
one stub section. A value of +/-1 indicates the bfd back-end one stub section. A value of +/-1 indicates the bfd back-end
should use a suitable default size. */ should use a suitable default size. */
@ -216,11 +219,12 @@ hppaelf_add_stub_section (stub_sec_name, input_section)
/* Another call-back for elf32_hppa_size_stubs. */ /* Another call-back for elf32_hppa_size_stubs. */
static void static void
hppaelf_layaout_sections_again () hppaelf_layout_sections_again ()
{ {
/* If we have changed sizes of the stub sections, then we need /* If we have changed sizes of the stub sections, then we need
to recalculate all the section offsets. This may mean we need to to recalculate all the section offsets. This may mean we need to
add even more stubs. */ add even more stubs. */
need_laying_out = 0;
/* Resize the sections. */ /* Resize the sections. */
lang_size_sections (stat_ptr->head, abs_output_section, lang_size_sections (stat_ptr->head, abs_output_section,
@ -239,13 +243,20 @@ hppaelf_layaout_sections_again ()
to build linker stubs. */ to build linker stubs. */
static void static void
hppaelf_finish () gld${EMULATION_NAME}_finish ()
{ {
/* If generating a relocatable output file, then we don't /* If generating a relocatable output file, then we don't
have to examine the relocs. */ have to examine the relocs. */
if (link_info.relocateable) if (link_info.relocateable)
return; return;
/* bfd_elf32_discard_info just plays with debugging sections,
ie. doesn't affect any code, so we can delay resizing the
sections. It's likely we'll resize everything in the process of
adding stubs. */
if (bfd_elf${ELFSIZE}_discard_info (&link_info))
need_laying_out = 1;
/* Call into the BFD backend to do the real work. */ /* Call into the BFD backend to do the real work. */
if (! elf32_hppa_size_stubs (output_bfd, if (! elf32_hppa_size_stubs (output_bfd,
stub_file->the_bfd, stub_file->the_bfd,
@ -253,12 +264,15 @@ hppaelf_finish ()
multi_subspace, multi_subspace,
group_size, group_size,
&hppaelf_add_stub_section, &hppaelf_add_stub_section,
&hppaelf_layaout_sections_again)) &hppaelf_layout_sections_again))
{ {
einfo ("%X%P: can not size stub section: %E\n"); einfo ("%X%P: can not size stub section: %E\n");
return; return;
} }
if (need_laying_out)
hppaelf_layout_sections_again ();
/* Set the global data pointer. */ /* Set the global data pointer. */
if (! elf32_hppa_set_gp (output_bfd, &link_info)) if (! elf32_hppa_set_gp (output_bfd, &link_info))
{ {
@ -323,17 +337,17 @@ PARSE_AND_LIST_LONGOPTS='
PARSE_AND_LIST_OPTIONS=' PARSE_AND_LIST_OPTIONS='
fprintf (file, _("\ fprintf (file, _("\
--multi-subspace Generate import and export stubs to support\n\ --multi-subspace Generate import and export stubs to support\n\
multiple sub-space shared libraries\n" multiple sub-space shared libraries\n"
)); ));
fprintf (file, _("\ fprintf (file, _("\
--stub-group-size=N Maximum size of a group of input sections that can be\n\ --stub-group-size=N Maximum size of a group of input sections that can be\n\
handled by one stub section. A negative value\n\ handled by one stub section. A negative value\n\
locates all stubs before their branches (with a\n\ locates all stubs before their branches (with a\n\
group size of -N), while a positive value allows\n\ group size of -N), while a positive value allows\n\
two groups of input sections, one before, and one\n\ two groups of input sections, one before, and one\n\
after each stub section. Values of +/-1 indicate\n\ after each stub section. Values of +/-1 indicate\n\
the linker should choose suitable defaults." the linker should choose suitable defaults.\n"
)); ));
' '
@ -355,5 +369,5 @@ PARSE_AND_LIST_ARGS_CASES='
# Put these extra hppaelf routines in ld_${EMULATION_NAME}_emulation # Put these extra hppaelf routines in ld_${EMULATION_NAME}_emulation
# #
LDEMUL_AFTER_PARSE=hppaelf_after_parse LDEMUL_AFTER_PARSE=hppaelf_after_parse
LDEMUL_FINISH=hppaelf_finish LDEMUL_FINISH=gld${EMULATION_NAME}_finish
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=hppaelf_create_output_section_statements LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=hppaelf_create_output_section_statements