PR 10474
* ldemul.c (after_allocation_default): Run lang_relax_sections. * ldlang.h (lang_relax_sections): Declare. * ldlang.c (relax_sections): Delete. (lang_relax_sections): New function. (lang_process): Don't relax directly from here. * emultempl/alphaelf.em (alpha_finish): Call finish_default. * emultempl/armelf.em (arm_elf_after_allocation): Delete. Move body.. (gld${EMULATION_NAME}_finish): ..to here. Move existing code.. (gld${EMULATION_NAME}_after_allocation): ..to here. New function. (LDEMUL_AFTER_ALLOCATION): Update. * emultempl/avrelf.em (avr_elf_finish, LDEMUL_FINISH): Delete. (avr_elf_after_allocation): New function. (LDEMUL_AFTER_ALLOCATION): Define. * emultempl/elf-generic.em (gld${EMULATION_NAME}_map_segments): Call lang_relax_sections. * emultempl/elf32.em (gld${EMULATION_NAME}_finish): Delete. Move.. (gld${EMULATION_NAME}_after_allocation): ..code to here. New function. (LDEMUL_AFTER_ALLOCATION, LDEMUL_FINISH): Update. * emultempl/genelf.em (gld${EMULATION_NAME}_finish): Delete. Move.. (gld${EMULATION_NAME}_after_allocation): ..code to here. New function. (LDEMUL_FINISH): Delete. (LDEMUL_AFTER_ALLOCATION): Define. * emultempl/hppaelf.em (gld${EMULATION_NAME}_finish): Delete. Move.. (gld${EMULATION_NAME}_after_allocation): ..to here. New function. (LDEMUL_FINISH): Delete. (LDEMUL_AFTER_ALLOCATION): Define. * emultempl/m68hc1xelf.em (m68hc11elf_finish): Delete. Move.. (m68hc11elf_after_allocation): ..to here. New function. (LDEMUL_FINISH): Delete. (LDEMUL_AFTER_ALLOCATION): Define. * emultempl/m68kelf.em (m68k_elf_after_allocation): Call gld${EMULATION_NAME}_after_allocation. * emultempl/mmix-elfnmmo.em (mmix_after_allocation): Call gld${EMULATION_NAME}_after_allocation. * emultempl/mmo.em (mmo_finish): Delete. Move body.. (gld${EMULATION_NAME}_after_allocation): ..to here. New function. (LDEMUL_FINISH): Define. * emultempl/ppc64elf.em (ppc_layout_sections_again): Set elf_gp. (gld${EMULATION_NAME}_finish): Move code sizing sections.. (gld${EMULATION_NAME}_after_allocation): ..to here. * emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_after_allocation): Call gld${EMULATION_NAME}_after_allocation. * emultempl/spuelf.em (gld${EMULATION_NAME}_finish): Delete bfd_elf_discard_info and map_segments call.
This commit is contained in:
parent
a8ad78a74e
commit
eaeb0a9d5c
18 changed files with 197 additions and 174 deletions
48
ld/ChangeLog
48
ld/ChangeLog
|
@ -1,3 +1,51 @@
|
||||||
|
2009-08-10 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
PR 10474
|
||||||
|
* ldemul.c (after_allocation_default): Run lang_relax_sections.
|
||||||
|
* ldlang.h (lang_relax_sections): Declare.
|
||||||
|
* ldlang.c (relax_sections): Delete.
|
||||||
|
(lang_relax_sections): New function.
|
||||||
|
(lang_process): Don't relax directly from here.
|
||||||
|
* emultempl/alphaelf.em (alpha_finish): Call finish_default.
|
||||||
|
* emultempl/armelf.em (arm_elf_after_allocation): Delete. Move body..
|
||||||
|
(gld${EMULATION_NAME}_finish): ..to here. Move existing code..
|
||||||
|
(gld${EMULATION_NAME}_after_allocation): ..to here. New function.
|
||||||
|
(LDEMUL_AFTER_ALLOCATION): Update.
|
||||||
|
* emultempl/avrelf.em (avr_elf_finish, LDEMUL_FINISH): Delete.
|
||||||
|
(avr_elf_after_allocation): New function.
|
||||||
|
(LDEMUL_AFTER_ALLOCATION): Define.
|
||||||
|
* emultempl/elf-generic.em (gld${EMULATION_NAME}_map_segments): Call
|
||||||
|
lang_relax_sections.
|
||||||
|
* emultempl/elf32.em (gld${EMULATION_NAME}_finish): Delete. Move..
|
||||||
|
(gld${EMULATION_NAME}_after_allocation): ..code to here. New function.
|
||||||
|
(LDEMUL_AFTER_ALLOCATION, LDEMUL_FINISH): Update.
|
||||||
|
* emultempl/genelf.em (gld${EMULATION_NAME}_finish): Delete. Move..
|
||||||
|
(gld${EMULATION_NAME}_after_allocation): ..code to here. New function.
|
||||||
|
(LDEMUL_FINISH): Delete.
|
||||||
|
(LDEMUL_AFTER_ALLOCATION): Define.
|
||||||
|
* emultempl/hppaelf.em (gld${EMULATION_NAME}_finish): Delete. Move..
|
||||||
|
(gld${EMULATION_NAME}_after_allocation): ..to here. New function.
|
||||||
|
(LDEMUL_FINISH): Delete.
|
||||||
|
(LDEMUL_AFTER_ALLOCATION): Define.
|
||||||
|
* emultempl/m68hc1xelf.em (m68hc11elf_finish): Delete. Move..
|
||||||
|
(m68hc11elf_after_allocation): ..to here. New function.
|
||||||
|
(LDEMUL_FINISH): Delete.
|
||||||
|
(LDEMUL_AFTER_ALLOCATION): Define.
|
||||||
|
* emultempl/m68kelf.em (m68k_elf_after_allocation): Call
|
||||||
|
gld${EMULATION_NAME}_after_allocation.
|
||||||
|
* emultempl/mmix-elfnmmo.em (mmix_after_allocation): Call
|
||||||
|
gld${EMULATION_NAME}_after_allocation.
|
||||||
|
* emultempl/mmo.em (mmo_finish): Delete. Move body..
|
||||||
|
(gld${EMULATION_NAME}_after_allocation): ..to here. New function.
|
||||||
|
(LDEMUL_FINISH): Define.
|
||||||
|
* emultempl/ppc64elf.em (ppc_layout_sections_again): Set elf_gp.
|
||||||
|
(gld${EMULATION_NAME}_finish): Move code sizing sections..
|
||||||
|
(gld${EMULATION_NAME}_after_allocation): ..to here.
|
||||||
|
* emultempl/sh64elf.em (sh64_elf_${EMULATION_NAME}_after_allocation):
|
||||||
|
Call gld${EMULATION_NAME}_after_allocation.
|
||||||
|
* emultempl/spuelf.em (gld${EMULATION_NAME}_finish): Delete
|
||||||
|
bfd_elf_discard_info and map_segments call.
|
||||||
|
|
||||||
2009-08-06 Michael Eager <eager@eagercon.com>
|
2009-08-06 Michael Eager <eager@eagercon.com>
|
||||||
|
|
||||||
* Makefile.am: Add eelf32mb_linux.o, eelf32microblaze.o to
|
* Makefile.am: Add eelf32mb_linux.o, eelf32microblaze.o to
|
||||||
|
|
|
@ -98,7 +98,7 @@ alpha_finish (void)
|
||||||
if (limit_32bit)
|
if (limit_32bit)
|
||||||
elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
|
elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
|
||||||
|
|
||||||
gld${EMULATION_NAME}_finish ();
|
finish_default ();
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|
|
@ -89,22 +89,6 @@ arm_elf_before_allocation (void)
|
||||||
gld${EMULATION_NAME}_before_allocation ();
|
gld${EMULATION_NAME}_before_allocation ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
arm_elf_after_allocation (void)
|
|
||||||
{
|
|
||||||
/* Call the standard elf routine. */
|
|
||||||
after_allocation_default ();
|
|
||||||
|
|
||||||
{
|
|
||||||
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
|
||||||
{
|
|
||||||
/* Figure out where VFP11 erratum veneers (and the labels returning
|
|
||||||
from same) have been placed. */
|
|
||||||
bfd_elf32_arm_vfp11_fix_veneer_locations (is->the_bfd, &link_info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fake input file for stubs. */
|
/* Fake input file for stubs. */
|
||||||
static lang_input_statement_type *stub_file;
|
static lang_input_statement_type *stub_file;
|
||||||
|
|
||||||
|
@ -285,17 +269,16 @@ compare_output_sec_vma (const void *a, const void *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gld${EMULATION_NAME}_finish (void)
|
gld${EMULATION_NAME}_after_allocation (void)
|
||||||
{
|
{
|
||||||
struct bfd_link_hash_entry * h;
|
|
||||||
unsigned int list_size = 10;
|
|
||||||
asection **sec_list = xmalloc (list_size * sizeof (asection *));
|
|
||||||
unsigned int sec_count = 0;
|
|
||||||
|
|
||||||
if (!link_info.relocatable)
|
if (!link_info.relocatable)
|
||||||
{
|
{
|
||||||
/* Build a sorted list of input text sections, then use that to process
|
/* Build a sorted list of input text sections, then use that to process
|
||||||
the unwind table index. */
|
the unwind table index. */
|
||||||
|
unsigned int list_size = 10;
|
||||||
|
asection **sec_list = xmalloc (list_size * sizeof (asection *));
|
||||||
|
unsigned int sec_count = 0;
|
||||||
|
|
||||||
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
||||||
{
|
{
|
||||||
bfd *abfd = is->the_bfd;
|
bfd *abfd = is->the_bfd;
|
||||||
|
@ -375,6 +358,21 @@ gld${EMULATION_NAME}_finish (void)
|
||||||
|
|
||||||
if (need_laying_out != -1)
|
if (need_laying_out != -1)
|
||||||
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gld${EMULATION_NAME}_finish (void)
|
||||||
|
{
|
||||||
|
struct bfd_link_hash_entry * h;
|
||||||
|
|
||||||
|
{
|
||||||
|
LANG_FOR_EACH_INPUT_STATEMENT (is)
|
||||||
|
{
|
||||||
|
/* Figure out where VFP11 erratum veneers (and the labels returning
|
||||||
|
from same) have been placed. */
|
||||||
|
bfd_elf32_arm_vfp11_fix_veneer_locations (is->the_bfd, &link_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (! link_info.relocatable)
|
if (! link_info.relocatable)
|
||||||
{
|
{
|
||||||
|
@ -659,7 +657,7 @@ PARSE_AND_LIST_ARGS_CASES='
|
||||||
# We have our own before_allocation etc. functions, but they call
|
# We have our own before_allocation etc. functions, but they call
|
||||||
# the standard routines, so give them a different name.
|
# the standard routines, so give them a different name.
|
||||||
LDEMUL_BEFORE_ALLOCATION=arm_elf_before_allocation
|
LDEMUL_BEFORE_ALLOCATION=arm_elf_before_allocation
|
||||||
LDEMUL_AFTER_ALLOCATION=arm_elf_after_allocation
|
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
|
||||||
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=arm_elf_create_output_section_statements
|
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=arm_elf_create_output_section_statements
|
||||||
|
|
||||||
# Replace the elf before_parse function with our own.
|
# Replace the elf before_parse function with our own.
|
||||||
|
|
|
@ -144,29 +144,24 @@ avr_elf_create_output_section_statements (void)
|
||||||
/* Re-calculates the size of the stubs so that we won't waste space. */
|
/* Re-calculates the size of the stubs so that we won't waste space. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
avr_elf_finish (void)
|
avr_elf_after_allocation (void)
|
||||||
{
|
{
|
||||||
if (!avr_no_stubs)
|
if (!avr_no_stubs && !command_line.relax)
|
||||||
{
|
{
|
||||||
/* Now build the linker stubs. */
|
/* If relaxing, elf32_avr_size_stubs will be called from
|
||||||
if (stub_file->the_bfd->sections != NULL)
|
elf32_avr_relax_section. */
|
||||||
{
|
|
||||||
/* Call again the trampoline analyzer to initialize the trampoline
|
|
||||||
stubs with the correct symbol addresses. Since there could have
|
|
||||||
been relaxation, the symbol addresses that were found during
|
|
||||||
first call may no longer be correct. */
|
|
||||||
if (!elf32_avr_size_stubs (link_info.output_bfd, &link_info, FALSE))
|
if (!elf32_avr_size_stubs (link_info.output_bfd, &link_info, FALSE))
|
||||||
{
|
|
||||||
einfo ("%X%P: can not size stub section: %E\n");
|
einfo ("%X%P: can not size stub section: %E\n");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gld${EMULATION_NAME}_after_allocation ();
|
||||||
|
|
||||||
|
/* Now build the linker stubs. */
|
||||||
|
if (!avr_no_stubs)
|
||||||
|
{
|
||||||
if (!elf32_avr_build_stubs (&link_info))
|
if (!elf32_avr_build_stubs (&link_info))
|
||||||
einfo ("%X%P: can not build stubs: %E\n");
|
einfo ("%X%P: can not build stubs: %E\n");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gld${EMULATION_NAME}_finish ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -266,5 +261,5 @@ PARSE_AND_LIST_ARGS_CASES='
|
||||||
# Put these extra avr-elf routines in ld_${EMULATION_NAME}_emulation
|
# Put these extra avr-elf routines in ld_${EMULATION_NAME}_emulation
|
||||||
#
|
#
|
||||||
LDEMUL_BEFORE_ALLOCATION=avr_elf_${EMULATION_NAME}_before_allocation
|
LDEMUL_BEFORE_ALLOCATION=avr_elf_${EMULATION_NAME}_before_allocation
|
||||||
LDEMUL_FINISH=avr_elf_finish
|
LDEMUL_AFTER_ALLOCATION=avr_elf_after_allocation
|
||||||
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=avr_elf_create_output_section_statements
|
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=avr_elf_create_output_section_statements
|
||||||
|
|
|
@ -31,21 +31,8 @@ gld${EMULATION_NAME}_map_segments (bfd_boolean need_layout)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (need_layout)
|
lang_relax_sections (need_layout);
|
||||||
{
|
|
||||||
lang_reset_memory_regions ();
|
|
||||||
|
|
||||||
/* Resize the sections. */
|
|
||||||
lang_size_sections (NULL, TRUE);
|
|
||||||
|
|
||||||
/* Redo special stuff. */
|
|
||||||
ldemul_after_allocation ();
|
|
||||||
|
|
||||||
/* Do the assignments again. */
|
|
||||||
lang_do_assignments ();
|
|
||||||
|
|
||||||
need_layout = FALSE;
|
need_layout = FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour
|
if (link_info.output_bfd->xvec->flavour == bfd_target_elf_flavour
|
||||||
&& !link_info.relocatable)
|
&& !link_info.relocatable)
|
||||||
|
|
|
@ -62,10 +62,9 @@ fragment <<EOF
|
||||||
static void gld${EMULATION_NAME}_before_parse (void);
|
static void gld${EMULATION_NAME}_before_parse (void);
|
||||||
static void gld${EMULATION_NAME}_after_open (void);
|
static void gld${EMULATION_NAME}_after_open (void);
|
||||||
static void gld${EMULATION_NAME}_before_allocation (void);
|
static void gld${EMULATION_NAME}_before_allocation (void);
|
||||||
|
static void gld${EMULATION_NAME}_after_allocation (void);
|
||||||
static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
|
static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
|
||||||
(asection *, const char *, int);
|
(asection *, const char *, int);
|
||||||
static void gld${EMULATION_NAME}_finish (void);
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [ "x${USE_LIBPATH}" = xyes ] ; then
|
if [ "x${USE_LIBPATH}" = xyes ] ; then
|
||||||
|
@ -1830,17 +1829,15 @@ gld${EMULATION_NAME}_place_orphan (asection *s,
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then
|
if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
|
||||||
fragment <<EOF
|
fragment <<EOF
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gld${EMULATION_NAME}_finish (void)
|
gld${EMULATION_NAME}_after_allocation (void)
|
||||||
{
|
{
|
||||||
bfd_boolean need_layout = bfd_elf_discard_info (link_info.output_bfd,
|
bfd_boolean need_layout = bfd_elf_discard_info (link_info.output_bfd,
|
||||||
&link_info);
|
&link_info);
|
||||||
|
|
||||||
gld${EMULATION_NAME}_map_segments (need_layout);
|
gld${EMULATION_NAME}_map_segments (need_layout);
|
||||||
finish_default ();
|
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
@ -2327,14 +2324,14 @@ struct ld_emulation_xfer_struct ld_${EMULATION_NAME}_emulation =
|
||||||
${LDEMUL_HLL-hll_default},
|
${LDEMUL_HLL-hll_default},
|
||||||
${LDEMUL_AFTER_PARSE-after_parse_default},
|
${LDEMUL_AFTER_PARSE-after_parse_default},
|
||||||
${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
|
${LDEMUL_AFTER_OPEN-gld${EMULATION_NAME}_after_open},
|
||||||
${LDEMUL_AFTER_ALLOCATION-after_allocation_default},
|
${LDEMUL_AFTER_ALLOCATION-gld${EMULATION_NAME}_after_allocation},
|
||||||
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
|
${LDEMUL_SET_OUTPUT_ARCH-set_output_arch_default},
|
||||||
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
|
${LDEMUL_CHOOSE_TARGET-ldemul_default_target},
|
||||||
${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
|
${LDEMUL_BEFORE_ALLOCATION-gld${EMULATION_NAME}_before_allocation},
|
||||||
${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
|
${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
|
||||||
"${EMULATION_NAME}",
|
"${EMULATION_NAME}",
|
||||||
"${OUTPUT_FORMAT}",
|
"${OUTPUT_FORMAT}",
|
||||||
${LDEMUL_FINISH-gld${EMULATION_NAME}_finish},
|
${LDEMUL_FINISH-finish_default},
|
||||||
${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},
|
||||||
|
|
|
@ -28,13 +28,6 @@ EOF
|
||||||
source_em ${srcdir}/emultempl/elf-generic.em
|
source_em ${srcdir}/emultempl/elf-generic.em
|
||||||
fragment <<EOF
|
fragment <<EOF
|
||||||
|
|
||||||
static void
|
|
||||||
gld${EMULATION_NAME}_finish (void)
|
|
||||||
{
|
|
||||||
gld${EMULATION_NAME}_map_segments (FALSE);
|
|
||||||
finish_default ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gld${EMULATION_NAME}_after_open (void)
|
gld${EMULATION_NAME}_after_open (void)
|
||||||
{
|
{
|
||||||
|
@ -53,8 +46,14 @@ gld${EMULATION_NAME}_after_open (void)
|
||||||
elf_group_id (sec) = syms[sec_data->this_hdr.sh_info - 1];
|
elf_group_id (sec) = syms[sec_data->this_hdr.sh_info - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gld${EMULATION_NAME}_after_allocation (void)
|
||||||
|
{
|
||||||
|
gld${EMULATION_NAME}_map_segments (FALSE);
|
||||||
|
}
|
||||||
EOF
|
EOF
|
||||||
# Put these extra routines in ld_${EMULATION_NAME}_emulation
|
# Put these extra routines in ld_${EMULATION_NAME}_emulation
|
||||||
#
|
#
|
||||||
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
|
||||||
LDEMUL_AFTER_OPEN=gld${EMULATION_NAME}_after_open
|
LDEMUL_AFTER_OPEN=gld${EMULATION_NAME}_after_open
|
||||||
|
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
|
||||||
|
|
|
@ -237,14 +237,13 @@ build_section_lists (lang_statement_union_type *statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Final emulation specific call. For the PA we use this opportunity
|
/* For the PA we use this opportunity to size and build linker stubs. */
|
||||||
to build linker stubs. */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gld${EMULATION_NAME}_finish (void)
|
gld${EMULATION_NAME}_after_allocation (void)
|
||||||
{
|
{
|
||||||
/* bfd_elf_discard_info just plays with debugging sections,
|
/* bfd_elf_discard_info just plays with data and debugging sections,
|
||||||
ie. doesn't affect any code, so we can delay resizing the
|
ie. doesn't affect code size, so we can delay resizing the
|
||||||
sections. It's likely we'll resize everything in the process of
|
sections. It's likely we'll resize everything in the process of
|
||||||
adding stubs. */
|
adding stubs. */
|
||||||
if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
|
if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
|
||||||
|
@ -301,8 +300,6 @@ gld${EMULATION_NAME}_finish (void)
|
||||||
einfo ("%X%P: can not build stubs: %E\n");
|
einfo ("%X%P: can not build stubs: %E\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish_default ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -376,5 +373,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=gld${EMULATION_NAME}_finish
|
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
|
||||||
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=hppaelf_create_output_section_statements
|
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=hppaelf_create_output_section_statements
|
||||||
|
|
|
@ -284,11 +284,10 @@ m68hc11elf_add_stub_section (const char *stub_sec_name,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Final emulation specific call. For the 68HC12 we use this opportunity
|
/* For the 68HC12 we use this opportunity to build linker stubs. */
|
||||||
to build linker stubs. */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
m68hc11elf_finish (void)
|
m68hc11elf_after_allocation (void)
|
||||||
{
|
{
|
||||||
/* Now build the linker stubs. */
|
/* Now build the linker stubs. */
|
||||||
if (stub_file->the_bfd->sections != NULL)
|
if (stub_file->the_bfd->sections != NULL)
|
||||||
|
@ -308,7 +307,7 @@ m68hc11elf_finish (void)
|
||||||
einfo ("%X%P: can not build stubs: %E\n");
|
einfo ("%X%P: can not build stubs: %E\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
gld${EMULATION_NAME}_finish ();
|
gld${EMULATION_NAME}_after_allocation ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -370,5 +369,5 @@ PARSE_AND_LIST_ARGS_CASES='
|
||||||
# Put these extra m68hc11elf routines in ld_${EMULATION_NAME}_emulation
|
# Put these extra m68hc11elf routines in ld_${EMULATION_NAME}_emulation
|
||||||
#
|
#
|
||||||
LDEMUL_BEFORE_ALLOCATION=m68hc11_elf_${EMULATION_NAME}_before_allocation
|
LDEMUL_BEFORE_ALLOCATION=m68hc11_elf_${EMULATION_NAME}_before_allocation
|
||||||
LDEMUL_FINISH=m68hc11elf_finish
|
LDEMUL_AFTER_ALLOCATION=m68hc11elf_after_allocation
|
||||||
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=m68hc11elf_create_output_section_statements
|
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=m68hc11elf_create_output_section_statements
|
||||||
|
|
|
@ -143,7 +143,7 @@ static void
|
||||||
m68k_elf_after_allocation (void)
|
m68k_elf_after_allocation (void)
|
||||||
{
|
{
|
||||||
/* Call the standard elf routine. */
|
/* Call the standard elf routine. */
|
||||||
after_allocation_default ();
|
gld${EMULATION_NAME}_after_allocation ();
|
||||||
|
|
||||||
#ifdef SUPPORT_EMBEDDED_RELOCS
|
#ifdef SUPPORT_EMBEDDED_RELOCS
|
||||||
if (command_line.embedded_relocs
|
if (command_line.embedded_relocs
|
||||||
|
|
|
@ -56,11 +56,11 @@ mmix_before_allocation (void)
|
||||||
static void
|
static void
|
||||||
mmix_after_allocation (void)
|
mmix_after_allocation (void)
|
||||||
{
|
{
|
||||||
asection *sec
|
asection *sec;
|
||||||
= bfd_get_section_by_name (link_info.output_bfd,
|
|
||||||
MMIX_REG_CONTENTS_SECTION_NAME);
|
|
||||||
bfd_signed_vma regvma;
|
bfd_signed_vma regvma;
|
||||||
|
|
||||||
|
gld${EMULATION_NAME}_after_allocation ();
|
||||||
|
|
||||||
/* If there's no register section, we don't need to do anything. On the
|
/* If there's no register section, we don't need to do anything. On the
|
||||||
other hand, if there's a non-standard linker-script without a mapping
|
other hand, if there's a non-standard linker-script without a mapping
|
||||||
from MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME when that section is
|
from MMIX_LD_ALLOCATED_REG_CONTENTS_SECTION_NAME when that section is
|
||||||
|
@ -72,6 +72,8 @@ mmix_after_allocation (void)
|
||||||
that's expected when you play tricks with linker scripts. The
|
that's expected when you play tricks with linker scripts. The
|
||||||
"NOCROSSREFS 2" test does not run the output so it does not matter
|
"NOCROSSREFS 2" test does not run the output so it does not matter
|
||||||
there. */
|
there. */
|
||||||
|
sec = bfd_get_section_by_name (link_info.output_bfd,
|
||||||
|
MMIX_REG_CONTENTS_SECTION_NAME);
|
||||||
if (sec == NULL)
|
if (sec == NULL)
|
||||||
sec
|
sec
|
||||||
= bfd_get_section_by_name (link_info.output_bfd,
|
= bfd_get_section_by_name (link_info.output_bfd,
|
||||||
|
|
|
@ -35,6 +35,8 @@ fragment <<EOF
|
||||||
get a weird testcase right; ld-mmix/bpo-22, forcing ELF to be
|
get a weird testcase right; ld-mmix/bpo-22, forcing ELF to be
|
||||||
output from the mmo emulation: -m mmo --oformat elf64-mmix! */
|
output from the mmo emulation: -m mmo --oformat elf64-mmix! */
|
||||||
#include "elf-bfd.h"
|
#include "elf-bfd.h"
|
||||||
|
|
||||||
|
static void gld${EMULATION_NAME}_after_allocation (void);
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
source_em ${srcdir}/emultempl/elf-generic.em
|
source_em ${srcdir}/emultempl/elf-generic.em
|
||||||
|
@ -119,11 +121,10 @@ mmo_wipe_sec_reloc_flag (bfd *abfd, asection *sec, void *ptr ATTRIBUTE_UNUSED)
|
||||||
/* Iterate with bfd_map_over_sections over mmo_wipe_sec_reloc_flag... */
|
/* Iterate with bfd_map_over_sections over mmo_wipe_sec_reloc_flag... */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mmo_finish (void)
|
gld${EMULATION_NAME}_after_allocation (void)
|
||||||
{
|
{
|
||||||
bfd_map_over_sections (link_info.output_bfd, mmo_wipe_sec_reloc_flag, NULL);
|
bfd_map_over_sections (link_info.output_bfd, mmo_wipe_sec_reloc_flag, NULL);
|
||||||
gld${EMULATION_NAME}_map_segments (FALSE);
|
gld${EMULATION_NAME}_map_segments (FALSE);
|
||||||
finish_default ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* To get on-demand global register allocation right, we need to parse the
|
/* To get on-demand global register allocation right, we need to parse the
|
||||||
|
@ -154,5 +155,4 @@ mmo_after_open (void)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
LDEMUL_PLACE_ORPHAN=mmo_place_orphan
|
LDEMUL_PLACE_ORPHAN=mmo_place_orphan
|
||||||
LDEMUL_FINISH=mmo_finish
|
|
||||||
LDEMUL_AFTER_OPEN=mmo_after_open
|
LDEMUL_AFTER_OPEN=mmo_after_open
|
||||||
|
|
|
@ -258,18 +258,12 @@ ppc_layout_sections_again (void)
|
||||||
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. */
|
||||||
gld${EMULATION_NAME}_map_segments (TRUE);
|
gld${EMULATION_NAME}_map_segments (TRUE);
|
||||||
need_laying_out = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Call the back-end function to set TOC base after we have placed all
|
|
||||||
the sections. */
|
|
||||||
static void
|
|
||||||
gld${EMULATION_NAME}_after_allocation (void)
|
|
||||||
{
|
|
||||||
if (!link_info.relocatable)
|
if (!link_info.relocatable)
|
||||||
_bfd_set_gp_value (link_info.output_bfd,
|
_bfd_set_gp_value (link_info.output_bfd,
|
||||||
ppc64_elf_toc (link_info.output_bfd));
|
ppc64_elf_toc (link_info.output_bfd));
|
||||||
|
|
||||||
|
need_laying_out = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -307,18 +301,13 @@ build_section_lists (lang_statement_union_type *statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Final emulation specific call. */
|
/* Call the back-end function to set TOC base after we have placed all
|
||||||
|
the sections. */
|
||||||
static void
|
static void
|
||||||
gld${EMULATION_NAME}_finish (void)
|
gld${EMULATION_NAME}_after_allocation (void)
|
||||||
{
|
{
|
||||||
/* e_entry on PowerPC64 points to the function descriptor for
|
/* bfd_elf_discard_info just plays with data and debugging sections,
|
||||||
_start. If _start is missing, default to the first function
|
ie. doesn't affect code size, so we can delay resizing the
|
||||||
descriptor in the .opd section. */
|
|
||||||
entry_section = ".opd";
|
|
||||||
|
|
||||||
/* bfd_elf_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
|
sections. It's likely we'll resize everything in the process of
|
||||||
adding stubs. */
|
adding stubs. */
|
||||||
if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
|
if (bfd_elf_discard_info (link_info.output_bfd, &link_info))
|
||||||
|
@ -354,8 +343,26 @@ gld${EMULATION_NAME}_finish (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_laying_out != -1)
|
if (need_laying_out != -1)
|
||||||
|
{
|
||||||
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
||||||
|
|
||||||
|
if (!link_info.relocatable)
|
||||||
|
_bfd_set_gp_value (link_info.output_bfd,
|
||||||
|
ppc64_elf_toc (link_info.output_bfd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Final emulation specific call. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gld${EMULATION_NAME}_finish (void)
|
||||||
|
{
|
||||||
|
/* e_entry on PowerPC64 points to the function descriptor for
|
||||||
|
_start. If _start is missing, default to the first function
|
||||||
|
descriptor in the .opd section. */
|
||||||
|
entry_section = ".opd";
|
||||||
|
|
||||||
if (link_info.relocatable)
|
if (link_info.relocatable)
|
||||||
{
|
{
|
||||||
asection *toc = bfd_get_section_by_name (link_info.output_bfd, ".toc");
|
asection *toc = bfd_get_section_by_name (link_info.output_bfd, ".toc");
|
||||||
|
|
|
@ -244,13 +244,13 @@ sh64_elf_${EMULATION_NAME}_after_allocation (void)
|
||||||
bfd_vma cranges_growth = 0;
|
bfd_vma cranges_growth = 0;
|
||||||
asection *osec;
|
asection *osec;
|
||||||
bfd_byte *crangesp;
|
bfd_byte *crangesp;
|
||||||
|
asection *cranges;
|
||||||
|
|
||||||
asection *cranges = bfd_get_section_by_name (link_info.output_bfd,
|
gld${EMULATION_NAME}_after_allocation ();
|
||||||
|
|
||||||
|
cranges = bfd_get_section_by_name (link_info.output_bfd,
|
||||||
SH64_CRANGES_SECTION_NAME);
|
SH64_CRANGES_SECTION_NAME);
|
||||||
|
|
||||||
/* If this ever starts doing something, we will pick it up. */
|
|
||||||
after_allocation_default ();
|
|
||||||
|
|
||||||
/* If there is no .cranges section, it is because it was seen earlier on
|
/* If there is no .cranges section, it is because it was seen earlier on
|
||||||
that none was needed. Otherwise it must have been created then, or
|
that none was needed. Otherwise it must have been created then, or
|
||||||
be present in input. */
|
be present in input. */
|
||||||
|
@ -376,11 +376,6 @@ sh64_elf_${EMULATION_NAME}_after_allocation (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ldemul_after_allocation may be called twice. First directly from
|
|
||||||
lang_process, and the second time when lang_process calls ldemul_finish,
|
|
||||||
which calls gld${EMULATION_NAME}_finish, e.g. gldshelf32_finish, which
|
|
||||||
is defined in emultempl/elf32.em and calls ldemul_after_allocation,
|
|
||||||
if bfd_elf_discard_info returned true. */
|
|
||||||
if (cranges->contents != NULL)
|
if (cranges->contents != NULL)
|
||||||
free (cranges->contents);
|
free (cranges->contents);
|
||||||
|
|
||||||
|
|
|
@ -406,12 +406,6 @@ spu_elf_relink (void)
|
||||||
static void
|
static void
|
||||||
gld${EMULATION_NAME}_finish (void)
|
gld${EMULATION_NAME}_finish (void)
|
||||||
{
|
{
|
||||||
int need_laying_out;
|
|
||||||
|
|
||||||
need_laying_out = bfd_elf_discard_info (link_info.output_bfd, &link_info);
|
|
||||||
|
|
||||||
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
|
||||||
|
|
||||||
if (is_spu_target ())
|
if (is_spu_target ())
|
||||||
{
|
{
|
||||||
if (params.local_store_lo < params.local_store_hi)
|
if (params.local_store_lo < params.local_store_hi)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* ldemul.c -- clearing house for ld emulation states
|
/* ldemul.c -- clearing house for ld emulation states
|
||||||
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
|
||||||
2001, 2002, 2003, 2005, 2007, 2008
|
2001, 2002, 2003, 2005, 2007, 2008, 2009
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of the GNU Binutils.
|
This file is part of the GNU Binutils.
|
||||||
|
@ -205,6 +205,7 @@ after_open_default (void)
|
||||||
void
|
void
|
||||||
after_allocation_default (void)
|
after_allocation_default (void)
|
||||||
{
|
{
|
||||||
|
lang_relax_sections (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
52
ld/ldlang.c
52
ld/ldlang.c
|
@ -6159,16 +6159,25 @@ lang_find_relro_sections (void)
|
||||||
|
|
||||||
/* Relax all sections until bfd_relax_section gives up. */
|
/* Relax all sections until bfd_relax_section gives up. */
|
||||||
|
|
||||||
static void
|
void
|
||||||
relax_sections (void)
|
lang_relax_sections (bfd_boolean need_layout)
|
||||||
{
|
{
|
||||||
|
if (command_line.relax)
|
||||||
|
{
|
||||||
|
/* We may need more than one relaxation pass. */
|
||||||
|
int i = link_info.relax_pass;
|
||||||
|
|
||||||
|
/* The backend can use it to determine the current pass. */
|
||||||
|
link_info.relax_pass = 0;
|
||||||
|
|
||||||
|
while (i--)
|
||||||
|
{
|
||||||
/* Keep relaxing until bfd_relax_section gives up. */
|
/* Keep relaxing until bfd_relax_section gives up. */
|
||||||
bfd_boolean relax_again;
|
bfd_boolean relax_again;
|
||||||
|
|
||||||
link_info.relax_trip = -1;
|
link_info.relax_trip = -1;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
relax_again = FALSE;
|
|
||||||
link_info.relax_trip++;
|
link_info.relax_trip++;
|
||||||
|
|
||||||
/* Note: pe-dll.c does something like this also. If you find
|
/* Note: pe-dll.c does something like this also. If you find
|
||||||
|
@ -6185,9 +6194,23 @@ relax_sections (void)
|
||||||
|
|
||||||
/* Perform another relax pass - this time we know where the
|
/* Perform another relax pass - this time we know where the
|
||||||
globals are, so can make a better guess. */
|
globals are, so can make a better guess. */
|
||||||
|
relax_again = FALSE;
|
||||||
lang_size_sections (&relax_again, FALSE);
|
lang_size_sections (&relax_again, FALSE);
|
||||||
}
|
}
|
||||||
while (relax_again);
|
while (relax_again);
|
||||||
|
|
||||||
|
link_info.relax_pass++;
|
||||||
|
}
|
||||||
|
need_layout = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (need_layout)
|
||||||
|
{
|
||||||
|
/* Final extra sizing to report errors. */
|
||||||
|
lang_do_assignments ();
|
||||||
|
lang_reset_memory_regions ();
|
||||||
|
lang_size_sections (NULL, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -6293,29 +6316,8 @@ lang_process (void)
|
||||||
/* Size up the sections. */
|
/* Size up the sections. */
|
||||||
lang_size_sections (NULL, !command_line.relax);
|
lang_size_sections (NULL, !command_line.relax);
|
||||||
|
|
||||||
/* Now run around and relax if we can. */
|
|
||||||
if (command_line.relax)
|
|
||||||
{
|
|
||||||
/* We may need more than one relaxation pass. */
|
|
||||||
int i = link_info.relax_pass;
|
|
||||||
|
|
||||||
/* The backend can use it to determine the current pass. */
|
|
||||||
link_info.relax_pass = 0;
|
|
||||||
|
|
||||||
while (i--)
|
|
||||||
{
|
|
||||||
relax_sections ();
|
|
||||||
link_info.relax_pass++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Final extra sizing to report errors. */
|
|
||||||
lang_do_assignments ();
|
|
||||||
lang_reset_memory_regions ();
|
|
||||||
lang_size_sections (NULL, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* See if anything special should be done now we know how big
|
/* See if anything special should be done now we know how big
|
||||||
everything is. */
|
everything is. This is where relaxation is done. */
|
||||||
ldemul_after_allocation ();
|
ldemul_after_allocation ();
|
||||||
|
|
||||||
/* Fix any .startof. or .sizeof. symbols. */
|
/* Fix any .startof. or .sizeof. symbols. */
|
||||||
|
|
|
@ -483,6 +483,8 @@ extern lang_output_section_statement_type *lang_enter_output_section_statement
|
||||||
etree_type *, int);
|
etree_type *, int);
|
||||||
extern void lang_final
|
extern void lang_final
|
||||||
(void);
|
(void);
|
||||||
|
extern void lang_relax_sections
|
||||||
|
(bfd_boolean);
|
||||||
extern void lang_process
|
extern void lang_process
|
||||||
(void);
|
(void);
|
||||||
extern void lang_section_start
|
extern void lang_section_start
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue