Browse Source

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.
cr-0x5f1
Alan Modra 20 years ago
parent
commit
8ded5a0fc3
  1. 30
      bfd/ChangeLog
  2. 17
      bfd/doc/bfdint.texi
  3. 6
      bfd/elf-bfd.h
  4. 2
      bfd/elf-eh-frame.c
  5. 953
      bfd/elf.c
  6. 13
      bfd/elf32-arm.c
  7. 7
      bfd/elf32-bfin.c
  8. 7
      bfd/elf32-frv.c
  9. 10
      bfd/elf32-i370.c
  10. 8
      bfd/elf64-hppa.c
  11. 7
      bfd/elfxx-ia64.c
  12. 21
      bfd/elfxx-mips.c
  13. 44
      ld/ChangeLog
  14. 548
      ld/Makefile.am
  15. 548
      ld/Makefile.in
  16. 3
      ld/emulparams/arcelf.sh
  17. 2
      ld/emulparams/d30v_e.sh
  18. 2
      ld/emulparams/d30v_o.sh
  19. 2
      ld/emulparams/d30velf.sh
  20. 1
      ld/emulparams/elf32_dlx.sh
  21. 2
      ld/emulparams/elf32_i860.sh
  22. 2
      ld/emulparams/elf32fr30.sh
  23. 2
      ld/emulparams/elf32frv.sh
  24. 1
      ld/emulparams/elf32frvfd.sh
  25. 2
      ld/emulparams/elf32iq10.sh
  26. 2
      ld/emulparams/elf32iq2000.sh
  27. 2
      ld/emulparams/elf32mt.sh
  28. 2
      ld/emulparams/mn10200.sh
  29. 1
      ld/emulparams/mn10300.sh
  30. 465
      ld/emulparams/msp430all.sh
  31. 1
      ld/emulparams/or32.sh
  32. 2
      ld/emulparams/or32elf.sh
  33. 2
      ld/emulparams/pjelf.sh
  34. 5
      ld/emulparams/pjlelf.sh
  35. 60
      ld/emultempl/elf-generic.em
  36. 23
      ld/emultempl/elf32.em
  37. 39
      ld/emultempl/genelf.em
  38. 13
      ld/emultempl/hppaelf.em
  39. 7
      ld/emultempl/mmo.em
  40. 13
      ld/emultempl/ppc64elf.em
  41. 4
      ld/ldlang.c
  42. 6
      ld/testsuite/ChangeLog
  43. 6
      ld/testsuite/ld-elf/eh1.d
  44. 6
      ld/testsuite/ld-elf/eh2.d
  45. 6
      ld/testsuite/ld-elf/eh3.d

30
bfd/ChangeLog

@ -1,3 +1,33 @@
2006-06-20 Alan Modra <amodra@bigpond.net.au>
* 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.
2006-06-19 Vladimir Prus <vladimir@codesourcery.com>
* elf32-arm.c (elf32_arm_swap_symbol_out): Don't set low

17
bfd/doc/bfdint.texi

@ -1744,23 +1744,6 @@ support.
The processor function hooks and constants are ad hoc and need better
documentation.
When a linker script uses @samp{SIZEOF_HEADERS}, the ELF backend must
guess at the number of program segments which will be required, in
@samp{get_program_header_size}. This is because the linker calls
@samp{bfd_sizeof_headers} before it knows all the section addresses and
sizes. The ELF backend may later discover, when creating program
segments, that more program segments are required. This is currently
reported as an error in @samp{assign_file_positions_for_segments}.
In practice this makes it difficult to use @samp{SIZEOF_HEADERS} except
with a carefully defined linker script. Unfortunately,
@samp{SIZEOF_HEADERS} is required for fast program loading on a native
system, since it permits the initial code section to appear on the same
page as the program segments, saving a page read when the program starts
running. Fortunately, native systems permit careful definition of the
linker script. Still, ideally it would be possible to use relaxation to
compute the number of program segments.
@node BFD glossary
@section BFD glossary
@cindex glossary for bfd

6
bfd/elf-bfd.h

@ -1864,10 +1864,12 @@ extern bfd_boolean bfd_elf_gc_common_final_link
extern bfd_boolean bfd_elf_reloc_symbol_deleted_p
(bfd_vma, void *);
extern struct elf_segment_map *
_bfd_elf_make_dynamic_segment
extern struct elf_segment_map * _bfd_elf_make_dynamic_segment
(bfd *, asection *);
extern bfd_boolean _bfd_elf_map_sections_to_segments
(bfd *, struct bfd_link_info *);
/* Exported interface for writing elf corefile notes. */
extern char *elfcore_write_note
(bfd *, char *, int *, const char *, int, const void *, int);

