From d6f672b881f21e96280bfdaddb08002a220a0999 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 1 Sep 1995 19:29:43 +0000 Subject: [PATCH] Fri Sep 1 15:18:50 1995 Kazumoto Kojima * elflink.h (elf_bfd_final_link): Don't change a DT_INIT or DT_FINI entry if the appropriate symbol is not in the hash table. * libelf.h (struct elf_backend_data): Add create_program_headers and want_hdr_in_seg fields. * elfxx-target.h (elf_backend_want_hdr_in_seg): Define if not defined. (elf_backend_create_program_headers): Likewise. (elfNN_bed): Initialize create_program_headers and want_hdr_in_seg. * elf.c (get_program_header_size): Call create_program_headers backend routine. (map_program_segments): Check want_hdr_in_seg backend field. Call create_program_headers backend routine. * elf.c (assign_file_positions_except_relocs): Align non allocated sections when creating an executable. * elfcode.h (elf_swap_phdr_in): Make non static. (elf_swap_phdr_out): Make non static. * libelf.h (bfd_elf32_swap_phdr_in): Declare. (bfd_elf32_swap_phdr_out): Declare. (bfd_elf64_swap_phdr_in): Declare. (bfd_elf64_swap_phdr_out): Declare. --- bfd/ChangeLog | 38 ++++++++++++++++++++++++++++++++++++++ bfd/elflink.h | 17 ++++++++++------- bfd/libelf.h | 19 +++++++++++++++++++ 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 02494db9cce..cc836b8ce8c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,43 @@ +Fri Sep 1 15:18:50 1995 Kazumoto Kojima + + * elflink.h (elf_bfd_final_link): Don't change a DT_INIT or + DT_FINI entry if the appropriate symbol is not in the hash table. + + * libelf.h (struct elf_backend_data): Add create_program_headers + and want_hdr_in_seg fields. + * elfxx-target.h (elf_backend_want_hdr_in_seg): Define if not + defined. + (elf_backend_create_program_headers): Likewise. + (elfNN_bed): Initialize create_program_headers and + want_hdr_in_seg. + * elf.c (get_program_header_size): Call create_program_headers + backend routine. + (map_program_segments): Check want_hdr_in_seg backend field. Call + create_program_headers backend routine. + + * elf.c (assign_file_positions_except_relocs): Align non allocated + sections when creating an executable. + + * elfcode.h (elf_swap_phdr_in): Make non static. + (elf_swap_phdr_out): Make non static. + * libelf.h (bfd_elf32_swap_phdr_in): Declare. + (bfd_elf32_swap_phdr_out): Declare. + (bfd_elf64_swap_phdr_in): Declare. + (bfd_elf64_swap_phdr_out): Declare. + + * ecofflink.c (ecoff_collect_shuffle): New static function. + (_bfd_ecoff_get_accumulated_pdr): New function. + (_bfd_ecoff_get_accumulated_sym): New function. + (_bfd_ecoff_get_accumulated_ss): New function. + * libbfd-in.h (_bfd_ecoff_get_accumulated_pdr): Declare. + (_bfd_ecoff_get_accumulated_sym): Declare. + (_bfd_ecoff_get_accumulated_ss): Declare. + * libbfd.h: Rebuild. + Fri Sep 1 13:20:25 1995 Ian Lance Taylor + * libecoff.h (_bfd_ecoff_bfd_print_private_bfd_data): Fix typo. + * elflink.h (elf_link_add_object_symbols): Handle indirect and warning symbols. If any section is named .gnu.warning.XXX, treat the contents as a warning to be issued if the symbol XXX is diff --git a/bfd/elflink.h b/bfd/elflink.h index ec12292f343..e1c22dd5d8c 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -2139,9 +2139,9 @@ elf_bfd_final_link (abfd, info) h = elf_link_hash_lookup (elf_hash_table (info), name, false, false, true); - BFD_ASSERT (h != NULL); - if (h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) + if (h != NULL + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak)) { dyn.d_un.d_val = h->root.u.def.value; o = h->root.u.def.section; @@ -2149,11 +2149,14 @@ elf_bfd_final_link (abfd, info) dyn.d_un.d_val += (o->output_section->vma + o->output_offset); else - /* The symbol is imported from another shared - library and does not apply to this one. */ - dyn.d_un.d_val = 0; + { + /* The symbol is imported from another shared + library and does not apply to this one. */ + dyn.d_un.d_val = 0; + } + + elf_swap_dyn_out (dynobj, &dyn, dyncon); } - elf_swap_dyn_out (dynobj, &dyn, dyncon); } break; diff --git a/bfd/libelf.h b/bfd/libelf.h index c0d2f7ebdd7..7a41be5e485 100644 --- a/bfd/libelf.h +++ b/bfd/libelf.h @@ -412,6 +412,14 @@ struct elf_backend_data void (*elf_backend_final_write_processing) PARAMS ((bfd *, boolean linker)); + /* A function to create any special program headers required by the + backend. PHDRS are the program headers, and PHDR_COUNT is the + number of them. If PHDRS is NULL, this just counts headers + without creating them. This returns an updated value for + PHDR_COUNT. */ + int (*elf_backend_create_program_headers) + PARAMS ((bfd *, Elf_Internal_Phdr *phdrs, int phdr_count)); + /* The swapping table to use when dealing with ECOFF information. Used for the MIPS ELF .mdebug section. */ const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap; @@ -425,6 +433,9 @@ struct elf_backend_data unsigned want_got_plt : 1; unsigned plt_readonly : 1; unsigned want_plt_sym : 1; + + /* Put ELF and program headers in the first loadable segment. */ + unsigned want_hdr_in_seg : 1; }; /* Information stored for each BFD section in an ELF file. This @@ -654,6 +665,10 @@ extern void bfd_elf32_swap_reloca_in PARAMS ((bfd *, Elf32_External_Rela *, Elf_Internal_Rela *)); extern void bfd_elf32_swap_reloca_out PARAMS ((bfd *, Elf_Internal_Rela *, Elf32_External_Rela *)); +extern void bfd_elf32_swap_phdr_in + PARAMS ((bfd *, Elf32_External_Phdr *, Elf_Internal_Phdr *)); +extern void bfd_elf32_swap_phdr_out + PARAMS ((bfd *, Elf_Internal_Phdr *, Elf32_External_Phdr *)); extern void bfd_elf32_swap_dyn_in PARAMS ((bfd *, const Elf32_External_Dyn *, Elf_Internal_Dyn *)); extern void bfd_elf32_swap_dyn_out @@ -686,6 +701,10 @@ extern void bfd_elf64_swap_reloca_in PARAMS ((bfd *, Elf64_External_Rela *, Elf_Internal_Rela *)); extern void bfd_elf64_swap_reloca_out PARAMS ((bfd *, Elf_Internal_Rela *, Elf64_External_Rela *)); +extern void bfd_elf64_swap_phdr_in + PARAMS ((bfd *, Elf64_External_Phdr *, Elf_Internal_Phdr *)); +extern void bfd_elf64_swap_phdr_out + PARAMS ((bfd *, Elf_Internal_Phdr *, Elf64_External_Phdr *)); extern void bfd_elf64_swap_dyn_in PARAMS ((bfd *, const Elf64_External_Dyn *, Elf_Internal_Dyn *)); extern void bfd_elf64_swap_dyn_out