mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
bfd/
* elf-bfd.h: Formatting. (_bfd_elf_map_sections_to_segments): Declare. * elf-eh-frame.c (_bfd_elf_discard_section_eh_frame_hdr): Don't clear program_header_size. * elf.c (get_program_header_size): Move. Don't use or set saved program_header_size here. (elf_modify_segment_map): New function. Split out from.. (assign_file_positions_for_load_sections): ..here. Assert header size is correct. Remove dead code. (_bfd_elf_map_sections_to_segments): Rename from map_sections_to_segments. Make global. Use get_program_header_size when we need estimate of header size. Call elf_modify_segment_map. Set program_header_size. (print_segment_map): Delete. (_bfd_elf_sizeof_headers): If segment_map available, get the actual size. * elf32-arm.c (elf32_arm_symbian_modify_segment_map): Make safe for calling more than once. * elf32-bfin.c (elf32_bfinfdpic_modify_segment_map): Likewise. * elf32-frv.c (elf32_frvfdpic_modify_segment_map): Likewise. * elfxx-mips.c (_bfd_mips_elf_modify_segment_map): Likewise. * elf32-i370.c (elf_backend_add_symbol_hook): Delete. (elf_backend_additional_program_headers): Delete. (elf_backend_modify_segment_map): Delete. * elf64-hppa.c (elf64_hppa_modify_segment_map): Convert to ISO C. * elfxx-ia64.c (elfNN_ia64_modify_segment_map): Likewise. * doc/bfdint.texi: Delete SIZEOF_HEADERS difficulties. ld/ * Makefile.am (ELF_DEPS): Define. Use in emul file deps. Fix many ELF emul file deps that incorrectly said they needed elf32.em instead of generic.em. Add genelf.em as required. * Makefile.in: Regenerate. * ldlang.c (lang_process): Call ldemul_finish before lang_check_section_addresses. * emulparams/arcelf.sh: Generic elf target needs genelf. * emulparams/d30v_e.sh: Likewise. * emulparams/d30v_o.sh: Likewise. * emulparams/d30velf.sh: Likewise. * emulparams/elf32_dlx.sh: Likewise. * emulparams/elf32_i860.sh: Likewise. * emulparams/elf32fr30.sh: Likewise. * emulparams/elf32frv.sh: Likewise. * emulparams/elf32iq10.sh: Likewise. * emulparams/elf32iq2000.sh: Likewise. * emulparams/elf32mt.sh: Likewise. * emulparams/mn10200.sh: Likewise. * emulparams/or32.sh: Likewise. * emulparams/or32elf.sh: Likewise. * emulparams/pjelf.sh: Likewise. * emulparams/msp430all.sh: Likewise. Extract common entries. * emulparams/pjlelf.sh: Include pjelf.sh. * emulparams/elf32frvfd.sh (EXTRA_EM_FILE): Unset. * emulparams/mn10300.sh (EXTRA_EM_FILE): Unset. * emultempl/elf-generic.em: New file. * emultempl/genelf.em: New file. * emultempl/elf32.em: Include elf-generic.em. (gld${EMULATION_NAME}_layout_sections_again): Delete. (gld${EMULATION_NAME}_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/hppaelf.em (hppaelf_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from hppaelf_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. * emultempl/mmo.em: Correct comment. Include elf-bfd.h and source elf-generic.em. (mmo_finish): Call gld${EMULATION_NAME}_map_segments. * emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise. (gld${EMULATION_NAME}_finish): Rename from ppc_finish. Call gld${EMULATION_NAME}_map_segments. (LDEMUL_FINISH): Update. ld/testsuite/ * ld-elf/eh1.d: Update for fewer program headers. * ld-elf/eh2.d: Likewise. * ld-elf/eh3.d: Likewise.
This commit is contained in:
60
ld/emultempl/elf-generic.em
Normal file
60
ld/emultempl/elf-generic.em
Normal file
@ -0,0 +1,60 @@
|
||||
# This shell script emits a C file. -*- C -*-
|
||||
# Copyright 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GLD, the Gnu Linker.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# This file is sourced from elf32.em and from ELF targets that use
|
||||
# generic.em.
|
||||
#
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
static void
|
||||
gld${EMULATION_NAME}_map_segments (bfd_boolean need_layout)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (output_bfd->xvec->flavour == bfd_target_elf_flavour)
|
||||
{
|
||||
bfd_size_type phdr_size;
|
||||
|
||||
phdr_size = elf_tdata (output_bfd)->program_header_size;
|
||||
if (!_bfd_elf_map_sections_to_segments (output_bfd, &link_info))
|
||||
einfo ("%F%P: map sections to segments failed: %E\n");
|
||||
|
||||
if (phdr_size != elf_tdata (output_bfd)->program_header_size)
|
||||
need_layout = TRUE;
|
||||
}
|
||||
|
||||
if (!need_layout)
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
EOF
|
@ -60,8 +60,7 @@ static void gld${EMULATION_NAME}_before_parse (void);
|
||||
static void gld${EMULATION_NAME}_after_open (void);
|
||||
static void gld${EMULATION_NAME}_before_allocation (void);
|
||||
static bfd_boolean gld${EMULATION_NAME}_place_orphan (asection *s);
|
||||
static void gld${EMULATION_NAME}_layout_sections_again (void);
|
||||
static void gld${EMULATION_NAME}_finish (void) ATTRIBUTE_UNUSED;
|
||||
static void gld${EMULATION_NAME}_finish (void);
|
||||
|
||||
EOF
|
||||
|
||||
@ -79,6 +78,7 @@ fi
|
||||
|
||||
# Import any needed special functions and/or overrides.
|
||||
#
|
||||
. ${srcdir}/emultempl/elf-generic.em
|
||||
if test -n "$EXTRA_EM_FILE" ; then
|
||||
. ${srcdir}/emultempl/${EXTRA_EM_FILE}.em
|
||||
fi
|
||||
@ -1559,27 +1559,12 @@ fi
|
||||
if test x"$LDEMUL_FINISH" != xgld"$EMULATION_NAME"_finish; then
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
static void
|
||||
gld${EMULATION_NAME}_layout_sections_again (void)
|
||||
{
|
||||
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 ();
|
||||
}
|
||||
|
||||
static void
|
||||
gld${EMULATION_NAME}_finish (void)
|
||||
{
|
||||
if (bfd_elf_discard_info (output_bfd, &link_info))
|
||||
gld${EMULATION_NAME}_layout_sections_again ();
|
||||
bfd_boolean need_layout = bfd_elf_discard_info (output_bfd, &link_info);
|
||||
|
||||
gld${EMULATION_NAME}_map_segments (need_layout);
|
||||
finish_default ();
|
||||
}
|
||||
EOF
|
||||
|
39
ld/emultempl/genelf.em
Normal file
39
ld/emultempl/genelf.em
Normal file
@ -0,0 +1,39 @@
|
||||
# This shell script emits a C file. -*- C -*-
|
||||
# Copyright 2006 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GLD, the Gnu Linker.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# This file is sourced from generic.em
|
||||
#
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
#include "elf-bfd.h"
|
||||
|
||||
EOF
|
||||
. ${srcdir}/emultempl/elf-generic.em
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
|
||||
static void
|
||||
gld${EMULATION_NAME}_finish (void)
|
||||
{
|
||||
gld${EMULATION_NAME}_map_segments (FALSE);
|
||||
finish_default ();
|
||||
}
|
||||
EOF
|
||||
# Put these extra routines in ld_${EMULATION_NAME}_emulation
|
||||
#
|
||||
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
@ -220,9 +220,8 @@ hppaelf_layout_sections_again (void)
|
||||
/* If we have changed sizes of the stub sections, then we need
|
||||
to recalculate all the section offsets. This may mean we need to
|
||||
add even more stubs. */
|
||||
need_laying_out = 0;
|
||||
|
||||
gld${EMULATION_NAME}_layout_sections_again ();
|
||||
gld${EMULATION_NAME}_map_segments (TRUE);
|
||||
need_laying_out = -1;
|
||||
}
|
||||
|
||||
|
||||
@ -248,7 +247,7 @@ build_section_lists (lang_statement_union_type *statement)
|
||||
to build linker stubs. */
|
||||
|
||||
static void
|
||||
hppaelf_finish (void)
|
||||
gld${EMULATION_NAME}_finish (void)
|
||||
{
|
||||
/* bfd_elf_discard_info just plays with debugging sections,
|
||||
ie. doesn't affect any code, so we can delay resizing the
|
||||
@ -288,8 +287,8 @@ hppaelf_finish (void)
|
||||
}
|
||||
}
|
||||
|
||||
if (need_laying_out)
|
||||
hppaelf_layout_sections_again ();
|
||||
if (need_laying_out != -1)
|
||||
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
||||
|
||||
if (! link_info.relocatable)
|
||||
{
|
||||
@ -381,5 +380,5 @@ PARSE_AND_LIST_ARGS_CASES='
|
||||
# Put these extra hppaelf routines in ld_${EMULATION_NAME}_emulation
|
||||
#
|
||||
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
|
||||
|
@ -18,16 +18,18 @@
|
||||
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# This file is sourced from elf32.em and mmo.em, used to define
|
||||
# linker MMIX-specifics common to ELF and MMO.
|
||||
# This file is sourced from generic.em
|
||||
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
/* Need to have this define before mmix-elfnmmo, which includes
|
||||
needrelax.em which uses this name for the before_allocation function,
|
||||
normally defined in elf32.em. */
|
||||
#define gldmmo_before_allocation before_allocation_default
|
||||
|
||||
#include "elf-bfd.h"
|
||||
EOF
|
||||
|
||||
. ${srcdir}/emultempl/elf-generic.em
|
||||
. ${srcdir}/emultempl/mmix-elfnmmo.em
|
||||
|
||||
cat >>e${EMULATION_NAME}.c <<EOF
|
||||
@ -112,6 +114,7 @@ static void
|
||||
mmo_finish (void)
|
||||
{
|
||||
bfd_map_over_sections (output_bfd, mmo_wipe_sec_reloc_flag, NULL);
|
||||
gld${EMULATION_NAME}_map_segments (FALSE);
|
||||
finish_default ();
|
||||
}
|
||||
|
||||
|
@ -258,9 +258,8 @@ ppc_layout_sections_again (void)
|
||||
/* If we have changed sizes of the stub sections, then we need
|
||||
to recalculate all the section offsets. This may mean we need to
|
||||
add even more stubs. */
|
||||
need_laying_out = 0;
|
||||
|
||||
gld${EMULATION_NAME}_layout_sections_again ();
|
||||
gld${EMULATION_NAME}_map_segments (TRUE);
|
||||
need_laying_out = -1;
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +310,7 @@ build_section_lists (lang_statement_union_type *statement)
|
||||
/* Final emulation specific call. */
|
||||
|
||||
static void
|
||||
ppc_finish (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
|
||||
@ -353,8 +352,8 @@ ppc_finish (void)
|
||||
}
|
||||
}
|
||||
|
||||
if (need_laying_out)
|
||||
ppc_layout_sections_again ();
|
||||
if (need_laying_out != -1)
|
||||
gld${EMULATION_NAME}_map_segments (need_laying_out);
|
||||
|
||||
if (link_info.relocatable)
|
||||
{
|
||||
@ -574,6 +573,6 @@ PARSE_AND_LIST_ARGS_CASES='
|
||||
#
|
||||
LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
|
||||
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
|
||||
LDEMUL_FINISH=ppc_finish
|
||||
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
|
||||
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
|
||||
LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
|
||||
|
Reference in New Issue
Block a user