2
bfd/elf-eh-frame.c

@ -846,8 +846,6 @@ _bfd_elf_discard_section_eh_frame_hdr (bfd *abfd, struct bfd_link_info *info)
if (hdr_info->table)
sec->size += 4 + hdr_info->fde_count * 8;
/* Request program headers to be recalculated. */
elf_tdata (abfd)->program_header_size = 0;
elf_tdata (abfd)->eh_frame_hdr = sec;
return TRUE;
}

953
bfd/elf.c

File diff suppressed because it is too large

13
bfd/elf32-arm.c

@ -9493,9 +9493,16 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd,
dynsec = bfd_get_section_by_name (abfd, ".dynamic");
if (dynsec)
{
m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
m->next = elf_tdata (abfd)->segment_map;
elf_tdata (abfd)->segment_map = m;
for (m = elf_tdata (abfd)->segment_map; m != NULL; m = m->next)
if (m->p_type == PT_DYNAMIC)
break;
if (m == NULL)
{
m = _bfd_elf_make_dynamic_segment (abfd, dynsec);
m->next = elf_tdata (abfd)->segment_map;
elf_tdata (abfd)->segment_map = m;
}
}
/* Also call the generic arm routine. */

7
bfd/elf32-bfin.c

@ -4234,8 +4234,11 @@ elf32_bfinfdpic_modify_segment_map (bfd *output_bfd,
/* Add the stack section to the PT_GNU_STACK segment,
such that its size and alignment requirements make it
to the segment. */
m->sections[m->count] = sec;
m->count++;
if (m->count == 0)
{
m->sections[m->count] = sec;
m->count++;
}
}
}

7
bfd/elf32-frv.c

@ -5757,8 +5757,11 @@ elf32_frvfdpic_modify_segment_map (bfd *output_bfd,
/* Add the stack section to the PT_GNU_STACK segment,
such that its size and alignment requirements make it
to the segment. */
m->sections[m->count] = sec;
m->count++;
if (m->count == 0)
{
m->sections[m->count] = sec;
m->count++;
}
}
}

10
bfd/elf32-i370.c

@ -1440,19 +1440,9 @@ i370_noop (void)
return 1;
}
/* We need to define these at least as no-ops to link glibc ld.so. */
#define elf_backend_add_symbol_hook \
(bfd_boolean (*) \
(bfd *, struct bfd_link_info *, Elf_Internal_Sym *, \
const char **, flagword *, asection **, bfd_vma *)) i370_noop
#define elf_backend_finish_dynamic_symbol \
(bfd_boolean (*) \
(bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, \
Elf_Internal_Sym *)) i370_noop
#define elf_backend_additional_program_headers \
(int (*) (bfd *, struct bfd_link_info *)) i370_noop
#define elf_backend_modify_segment_map \
(bfd_boolean (*) (bfd *, struct bfd_link_info *)) i370_noop
#include "elf32-target.h"

8
bfd/elf64-hppa.c

@ -204,9 +204,6 @@ static bfd_boolean elf64_hppa_finish_dynamic_symbol
PARAMS ((bfd *, struct bfd_link_info *,
struct elf_link_hash_entry *, Elf_Internal_Sym *));
static bfd_boolean elf64_hppa_modify_segment_map
PARAMS ((bfd *, struct bfd_link_info *));
static enum elf_reloc_type_class elf64_hppa_reloc_type_class
PARAMS ((const Elf_Internal_Rela *));
@ -2641,9 +2638,8 @@ elf64_hppa_additional_program_headers (bfd *abfd,
existence of a .interp section. */
static bfd_boolean
elf64_hppa_modify_segment_map (abfd, info)
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
elf64_hppa_modify_segment_map (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
struct elf_segment_map *m;
asection *s;

7
bfd/elfxx-ia64.c

@ -215,8 +215,6 @@ static bfd_boolean elfNN_ia64_add_symbol_hook
PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *sym,
const char **namep, flagword *flagsp, asection **secp,
bfd_vma *valp));
static bfd_boolean elfNN_ia64_modify_segment_map
PARAMS ((bfd *, struct bfd_link_info *));
static bfd_boolean elfNN_ia64_is_local_label_name
PARAMS ((bfd *abfd, const char *name));
static bfd_boolean elfNN_ia64_dynamic_symbol_p
@ -1655,9 +1653,8 @@ elfNN_ia64_additional_program_headers (bfd *abfd,
}
static bfd_boolean
elfNN_ia64_modify_segment_map (abfd, info)
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
elfNN_ia64_modify_segment_map (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED)
{
struct elf_segment_map *m, **pm;
Elf_Internal_Shdr *hdr;

21
bfd/elfxx-mips.c

@ -9230,15 +9230,18 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd,
|| (*pm)->p_type == PT_INTERP))
pm = &(*pm)->next;
amt = sizeof (struct elf_segment_map);
options_segment = bfd_zalloc (abfd, amt);
options_segment->next = *pm;
options_segment->p_type = PT_MIPS_OPTIONS;
options_segment->p_flags = PF_R;
options_segment->p_flags_valid = TRUE;
options_segment->count = 1;
options_segment->sections[0] = s;
*pm = options_segment;
if (*pm == NULL || (*pm)->p_type != PT_MIPS_OPTIONS)
{
amt = sizeof (struct elf_segment_map);
options_segment = bfd_zalloc (abfd, amt);
options_segment->next = *pm;
options_segment->p_type = PT_MIPS_OPTIONS;
options_segment->p_flags = PF_R;
options_segment->p_flags_valid = TRUE;
options_segment->count = 1;
options_segment->sections[0] = s;
*pm = options_segment;
}
}
}
else

44
ld/ChangeLog

@ -1,3 +1,47 @@
2006-06-20 Alan Modra <amodra@bigpond.net.au>
* 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.
2006-06-19 Alan Modra <amodra@bigpond.net.au>
* ldexp.c (fold_name): Adjust bfd_sizeof_headers call.

548
ld/Makefile.am

File diff suppressed because it is too large

548
ld/Makefile.in

File diff suppressed because it is too large

3
ld/emulparams/arcelf.sh

@ -1,4 +1,6 @@
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-littlearc"
LITTLE_OUTPUT_FORMAT="elf32-littlearc"
BIG_OUTPUT_FORMAT="elf32-bigarc"
@ -8,4 +10,3 @@ NONPAGED_TEXT_START_ADDR=0x0
ARCH=arc
MACHINE=
ENTRY=start
#TEMPLATE_NAME=elf32

2
ld/emulparams/d30v_e.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=elfd30v
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-d30v"
TEXT_START_ADDR=0x00000000
DATA_START_ADDR=0x20000000

2
ld/emulparams/d30v_o.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=elfd30v
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-d30v"
TEXT_START_ADDR=0x00000000
DATA_START_ADDR=0x20000000

2
ld/emulparams/d30velf.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=elfd30v
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-d30v"
TEXT_START_ADDR=0x00000000
DATA_START_ADDR=0x20000000

1
ld/emulparams/elf32_dlx.sh

@ -1,5 +1,6 @@
SCRIPT_NAME=dlx
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-dlx"
ARCH=dlx
MACHINE=

2
ld/emulparams/elf32_i860.sh

@ -1,5 +1,7 @@
# A work in progress...
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-i860-little"
BIG_OUTPUT_FORMAT="elf32-i860"
LITTLE_OUTPUT_FORMAT="elf32-i860-little"

2
ld/emulparams/elf32fr30.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-fr30"
TEXT_START_ADDR=0x10000
ARCH=fr30

2
ld/emulparams/elf32frv.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-frv"
TEXT_START_ADDR=0x10000
ARCH=frv

1
ld/emulparams/elf32frvfd.sh

@ -3,6 +3,7 @@ unset STACK_ADDR
OUTPUT_FORMAT="elf32-frvfdpic"
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
TEMPLATE_NAME=elf32
unset EXTRA_EM_FILE
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
EMBEDDED= # This gets us program headers mapped as part of the text segment.

2
ld/emulparams/elf32iq10.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=iq2000
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-iq2000"
DATA_ADDR=0x1000
TEXT_START_ADDR=0x80000000

2
ld/emulparams/elf32iq2000.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=iq2000
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-iq2000"
DATA_ADDR=0x1000
TEXT_START_ADDR=0x80000000

2
ld/emulparams/elf32mt.sh

@ -1,5 +1,7 @@
MACHINE=
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-mt"
# See also `include/elf/mt.h'
TEXT_START_ADDR=0x2000

2
ld/emulparams/mn10200.sh

@ -2,6 +2,8 @@
# mn10300.sh
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-mn10200"
TEXT_START_ADDR=0x0
ARCH=mn10200

1
ld/emulparams/mn10300.sh

@ -2,4 +2,5 @@
OUTPUT_FORMAT="elf32-mn10300"
ARCH=mn10300
TEMPLATE_NAME=elf32
unset EXTRA_EM_FILE
GENERATE_SHLIB_SCRIPT=yes

465
ld/emulparams/msp430all.sh

File diff suppressed because it is too large

1
ld/emulparams/or32.sh

@ -1,6 +1,5 @@
SCRIPT_NAME=or32
OUTPUT_FORMAT="coff-or32-big"
# OUTPUT_FORMAT="elf32-or32"
TEXT_START_ADDR=0x1000000
TARGET_PAGE_SIZE=0x1000000
ARCH=or32

2
ld/emulparams/or32elf.sh

@ -1,4 +1,6 @@
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-or32"
TEXT_START_ADDR=0x1000000
TARGET_PAGE_SIZE=0x1000000

2
ld/emulparams/pjelf.sh

@ -1,4 +1,6 @@
SCRIPT_NAME=elf
TEMPLATE_NAME=generic
EXTRA_EM_FILE=genelf
OUTPUT_FORMAT="elf32-pj"
TEXT_START_ADDR=0x1000000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"

5
ld/emulparams/pjlelf.sh

@ -1,5 +1,2 @@
SCRIPT_NAME=elf
. ${srcdir}/emulparams/pjelf.sh
OUTPUT_FORMAT="elf32-pjl"
TEXT_START_ADDR=0x1000000
MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
ARCH=pj

60
ld/emultempl/elf-generic.em

@ -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

23
ld/emultempl/elf32.em

@ -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

@ -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

13
ld/emultempl/hppaelf.em

@ -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

7
ld/emultempl/mmo.em

@ -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 ();
}

13
ld/emultempl/ppc64elf.em

@ -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

4
ld/ldlang.c

@ -5568,13 +5568,13 @@ lang_process (void)
lang_do_assignments ();
ldemul_finish ();
/* Make sure that the section addresses make sense. */
if (! link_info.relocatable
&& command_line.check_section_addresses)
lang_check_section_addresses ();
/* Final stuffs. */
ldemul_finish ();
lang_end ();
}

6
ld/testsuite/ChangeLog

@ -1,3 +1,9 @@
2006-06-20 Alan Modra <amodra@bigpond.net.au>
* ld-elf/eh1.d: Update for fewer program headers.
* ld-elf/eh2.d: Likewise.
* ld-elf/eh3.d: Likewise.
2006-06-19 Vladimir Prus <vladimir@codesourcery.com>
* ld-arm/arm-elf.exp: New test.

6
ld/testsuite/ld-elf/eh1.d

@ -22,11 +22,11 @@ The section .eh_frame contains:
DW_CFA_nop
DW_CFA_nop
00000018 0000001c 0000001c FDE cie=00000000 pc=004000b0..004000b0
DW_CFA_advance_loc: 0 to 004000b0
00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078
DW_CFA_advance_loc: 0 to 00400078
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r6 at cfa-16
DW_CFA_advance_loc: 0 to 004000b0
DW_CFA_advance_loc: 0 to 00400078
DW_CFA_def_cfa_reg: r6
00000038 ZERO terminator

6
ld/testsuite/ld-elf/eh2.d

@ -22,11 +22,11 @@ The section .eh_frame contains:
DW_CFA_nop
DW_CFA_nop
00000018 0000001c 0000001c FDE cie=00000000 pc=004000b0..004000b0
DW_CFA_advance_loc: 0 to 004000b0
00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078
DW_CFA_advance_loc: 0 to 00400078
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r6 at cfa-16
DW_CFA_advance_loc: 0 to 004000b0
DW_CFA_advance_loc: 0 to 00400078
DW_CFA_def_cfa_reg: r6
00000038 ZERO terminator

6
ld/testsuite/ld-elf/eh3.d

@ -22,11 +22,11 @@ The section .eh_frame contains:
DW_CFA_nop
DW_CFA_nop
00000018 0000001c 0000001c FDE cie=00000000 pc=004000b0..004000b0
DW_CFA_advance_loc: 0 to 004000b0
00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078
DW_CFA_advance_loc: 0 to 00400078
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r6 at cfa-16
DW_CFA_advance_loc: 0 to 004000b0
DW_CFA_advance_loc: 0 to 00400078
DW_CFA_def_cfa_reg: r6
00000038 ZERO terminator

Loading…
Cancel
Save