From: Alan Modra Date: Thu, 9 May 2002 11:54:56 +0000 (+0000) Subject: Merge from mainline X-Git-Tag: binutils-2_12_1~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=87774662fce4d937fd86b774c70c7792d200b68f;p=thirdparty%2Fbinutils-gdb.git Merge from mainline --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index d137430e284..8951395a9d3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,129 @@ +2002-05-09 Alan Modra + + * elf64-ppc.c (RA_REGISTER_MASK, RA_REGISTER_SHIFT): Delete. + + Merge from mainline + 2002-05-08 Alan Modra + * elf32-ppc.c (ppc_elf_create_got): New function. + (ppc_elf_create_dynamic_sections): Call ppc_elf_create_got before + _bfd_elf_create_dynamic_sections. Correct .plt flags. + (ppc_elf_check_relocs): Use ppc_elf_create_got in place of + _bfd_elf_create_got_section. + + 2002-05-07 Alan Modra + * elf-bfd.h (struct elf_backend_data): Add rela_normal. + * elfxx-target.h (elf_backend_rela_normal): Define. + (elfNN_bed): Init rela_normal. + * elflink.h (elf_link_input_bfd ): Handle adjustment + for section symbols here if rela_normal. Simplify abs section test. + * elf-m10200.c (mn10200_elf_relocate_section): If relocatable, + return immediately. Remove code handling relocatable linking. + * elf-m10300.c (mn10300_elf_relocate_section): Likewise. + * elf32-fr30.c (fr30_elf_relocate_section): Likewise. + * elf32-i370.c (i370_elf_relocate_section): Likewise. + * elf32-i860.c (elf32_i860_relocate_section): Likewise. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-mcore.c (mcore_elf_relocate_section): Likewise. + * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-s390.c (elf_s390_relocate_section): Likewise. + * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise. + * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. + * elf64-s390.c (elf_s390_relocate_section): Likewise. + * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. + * elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise. + * elf32-arm.h (elf32_arm_relocate_section): Likewise #ifndef USE_REL. + * elf32-m32r.c (m32r_elf_relocate_section): Likewise. + * elf-m10200.c (elf_backend_rela_normal): Define. + * elf-m10300.c (elf_backend_rela_normal): Define. + * elf32-fr30.c (elf_backend_rela_normal): Define. + * elf32-i370.c (elf_backend_rela_normal): Define. + * elf32-i860.c (elf_backend_rela_normal): Define. + * elf32-m68k.c (elf_backend_rela_normal): Define. + * elf32-mcore.c (elf_backend_rela_normal): Define. + * elf32-openrisc.c (elf_backend_rela_normal): Define. + * elf32-ppc.c (elf_backend_rela_normal): Define. + * elf32-s390.c (elf_backend_rela_normal): Define. + * elf32-xstormy16.c (elf_backend_rela_normal): Define. + * elf64-ppc.c (elf_backend_rela_normal): Define. + * elf64-s390.c (elf_backend_rela_normal): Define. + * elf64-x86-64.c (elf_backend_rela_normal): Define. + * elfxx-ia64.c (elf_backend_rela_normal): Define. + * elf32-arm.h (elf_backend_rela_normal): Define #ifndef USE_REL. + * elf32-m32r.c (elf_backend_rela_normal): Likewise. + + 2002-05-06 Alan Modra + * elflink.h (elf_link_input_bfd ): Adjust r_offset + when not relocatable. Fix reloc_emitter call for K&R. + + 2002-05-04 Alan Modra + * dwarf2.c (struct line_head): Make prologue_length a bfd_vma. + (read_abbrevs): Change "offset" param to bfd_vma. + (parse_comp_unit): Change "version" and addr_size to unsigned ints. + Change "abbrev_offset" to bfd_vma. + (read_indirect_string): Use correct conversion chars in error + message format string, cast bfd_vma's to unsigned long. + (read_abbrevs): Likewise. + (read_attribute_value): Likewise. + (decode_line_info): Likewise. + (scan_unit_for_functions): Likewise. + (parse_comp_unit): Likewise. + + 2002-05-04 Bob Byrnes + * opncls.c (_bfd_new_bfd_contained_in): Check return value of + _bfd_new_bfd. + + 2002-05-02 Alan Modra + * elf64-ppc.c (ppc64_elf_howto_raw ): Change to a + 16 bit reloc. + : Likewise. + (ppc64_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to + SECTOFF reloc. + * elf32-ppc.c (ppc_elf_howto_raw ): Correct. + (ppc_elf_reloc_type_lookup): Map from BFD_RELOC_16_BASEREL to + SECTOFF reloc. + * elf64-ppc.c (ppc64_elf_addr16_ha_reloc): Delete. + (ppc64_elf_ha_reloc): New function. + (ppc64_elf_brtaken_reloc): New function. + (ppc64_elf_sectoff_reloc): New function. + (ppc64_elf_sectoff_ha_reloc): New function. + (ppc64_elf_toc_reloc): New function. + (ppc64_elf_toc_ha_reloc): New function. + (ppc64_elf_toc64_reloc): New function. + (ppc64_elf_unhandled_reloc): New function. + (ppc64_elf_howto_raw): Use the above. + : Mark pc_relative, pcrel_offset. + : Not pc_relative or pcrel_offset. Fix dst_mask. + : Likewise. + (IS_ABSOLUTE_RELOC): Update. + (struct ppc_link_hash_table): Add have_undefweak. + (ppc64_elf_link_hash_table_create): Init. + (func_desc_adjust): Set have_undefweak. + (ppc64_elf_func_desc_adjust): Call func_desc_adjust earlier. Only + add the .sfpr blr when have_undefweak. + (ppc64_elf_set_toc): Rename to ppc64_elf_toc, remove info param + and relocatable test. Return TOCstart and don't set elf_gp. + (ppc64_elf_relocate_section): Correct BRTAKEN/BRNTAKEN branch + offset calculation. Add assert on weak sym branch tweaks. + * elf64-ppc.h (ppc64_elf_set_toc): Delete. + (ppc64_elf_toc): Declare. + + 2002-05-01 Alan Modra + * syms.c (_bfd_stab_section_find_nearest_line): Don't bomb on NULL + file_name. + + 2002-05-01 Alan Modra + * elf64-ppc.c (CROR_151515, CROR_313131): Define. + (ppc64_elf_relocate_section): Use them. Don't look for plt calls + on R_PPC64_ADDR24 relocs. Require a nop or no link reg on plt + call branches. Correct undefined weak destination. + (ppc64_elf_func_desc_adjust): Always create at least one blr in + .sfpr, and correct case where either only savef* or restf* is + needed. + + 2002-04-09 DJ Delorie + * elfarm-nabi.c (elf32_arm_howto_table): Fix ABS16 masks. + 2002-05-06 Nick Clifton * elf32-arm.h (elf32_arm_final_link_relocate): Convert diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index f129e0b60cb..e3b8e27370c 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -42,7 +42,7 @@ struct line_head { bfd_vma total_length; unsigned short version; - unsigned int prologue_length; + bfd_vma prologue_length; unsigned char minimum_instruction_length; unsigned char default_is_stmt; int line_base; @@ -225,7 +225,7 @@ static bfd_vma read_address PARAMS ((struct comp_unit *, char *)); static struct abbrev_info *lookup_abbrev PARAMS ((unsigned int, struct abbrev_info **)); static struct abbrev_info **read_abbrevs - PARAMS ((bfd *, unsigned int, struct dwarf2_debug *)); + PARAMS ((bfd *, bfd_vma, struct dwarf2_debug *)); static char *read_attribute PARAMS ((struct attribute *, struct attr_abbrev *, struct comp_unit *, char *)); @@ -396,8 +396,8 @@ read_indirect_string (unit, buf, bytes_read_ptr) if (offset >= stash->dwarf_str_size) { - (*_bfd_error_handler) (_("Dwarf Error: DW_FORM_strp offset (%u) greater than or equal to .debug_str size (%u)."), - offset, stash->dwarf_str_size); + (*_bfd_error_handler) (_("Dwarf Error: DW_FORM_strp offset (%lu) greater than or equal to .debug_str size (%lu)."), + (unsigned long) offset, stash->dwarf_str_size); bfd_set_error (bfd_error_bad_value); return NULL; } @@ -523,7 +523,7 @@ lookup_abbrev (number,abbrevs) static struct abbrev_info** read_abbrevs (abfd, offset, stash) bfd * abfd; - unsigned int offset; + bfd_vma offset; struct dwarf2_debug *stash; { struct abbrev_info **abbrevs; @@ -557,8 +557,8 @@ read_abbrevs (abfd, offset, stash) if (offset >= stash->dwarf_abbrev_size) { - (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%u) greater than or equal to .debug_abbrev size (%u)."), - offset, stash->dwarf_abbrev_size); + (*_bfd_error_handler) (_("Dwarf Error: Abbrev offset (%lu) greater than or equal to .debug_abbrev size (%lu)."), + (unsigned long) offset, stash->dwarf_abbrev_size); bfd_set_error (bfd_error_bad_value); return 0; } @@ -754,7 +754,7 @@ read_attribute_value (attr, form, unit, info_ptr) info_ptr = read_attribute_value (attr, form, unit, info_ptr); break; default: - (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %d."), + (*_bfd_error_handler) (_("Dwarf Error: Invalid or unhandled FORM value: %u."), form); bfd_set_error (bfd_error_bad_value); } @@ -958,7 +958,7 @@ decode_line_info (unit, stash) below. */ if (unit->line_offset >= stash->dwarf_line_size) { - (*_bfd_error_handler) (_("Dwarf Error: Line offset (%u) greater than or equal to .debug_line size (%u)."), + (*_bfd_error_handler) (_("Dwarf Error: Line offset (%lu) greater than or equal to .debug_line size (%lu)."), unit->line_offset, stash->dwarf_line_size); bfd_set_error (bfd_error_bad_value); return 0; @@ -1345,7 +1345,7 @@ scan_unit_for_functions (unit) abbrev = lookup_abbrev (abbrev_number,unit->abbrevs); if (! abbrev) { - (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."), + (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."), abbrev_number); bfd_set_error (bfd_error_bad_value); return false; @@ -1486,9 +1486,9 @@ parse_comp_unit (abfd, stash, unit_length, offset_size) unsigned int offset_size; { struct comp_unit* unit; - unsigned short version; - unsigned int abbrev_offset = 0; - unsigned char addr_size; + unsigned int version; + bfd_vma abbrev_offset = 0; + unsigned int addr_size; struct abbrev_info** abbrevs; unsigned int abbrev_number, bytes_read, i; struct abbrev_info *abbrev; @@ -1517,7 +1517,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size) if (version != 2) { - (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%hu', this reader only handles version 2 information."), version); + (*_bfd_error_handler) (_("Dwarf Error: found dwarf version '%u', this reader only handles version 2 information."), version); bfd_set_error (bfd_error_bad_value); return 0; } @@ -1526,7 +1526,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size) { (*_bfd_error_handler) (_("Dwarf Error: found address size '%u', this reader can not handle sizes greater than '%u'."), addr_size, - sizeof (bfd_vma)); + (unsigned int) sizeof (bfd_vma)); bfd_set_error (bfd_error_bad_value); return 0; } @@ -1547,7 +1547,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size) info_ptr += bytes_read; if (! abbrev_number) { - (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %d."), + (*_bfd_error_handler) (_("Dwarf Error: Bad abbrev number: %u."), abbrev_number); bfd_set_error (bfd_error_bad_value); return 0; @@ -1556,7 +1556,7 @@ parse_comp_unit (abfd, stash, unit_length, offset_size) abbrev = lookup_abbrev (abbrev_number, abbrevs); if (! abbrev) { - (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %d."), + (*_bfd_error_handler) (_("Dwarf Error: Could not find abbrev number %u."), abbrev_number); bfd_set_error (bfd_error_bad_value); return 0; diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 4439daaff98..d10fda9b833 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -788,6 +788,11 @@ struct elf_backend_data section. */ unsigned default_use_rela_p : 1; + /* Set if RELA relocations for a relocatable link can be handled by + generic code. Backends that set this flag need do nothing in the + backend relocate_section routine for relocatable linking. */ + unsigned rela_normal : 1; + /* True if addresses "naturally" sign extend. This is used when swapping in from Elf32 when BFD64. */ unsigned sign_extend_vma : 1; diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index e514934fbbc..4e8de60df94 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -1,5 +1,5 @@ /* Matsushita 10200 specific support for 32-bit ELF - Copyright 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -347,6 +347,9 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section, struct elf_link_hash_entry **sym_hashes; Elf_Internal_Rela *rel, *relend; + if (info->relocateable) + return true; + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -367,26 +370,6 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section, r_type = ELF32_R_TYPE (rel->r_info); howto = elf_mn10200_howto_table + r_type; - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -1572,6 +1555,7 @@ mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order, #define ELF_MACHINE_ALT1 EM_CYGNUS_MN10200 #define ELF_MAXPAGESIZE 0x1000 +#define elf_backend_rela_normal 1 #define elf_info_to_howto mn10200_info_to_howto #define elf_info_to_howto_rel 0 #define elf_backend_relocate_section mn10200_elf_relocate_section diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index a80060a7f83..b0cac2837b0 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -551,6 +551,9 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, struct elf32_mn10300_link_hash_entry **sym_hashes; Elf_Internal_Rela *rel, *relend; + if (info->relocateable) + return true; + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = (struct elf32_mn10300_link_hash_entry **) (elf_sym_hashes (input_bfd)); @@ -577,26 +580,6 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section, || r_type == R_MN10300_GNU_VTENTRY) continue; - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -3084,6 +3067,7 @@ _bfd_mn10300_elf_merge_private_bfd_data (ibfd, obfd) #define elf_info_to_howto mn10300_info_to_howto #define elf_info_to_howto_rel 0 #define elf_backend_can_gc_sections 1 +#define elf_backend_rela_normal 1 #define elf_backend_check_relocs mn10300_elf_check_relocs #define elf_backend_gc_mark_hook mn10300_elf_gc_mark_hook #define elf_backend_relocate_section mn10300_elf_relocate_section diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index 9e8b09f931b..7d02127d6b1 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -1830,6 +1830,11 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela * relend; const char * name; +#ifndef USE_REL + if (info->relocateable) + return true; +#endif + symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -1862,6 +1867,7 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, #endif howto = bfd_reloc.howto; +#ifdef USE_REL if (info->relocateable) { /* This is a relocateable link. We don't have to change @@ -1874,19 +1880,16 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section, if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) { sec = local_sections[r_symndx]; -#ifdef USE_REL arm_add_to_rel (input_bfd, contents + rel->r_offset, howto, (bfd_signed_vma) (sec->output_offset + sym->st_value)); -#else - rel->r_addend += (sec->output_offset + sym->st_value); -#endif } } continue; } +#endif /* This is a final link. */ h = NULL; @@ -3637,6 +3640,9 @@ elf32_arm_reloc_type_class (rela) #define elf_backend_plt_readonly 1 #define elf_backend_want_got_plt 1 #define elf_backend_want_plt_sym 0 +#ifndef USE_REL +#define elf_backend_rela_normal 1 +#endif #define elf_backend_got_header_size 12 #define elf_backend_plt_header_size PLT_ENTRY_SIZE diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index 8e31d675223..e1bc741b407 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -1,5 +1,5 @@ /* FR30-specific support for 32-bit ELF. - Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -517,6 +517,9 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela * rel; Elf_Internal_Rela * relend; + if (info->relocateable) + return true; + symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); relend = relocs + input_section->reloc_count; @@ -541,27 +544,6 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section, r_symndx = ELF32_R_SYM (rel->r_info); - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections [r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ howto = fr30_elf_howto_table + ELF32_R_TYPE (rel->r_info); h = NULL; sym = NULL; @@ -806,6 +788,7 @@ fr30_elf_check_relocs (abfd, info, sec, relocs) #define elf_backend_check_relocs fr30_elf_check_relocs #define elf_backend_can_gc_sections 1 +#define elf_backend_rela_normal 1 #define bfd_elf32_bfd_reloc_type_lookup fr30_reloc_type_lookup diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 07d5f9d5932..fc82b47a080 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -1277,6 +1277,9 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_vma *local_got_offsets; boolean ret = true; + if (info->relocateable) + return true; + #ifdef DEBUG fprintf (stderr, "i370_elf_relocate_section called for %s section %s, %ld relocations%s\n", bfd_archive_filename (input_bfd), @@ -1320,34 +1323,6 @@ i370_elf_relocate_section (output_bfd, info, input_bfd, input_section, howto = i370_elf_howto_table[(int)r_type]; r_symndx = ELF32_R_SYM (rel->r_info); - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - addend = rel->r_addend += sec->output_offset + sym->st_value; - } - } - -#ifdef DEBUG - fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n", - howto->name, - (int)r_type, - r_symndx, - (long)offset, - (long)addend); -#endif - continue; - } - - /* This is a final link. */ if (r_symndx < symtab_hdr->sh_info) { sym = local_syms + r_symndx; @@ -1661,6 +1636,7 @@ i370_elf_post_process_headers (abfd, link_info) #define elf_backend_plt_not_loaded 1 #define elf_backend_got_symbol_offset 4 +#define elf_backend_rela_normal 1 #define bfd_elf32_bfd_reloc_type_lookup i370_elf_reloc_type_lookup #define bfd_elf32_bfd_set_private_flags i370_elf_set_private_flags diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index 7b5d0520c21..82c7190d420 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -1,5 +1,6 @@ /* Intel i860 specific support for 32-bit ELF. - Copyright 1993, 1995, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1993, 1995, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. Full i860 support contributed by Jason Eckhardt . @@ -878,6 +879,9 @@ elf32_i860_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela * rel; Elf_Internal_Rela * relend; + if (info->relocateable) + return true; + symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); relend = relocs + input_section->reloc_count; @@ -904,27 +908,6 @@ elf32_i860_relocate_section (output_bfd, info, input_bfd, input_section, r_symndx = ELF32_R_SYM (rel->r_info); - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections [r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info)); h = NULL; sym = NULL; @@ -1097,6 +1080,7 @@ elf32_i860_is_local_label_name (abfd, name) #define ELF_MACHINE_CODE EM_860 #define ELF_MAXPAGESIZE 4096 +#define elf_backend_rela_normal 1 #define elf_info_to_howto_rel NULL #define elf_info_to_howto elf32_i860_info_to_howto_rela #define elf_backend_relocate_section elf32_i860_relocate_section diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index b3b62204893..e8015a9b3c6 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -981,6 +981,11 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* Assume success. */ boolean ret = true; +#ifndef USE_REL + if (info->relocateable) + return true; +#endif + rel = relocs; relend = relocs + input_section->reloc_count; for (; rel < relend; rel++) @@ -1020,6 +1025,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, howto = m32r_elf_howto_table + r_type; r_symndx = ELF32_R_SYM (rel->r_info); +#ifdef USE_REL if (info->relocateable) { /* This is a relocateable link. We don't have to change @@ -1045,16 +1051,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, sec = local_sections[r_symndx]; addend += sec->output_offset + sym->st_value; -#ifndef USE_REL - /* This can't be done for USE_REL because it doesn't mean anything - and elf_link_input_bfd asserts this stays zero. */ - rel->r_addend = addend; -#endif -#ifndef USE_REL - /* Addends are stored with relocs. We're done. */ - continue; -#else /* USE_REL */ /* If partial_inplace, we need to store any additional addend back in the section. */ if (! howto->partial_inplace) @@ -1088,9 +1085,9 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, r = _bfd_relocate_contents (howto, input_bfd, addend, contents + offset); } -#endif /* USE_REL */ } else +#endif /* USE_REL */ { bfd_vma relocation; @@ -2161,6 +2158,9 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) #define elf_backend_check_relocs m32r_elf_check_relocs #define elf_backend_can_gc_sections 1 +#ifndef USE_REL +#define elf_backend_rela_normal 1 +#endif #if 0 /* not yet */ /* relax support */ #define bfd_elf32_bfd_relax_section m32r_elf_relax_section diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 8af577dff45..841082efe1f 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -1308,6 +1308,9 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; + if (info->relocateable) + return true; + dynobj = elf_hash_table (info)->dynobj; symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -1340,26 +1343,6 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, r_symndx = ELF32_R_SYM (rel->r_info); - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -2325,5 +2308,6 @@ elf32_m68k_reloc_type_class (rela) #define elf_backend_plt_readonly 1 #define elf_backend_want_plt_sym 0 #define elf_backend_got_header_size 12 +#define elf_backend_rela_normal 1 #include "elf32-target.h" diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c index a0784f6b0d0..38e9c13d13c 100644 --- a/bfd/elf32-mcore.c +++ b/bfd/elf32-mcore.c @@ -1,5 +1,6 @@ /* Motorola MCore specific support for 32-bit ELF - Copyright 1994, 1995, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1994, 1995, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -414,6 +415,9 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, (info->relocateable) ? " (relocatable)" : ""); #endif + if (info->relocateable) + return true; + if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */ mcore_elf_howto_init (); @@ -447,32 +451,6 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section, howto = mcore_elf_howto_table [(int) r_type]; r_symndx = ELF32_R_SYM (rel->r_info); - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - - if ((unsigned)ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - addend = rel->r_addend += sec->output_offset + sym->st_value; - } - } - -#ifdef DEBUG - fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n", - howto->name, (int) r_type, r_symndx, (long) offset, (long) addend); -#endif - continue; - } - - /* This is a final link. */ - /* Complain about known relocation that are not yet supported. */ if (howto->special_function == mcore_elf_unsupported_reloc) { @@ -726,5 +704,6 @@ mcore_elf_check_relocs (abfd, info, sec, relocs) #define elf_backend_check_relocs mcore_elf_check_relocs #define elf_backend_can_gc_sections 1 +#define elf_backend_rela_normal 1 #include "elf32-target.h" diff --git a/bfd/elf32-openrisc.c b/bfd/elf32-openrisc.c index 5f603660345..34d4d9facde 100644 --- a/bfd/elf32-openrisc.c +++ b/bfd/elf32-openrisc.c @@ -1,5 +1,5 @@ /* OpenRISC-specific support for 32-bit ELF. - Copyright 2001 Free Software Foundation, Inc. + Copyright 2001, 2002 Free Software Foundation, Inc. Contributed by Johan Rydberg, jrydberg@opencores.org This file is part of BFD, the Binary File Descriptor library. @@ -338,6 +338,9 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; + if (info->relocateable) + return true; + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); relend = relocs + input_section->reloc_count; @@ -361,25 +364,6 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section, || r_type == R_OPENRISC_GNU_VTENTRY) continue; - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - continue; - } - if ((unsigned int) r_type > (sizeof openrisc_elf_howto_table / sizeof (reloc_howto_type))) abort (); @@ -645,6 +629,7 @@ openrisc_elf_final_write_processing (abfd, linker) #define elf_backend_check_relocs openrisc_elf_check_relocs #define elf_backend_can_gc_sections 1 +#define elf_backend_rela_normal 1 #define bfd_elf32_bfd_reloc_type_lookup openrisc_reloc_type_lookup diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 9549d29367e..31d9e0c3f3d 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1,5 +1,5 @@ /* PowerPC-specific support for 32-bit ELF - Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 + Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. @@ -49,6 +49,8 @@ static boolean ppc_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); static int ppc_elf_additional_program_headers PARAMS ((bfd *)); static boolean ppc_elf_modify_segment_map PARAMS ((bfd *)); +static asection *ppc_elf_create_got + PARAMS ((bfd *, struct bfd_link_info *)); static boolean ppc_elf_create_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); @@ -679,20 +681,20 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* 32-bit section relative relocation. */ + /* 16-bit section relative relocation. */ HOWTO (R_PPC_SECTOFF, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - true, /* pc_relative */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ bfd_elf_generic_reloc, /* special_function */ "R_PPC_SECTOFF", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ /* 16-bit lower half section relative relocation. */ HOWTO (R_PPC_SECTOFF_LO, /* type */ @@ -1295,7 +1297,7 @@ ppc_elf_reloc_type_lookup (abfd, code) case BFD_RELOC_HI16_PLTOFF: ppc_reloc = R_PPC_PLT16_HI; break; case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC_PLT16_HA; break; case BFD_RELOC_GPREL16: ppc_reloc = R_PPC_SDAREL16; break; - case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC_SECTOFF; break; + case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC_SECTOFF; break; case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC_SECTOFF_LO; break; case BFD_RELOC_HI16_BASEREL: ppc_reloc = R_PPC_SECTOFF_HI; break; case BFD_RELOC_HI16_S_BASEREL: ppc_reloc = R_PPC_SECTOFF_HA; break; @@ -1632,6 +1634,30 @@ ppc_elf_modify_segment_map (abfd) return true; } +/* The powerpc .got has a blrl instruction in it. Mark it executable. */ + +static asection * +ppc_elf_create_got (abfd, info) + bfd *abfd; + struct bfd_link_info *info; +{ + register asection *s; + flagword flags; + + if (!_bfd_elf_create_got_section (abfd, info)) + return NULL; + + s = bfd_get_section_by_name (abfd, ".got"); + if (s == NULL) + abort (); + + flags = (SEC_ALLOC | SEC_LOAD | SEC_CODE | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED); + if (!bfd_set_section_flags (abfd, s, flags)) + return NULL; + return s; +} + /* We have to create .dynsbss and .rela.sbss here so that they get mapped to output sections (just like _bfd_elf_create_dynamic_sections has to create .dynbss and .rela.bss). */ @@ -1644,6 +1670,9 @@ ppc_elf_create_dynamic_sections (abfd, info) register asection *s; flagword flags; + if (!ppc_elf_create_got (abfd, info)) + return false; + if (!_bfd_elf_create_dynamic_sections (abfd, info)) return false; @@ -1663,7 +1692,13 @@ ppc_elf_create_dynamic_sections (abfd, info) || ! bfd_set_section_alignment (abfd, s, 2)) return false; } - return true; + + s = bfd_get_section_by_name (abfd, ".plt"); + if (s == NULL) + abort (); + + flags = SEC_ALLOC | SEC_CODE | SEC_IN_MEMORY | SEC_LINKER_CREATED; + return bfd_set_section_flags (abfd, s, flags); } /* Adjust a symbol defined by a dynamic object and referenced by a @@ -2119,10 +2154,9 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) { if (dynobj == NULL) elf_hash_table (info)->dynobj = dynobj = abfd; - if (! _bfd_elf_create_got_section (dynobj, info)) + sgot = ppc_elf_create_got (dynobj, info); + if (sgot == NULL) return false; - sgot = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (sgot != NULL); } } @@ -2139,10 +2173,9 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) { if (dynobj == NULL) elf_hash_table (info)->dynobj = dynobj = abfd; - if (! _bfd_elf_create_got_section (dynobj, info)) + sgot = ppc_elf_create_got (dynobj, info); + if (sgot == NULL) return false; - sgot = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (sgot != NULL); } if (srelgot == NULL @@ -2896,6 +2929,9 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, (info->relocateable) ? " (relocatable)" : ""); #endif + if (info->relocateable) + return true; + if (!ppc_elf_howto_table[R_PPC_ADDR32]) /* Initialize howto table if needed. */ ppc_elf_howto_init (); @@ -2940,34 +2976,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, howto = ppc_elf_howto_table[(int) r_type]; r_symndx = ELF32_R_SYM (rel->r_info); - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - addend = rel->r_addend += sec->output_offset + sym->st_value; - } - } - -#ifdef DEBUG - fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n", - howto->name, - (int) r_type, - r_symndx, - (long) offset, - (long) addend); -#endif - continue; - } - - /* This is a final link. */ if (r_symndx < symtab_hdr->sh_info) { sym = local_syms + r_symndx; @@ -3781,6 +3789,7 @@ ppc_elf_grok_psinfo (abfd, note) #define elf_backend_can_refcount 1 #define elf_backend_got_header_size 12 #define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE +#define elf_backend_rela_normal 1 #define bfd_elf32_bfd_merge_private_bfd_data ppc_elf_merge_private_bfd_data #define bfd_elf32_bfd_relax_section ppc_elf_relax_section diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 1c112695d40..ed5f3f0d127 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1632,6 +1632,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; + if (info->relocateable) + return true; + htab = elf_s390_hash_table (info); symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -1661,30 +1664,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, bfd_set_error (bfd_error_bad_value); return false; } - howto = elf_howto_table + r_type; + howto = elf_howto_table + r_type; r_symndx = ELF32_R_SYM (rel->r_info); - - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -2467,6 +2449,7 @@ elf_s390_grok_prstatus (abfd, note) #define elf_backend_want_plt_sym 0 #define elf_backend_got_header_size 12 #define elf_backend_plt_header_size PLT_ENTRY_SIZE +#define elf_backend_rela_normal 1 #define elf_info_to_howto elf_s390_info_to_howto diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c index 484acdded47..d6b8dd3c492 100644 --- a/bfd/elf32-xstormy16.c +++ b/bfd/elf32-xstormy16.c @@ -790,6 +790,9 @@ xstormy16_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd *dynobj; asection *splt; + if (info->relocateable) + return true; + symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); relend = relocs + input_section->reloc_count; @@ -818,28 +821,6 @@ xstormy16_elf_relocate_section (output_bfd, info, input_bfd, input_section, continue; r_symndx = ELF32_R_SYM (rel->r_info); - - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections [r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ howto = xstormy16_elf_howto_table + ELF32_R_TYPE (rel->r_info); h = NULL; sym = NULL; @@ -1108,6 +1089,7 @@ xstormy16_elf_gc_sweep_hook (abfd, info, sec, relocs) xstormy16_elf_finish_dynamic_sections #define elf_backend_can_gc_sections 1 +#define elf_backend_rela_normal 1 #define bfd_elf32_bfd_reloc_type_lookup xstormy16_reloc_type_lookup #define bfd_elf32_bfd_relax_section xstormy16_elf_relax_section diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 6adc2026755..d25c25fd89f 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -39,7 +39,21 @@ static reloc_howto_type *ppc64_elf_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); static void ppc64_elf_info_to_howto PARAMS ((bfd *abfd, arelent *cache_ptr, Elf64_Internal_Rela *dst)); -static bfd_reloc_status_type ppc64_elf_addr16_ha_reloc +static bfd_reloc_status_type ppc64_elf_ha_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_brtaken_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_sectoff_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_sectoff_ha_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_toc_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_toc_ha_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_toc64_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static bfd_reloc_status_type ppc64_elf_unhandled_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); static boolean ppc64_elf_set_private_flags PARAMS ((bfd *, flagword)); @@ -101,12 +115,6 @@ static boolean ppc64_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); -/* Mask to set RA in memory instructions. */ -#define RA_REGISTER_MASK 0x001f0000 - -/* Value to shift register by to insert RA. */ -#define RA_REGISTER_SHIFT 16 - /* The name of the dynamic interpreter. This is put in the .interp section. */ #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" @@ -146,6 +154,10 @@ static boolean ppc64_elf_finish_dynamic_sections /* Pad with this. */ #define NOP 0x60000000 +/* Some other nops. */ +#define CROR_151515 0x4def7b82 +#define CROR_313131 0x4ffffb82 + /* .glink entries for the first 32k functions are two instructions. */ #define LI_R0_0 0x38000000 /* li %r0,0 */ #define B_DOT 0x48000000 /* b . */ @@ -273,7 +285,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_ha_reloc, /* special_function */ "R_PPC64_ADDR16_HA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -306,7 +318,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_brtaken_reloc, /* special_function */ "R_PPC64_ADDR14_BRTAKEN",/* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -323,7 +335,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_brtaken_reloc, /* special_function */ "R_PPC64_ADDR14_BRNTAKEN",/* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -370,7 +382,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_brtaken_reloc, /* special_function */ "R_PPC64_REL14_BRTAKEN", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -387,7 +399,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { true, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_brtaken_reloc, /* special_function */ "R_PPC64_REL14_BRNTAKEN",/* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -403,7 +415,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GOT16", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -419,7 +431,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GOT16_LO", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -435,7 +447,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GOT16_HI", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -451,7 +463,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GOT16_HA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -470,7 +482,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_COPY", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -486,7 +498,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GLOB_DAT", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -502,7 +514,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_JMP_SLOT", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -580,7 +592,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLT32", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -612,7 +624,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLT16_LO", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -628,7 +640,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLT16_HI", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -644,31 +656,29 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLT16_HA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ 0xffff, /* dst_mask */ false), /* pcrel_offset */ - /* 32-bit section relative relocation. */ - /* FIXME: Verify R_PPC64_SECTOFF. Seems strange with size=2 and - dst_mask=0. */ + /* 16-bit section relative relocation. */ HOWTO (R_PPC64_SECTOFF, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - true, /* pc_relative */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_sectoff_reloc, /* special_function */ "R_PPC64_SECTOFF", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ + 0xffff, /* dst_mask */ + false), /* pcrel_offset */ - /* 16-bit lower half section relative relocation. */ + /* Like R_PPC64_SECTOFF, but no overflow warning. */ HOWTO (R_PPC64_SECTOFF_LO, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -676,7 +686,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_sectoff_reloc, /* special_function */ "R_PPC64_SECTOFF_LO", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -691,7 +701,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_sectoff_reloc, /* special_function */ "R_PPC64_SECTOFF_HI", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -706,7 +716,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_sectoff_ha_reloc, /* special_function */ "R_PPC64_SECTOFF_HA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -714,8 +724,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false), /* pcrel_offset */ /* Like R_PPC64_REL24 without touching the two least significant - bits. */ - /* FIXME: Verify R_PPC64_ADDR30. */ + bits. Should have been named R_PPC64_REL30! */ HOWTO (R_PPC64_ADDR30, /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -771,7 +780,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_ha_reloc, /* special_function */ "R_PPC64_ADDR16_HIGHERA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -802,7 +811,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_ha_reloc, /* special_function */ "R_PPC64_ADDR16_HIGHESTA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -847,7 +856,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLT64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -864,7 +873,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { true, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTREL64", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -881,7 +890,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_toc_reloc, /* special_function */ "R_PPC64_TOC16", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -898,7 +907,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_toc_reloc, /* special_function */ "R_PPC64_TOC16_LO", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -915,7 +924,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_toc_reloc, /* special_function */ "R_PPC64_TOC16_HI", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -934,7 +943,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_toc_ha_reloc, /* special_function */ "R_PPC64_TOC16_HA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -951,7 +960,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_toc64_reloc, /* special_function */ "R_PPC64_TOC", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -974,7 +983,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTGOT16", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -990,7 +999,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTGOT16_LO", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1006,7 +1015,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTGOT16_HI", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1024,7 +1033,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont,/* complain_on_overflow */ - ppc64_elf_addr16_ha_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTGOT16_HA", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1069,7 +1078,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GOT16_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1084,7 +1093,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_GOT16_LO_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1099,7 +1108,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLT16_LO_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1107,21 +1116,19 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false), /* pcrel_offset */ /* Like R_PPC64_SECTOFF, but for instructions with a DS field. */ - /* FIXME: Verify R_PPC64_SECTOFF. Seems strange with size=2 and - dst_mask=0. */ HOWTO (R_PPC64_SECTOFF_DS, /* type */ 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 32, /* bitsize */ - true, /* pc_relative */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_sectoff_reloc, /* special_function */ "R_PPC64_SECTOFF_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ - 0, /* dst_mask */ - true), /* pcrel_offset */ + 0xfffc, /* dst_mask */ + false), /* pcrel_offset */ /* Like R_PPC64_SECTOFF_LO, but for instructions with a DS field. */ HOWTO (R_PPC64_SECTOFF_LO_DS, /* type */ @@ -1131,7 +1138,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_sectoff_reloc, /* special_function */ "R_PPC64_SECTOFF_LO_DS",/* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1146,7 +1153,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_toc_reloc, /* special_function */ "R_PPC64_TOC16_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1161,7 +1168,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_toc_reloc, /* special_function */ "R_PPC64_TOC16_LO_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1177,7 +1184,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTGOT16_DS", /* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1193,7 +1200,7 @@ static reloc_howto_type ppc64_elf_howto_raw[] = { false, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + ppc64_elf_unhandled_reloc, /* special_function */ "R_PPC64_PLTGOT16_LO_DS",/* name */ false, /* partial_inplace */ 0, /* src_mask */ @@ -1319,7 +1326,7 @@ ppc64_elf_reloc_type_lookup (abfd, code) break; case BFD_RELOC_HI16_S_PLTOFF: ppc_reloc = R_PPC64_PLT16_HA; break; - case BFD_RELOC_32_BASEREL: ppc_reloc = R_PPC64_SECTOFF; + case BFD_RELOC_16_BASEREL: ppc_reloc = R_PPC64_SECTOFF; break; case BFD_RELOC_LO16_BASEREL: ppc_reloc = R_PPC64_SECTOFF_LO; break; @@ -1417,41 +1424,265 @@ ppc64_elf_info_to_howto (abfd, cache_ptr, dst) /* Handle the R_PPC_ADDR16_HA and similar relocs. */ static bfd_reloc_status_type -ppc64_elf_addr16_ha_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd ATTRIBUTE_UNUSED; +ppc64_elf_ha_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + /* Adjust the addend for sign extension of the low 16 bits. + We won't actually be using the low 16 bits, so trashing them + doesn't matter. */ + reloc_entry->addend += 0x8000; + return bfd_reloc_continue; +} + +static bfd_reloc_status_type +ppc64_elf_brtaken_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; arelent *reloc_entry; asymbol *symbol; - PTR data ATTRIBUTE_UNUSED; + PTR data; asection *input_section; bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; + char **error_message; { - bfd_vma relocation; + long insn; + enum elf_ppc_reloc_type r_type; + bfd_size_type octets; + /* Disabled until we sort out how ld should choose 'y' vs 'at'. */ + boolean is_power4 = false; + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + octets = reloc_entry->address * bfd_octets_per_byte (abfd); + insn = bfd_get_32 (abfd, (bfd_byte *) data + octets); + insn &= ~(0x01 << 21); + r_type = (enum elf_ppc_reloc_type) reloc_entry->howto->type; + if (r_type == R_PPC64_ADDR14_BRTAKEN + || r_type == R_PPC64_REL14_BRTAKEN) + insn |= 0x01 << 21; /* 'y' or 't' bit, lowest bit of BO field. */ + + if (is_power4) + { + /* Set 'a' bit. This is 0b00010 in BO field for branch + on CR(BI) insns (BO == 001at or 011at), and 0b01000 + for branch on CTR insns (BO == 1a00t or 1a01t). */ + if ((insn & (0x14 << 21)) == (0x04 << 21)) + insn |= 0x02 << 21; + else if ((insn & (0x14 << 21)) == (0x10 << 21)) + insn |= 0x08 << 21; + else + return bfd_reloc_continue; + } + else { - reloc_entry->address += input_section->output_offset; - return bfd_reloc_ok; + bfd_vma target = 0; + bfd_vma from; + + if (!bfd_is_com_section (symbol->section)) + target = symbol->value; + target += symbol->section->output_section->vma; + target += symbol->section->output_offset; + target += reloc_entry->addend; + + from = (reloc_entry->address + + input_section->output_offset + + input_section->output_section->vma); + + /* Invert 'y' bit if not the default. */ + if ((bfd_signed_vma) (target - from) < 0) + insn ^= 0x01 << 21; } + bfd_put_32 (abfd, (bfd_vma) insn, (bfd_byte *) data + octets); + return bfd_reloc_continue; +} + +static bfd_reloc_status_type +ppc64_elf_sectoff_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); - if (reloc_entry->address > input_section->_cooked_size) - return bfd_reloc_outofrange; + /* Subtract the symbol section base address. */ + reloc_entry->addend -= symbol->section->output_section->vma; + return bfd_reloc_continue; +} - if (bfd_is_com_section (symbol->section)) - relocation = 0; - else - relocation = symbol->value; +static bfd_reloc_status_type +ppc64_elf_sectoff_ha_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + /* Subtract the symbol section base address. */ + reloc_entry->addend -= symbol->section->output_section->vma; + + /* Adjust the addend for sign extension of the low 16 bits. */ + reloc_entry->addend += 0x8000; + return bfd_reloc_continue; +} + +static bfd_reloc_status_type +ppc64_elf_toc_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + bfd_vma TOCstart; + + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + TOCstart = _bfd_get_gp_value (input_section->output_section->owner); + if (TOCstart == 0) + TOCstart = ppc64_elf_toc (input_section->output_section->owner); - relocation += symbol->section->output_section->vma; - relocation += symbol->section->output_offset; - relocation += reloc_entry->addend; + /* Subtract the TOC base address. */ + reloc_entry->addend -= TOCstart + TOC_BASE_OFF; + return bfd_reloc_continue; +} + +static bfd_reloc_status_type +ppc64_elf_toc_ha_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + bfd_vma TOCstart; + + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + TOCstart = _bfd_get_gp_value (input_section->output_section->owner); + if (TOCstart == 0) + TOCstart = ppc64_elf_toc (input_section->output_section->owner); - reloc_entry->addend += (relocation & 0x8000) << 1; + /* Subtract the TOC base address. */ + reloc_entry->addend -= TOCstart + TOC_BASE_OFF; + /* Adjust the addend for sign extension of the low 16 bits. */ + reloc_entry->addend += 0x8000; return bfd_reloc_continue; } +static bfd_reloc_status_type +ppc64_elf_toc64_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + bfd_vma TOCstart; + bfd_size_type octets; + + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + TOCstart = _bfd_get_gp_value (input_section->output_section->owner); + if (TOCstart == 0) + TOCstart = ppc64_elf_toc (input_section->output_section->owner); + + octets = reloc_entry->address * bfd_octets_per_byte (abfd); + bfd_put_64 (abfd, TOCstart + TOC_BASE_OFF, (bfd_byte *) data + octets); + return bfd_reloc_ok; +} + +static bfd_reloc_status_type +ppc64_elf_unhandled_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message; +{ + /* If this is a relocatable link (output_bfd test tells us), just + call the generic function. Any adjustment will be done at final + link time. */ + if (output_bfd != NULL) + return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, error_message); + + if (error_message != NULL) + { + static char buf[60]; + sprintf (buf, "generic linker can't handle %s", + reloc_entry->howto->name); + *error_message = buf; + } + return bfd_reloc_dangerous; +} + /* Function to set whether a module needs the -mrelocatable bit set. */ static boolean @@ -1731,6 +1962,9 @@ struct ppc_link_hash_table /* Set on error. */ int plt_overflow; + /* Set if we detect a reference undefined weak symbol. */ + unsigned int have_undefweak; + /* Small local sym to section mapping cache. */ struct sym_sec_cache sym_sec; }; @@ -1800,6 +2034,7 @@ ppc64_elf_link_hash_table_create (abfd) htab->sglink = NULL; htab->sfpr = NULL; htab->plt_overflow = 0; + htab->have_undefweak = 0; htab->sym_sec.abfd = NULL; return &htab->elf.root; @@ -2515,6 +2750,10 @@ func_desc_adjust (h, inf) if (!((struct ppc_link_hash_entry *) h)->is_func) return true; + if (h->root.type == bfd_link_hash_undefweak + && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR)) + htab->have_undefweak = true; + if (h->plt.refcount > 0 && h->root.root.string[0] == '.' && h->root.root.string[1] != '\0') @@ -2610,6 +2849,7 @@ ppc64_elf_func_desc_adjust (obfd, info) unsigned int lowest_restf = MAX_SAVE_FPR + 2; unsigned int i; struct elf_link_hash_entry *h; + bfd_byte *p; char sym[10]; htab = ppc_hash_table (info); @@ -2660,41 +2900,52 @@ ppc64_elf_func_desc_adjust (obfd, info) } } + elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info); + htab->sfpr->_raw_size = ((MAX_SAVE_FPR + 2 - lowest_savef) * 4 + (MAX_SAVE_FPR + 2 - lowest_restf) * 4); if (htab->sfpr->_raw_size == 0) { - _bfd_strip_section_from_output (info, htab->sfpr); - } - else - { - bfd_byte *p = (bfd_byte *) bfd_alloc (htab->elf.dynobj, - htab->sfpr->_raw_size); - if (p == NULL) - return false; - htab->sfpr->contents = p; - - for (i = lowest_savef; i <= MAX_SAVE_FPR; i++) + if (!htab->have_undefweak) { - unsigned int fpr = i << 21; - unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8; - bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p); - p += 4; + _bfd_strip_section_from_output (info, htab->sfpr); + return true; } + + htab->sfpr->_raw_size = 4; + } + + p = (bfd_byte *) bfd_alloc (htab->elf.dynobj, htab->sfpr->_raw_size); + if (p == NULL) + return false; + htab->sfpr->contents = p; + + for (i = lowest_savef; i <= MAX_SAVE_FPR; i++) + { + unsigned int fpr = i << 21; + unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8; + bfd_put_32 (htab->elf.dynobj, STFD_FR0_0R1 + fpr + stackoff, p); + p += 4; + } + if (lowest_savef <= MAX_SAVE_FPR) + { bfd_put_32 (htab->elf.dynobj, BLR, p); p += 4; + } - for (i = lowest_restf; i <= MAX_SAVE_FPR; i++) - { - unsigned int fpr = i << 21; - unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8; - bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p); - p += 4; - } - bfd_put_32 (htab->elf.dynobj, BLR, p); + for (i = lowest_restf; i <= MAX_SAVE_FPR; i++) + { + unsigned int fpr = i << 21; + unsigned int stackoff = (1 << 16) - (MAX_SAVE_FPR + 1 - i) * 8; + bfd_put_32 (htab->elf.dynobj, LFD_FR0_0R1 + fpr + stackoff, p); p += 4; } + if (lowest_restf <= MAX_SAVE_FPR + || htab->sfpr->_raw_size == 4) + { + bfd_put_32 (htab->elf.dynobj, BLR, p); + } elf_link_hash_traverse (&htab->elf, func_desc_adjust, (PTR) info); return true; @@ -3285,69 +3536,61 @@ ppc64_elf_size_dynamic_sections (output_bfd, info) return true; } -/* Called after we have seen all the input files/sections, but before - final symbol resolution and section placement has been determined. +/* Called after we have determined section placement. If sections + move, we'll be called again. Provide a value for TOCstart. */ - We use this hook to provide a value for TOCstart, which we store in - the output bfd elf_gp. */ - -boolean -ppc64_elf_set_toc (obfd, info) +bfd_vma +ppc64_elf_toc (obfd) bfd *obfd; - struct bfd_link_info *info; { - if (!info->relocateable) - { - asection *s; - bfd_vma TOCstart; + asection *s; + bfd_vma TOCstart; - /* The TOC consists of sections .got, .toc, .tocbss, .plt in that - order. The TOC starts where the first of these sections starts. */ - s = bfd_get_section_by_name (obfd, ".got"); - if (s == NULL) - s = bfd_get_section_by_name (obfd, ".toc"); + /* The TOC consists of sections .got, .toc, .tocbss, .plt in that + order. The TOC starts where the first of these sections starts. */ + s = bfd_get_section_by_name (obfd, ".got"); + if (s == NULL) + s = bfd_get_section_by_name (obfd, ".toc"); + if (s == NULL) + s = bfd_get_section_by_name (obfd, ".tocbss"); + if (s == NULL) + s = bfd_get_section_by_name (obfd, ".plt"); + if (s == NULL) + { + /* This may happen for + o references to TOC base (SYM@toc / TOC[tc0]) without a + .toc directive + o bad linker script + o --gc-sections and empty TOC sections + + FIXME: Warn user? */ + + /* Look for a likely section. We probably won't even be + using TOCstart. */ + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY)) + == (SEC_ALLOC | SEC_SMALL_DATA)) + break; if (s == NULL) - s = bfd_get_section_by_name (obfd, ".tocbss"); + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA)) + == (SEC_ALLOC | SEC_SMALL_DATA)) + break; if (s == NULL) - s = bfd_get_section_by_name (obfd, ".plt"); + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC) + break; if (s == NULL) - { - /* This may happen for - o references to TOC base (SYM@toc / TOC[tc0]) without a - .toc directive - o bad linker script - o --gc-sections and empty TOC sections - - FIXME: Warn user? */ - - /* Look for a likely section. We probably won't even be - using TOCstart. */ - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA | SEC_READONLY)) - == (SEC_ALLOC | SEC_SMALL_DATA)) - break; - if (s == NULL) - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & (SEC_ALLOC | SEC_SMALL_DATA)) - == (SEC_ALLOC | SEC_SMALL_DATA)) - break; - if (s == NULL) - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & (SEC_ALLOC | SEC_READONLY)) == SEC_ALLOC) - break; - if (s == NULL) - for (s = obfd->sections; s != NULL; s = s->next) - if ((s->flags & SEC_ALLOC) == SEC_ALLOC) - break; - } + for (s = obfd->sections; s != NULL; s = s->next) + if ((s->flags & SEC_ALLOC) == SEC_ALLOC) + break; + } - TOCstart = 0; - if (s != NULL) - TOCstart = s->output_section->vma + s->output_offset; + TOCstart = 0; + if (s != NULL) + TOCstart = s->output_section->vma + s->output_offset; - elf_gp (obfd) = TOCstart; - } - return true; + return TOCstart; } /* PowerPC64 .plt entries are 24 bytes long, which doesn't divide @@ -3642,6 +3885,9 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* Disabled until we sort out how ld should choose 'y' vs 'at'. */ boolean is_power4 = false; + if (info->relocateable) + return true; + /* Initialize howto table if needed. */ if (!ppc64_elf_howto_table[R_PPC64_ADDR32]) ppc_howto_init (); @@ -3668,32 +3914,11 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, unsigned long r_symndx; bfd_vma relocation; boolean unresolved_reloc; - boolean has_nop; long insn; + bfd_vma from; r_type = (enum elf_ppc_reloc_type) ELF64_R_TYPE (rel->r_info); r_symndx = ELF64_R_SYM (rel->r_info); - - if (info->relocateable) - { - /* This is a relocatable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if ((unsigned) ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - continue; - } - - /* This is a final link. */ - offset = rel->r_offset; addend = rel->r_addend; r = bfd_reloc_other; @@ -3716,6 +3941,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, sym_name = ""; relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); + /* rel may have changed, update our copy of addend. */ addend = rel->r_addend; } else @@ -3791,8 +4017,12 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, } else { + from = (offset + + input_section->output_offset + + input_section->output_section->vma); + /* Invert 'y' bit if not the default. */ - if ((bfd_signed_vma) (relocation - offset) < 0) + if ((bfd_signed_vma) (relocation + addend - from) < 0) insn ^= 0x01 << 21; } @@ -3800,57 +4030,71 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, break; case R_PPC64_REL24: - case R_PPC64_ADDR24: - /* An ADDR24 or REL24 branching to a linkage function may be - followed by a nop that we have to replace with a ld in - order to restore the TOC base pointer. Only calls to - shared objects need to alter the TOC base. These are - recognized by their need for a PLT entry. */ - has_nop = 0; + /* A REL24 branching to a linkage function is followed by a + nop. We replace the nop with a ld in order to restore + the TOC base pointer. Only calls to shared objects need + to alter the TOC base. These are recognized by their + need for a PLT entry. */ if (h != NULL && h->plt.offset != (bfd_vma) -1 && htab->sstub != NULL) { - /* plt.offset here is the offset into the stub section. */ - relocation = (htab->sstub->output_section->vma - + htab->sstub->output_offset - + h->plt.offset); - unresolved_reloc = false; - - /* Make sure that there really is an instruction after - the branch that we can decode. */ + boolean can_plt_call = 0; + if (offset + 8 <= input_section->_cooked_size) { - bfd_byte *pnext; - - pnext = contents + offset + 4; - insn = bfd_get_32 (input_bfd, pnext); - - if (insn == 0x60000000 /* nop (ori r0,r0,0) */ - || insn == 0x4def7b82 /* cror 15,15,15 */ - || insn == 0x4ffffb82) /* cror 31,31,31 */ + insn = bfd_get_32 (input_bfd, contents + offset + 4); + if (insn == NOP + || insn == CROR_151515 || insn == CROR_313131) { - bfd_put_32 (input_bfd, - (bfd_vma) 0xe8410028, /* ld r2,40(r1) */ - pnext); - has_nop = 1; + bfd_put_32 (input_bfd, (bfd_vma) LD_R2_40R1, + contents + offset + 4); + can_plt_call = 1; } } + + if (!can_plt_call) + { + /* If this is a plain branch rather than a branch + and link, don't require a nop. */ + insn = bfd_get_32 (input_bfd, contents + offset); + if ((insn & 1) == 0) + can_plt_call = 1; + } + + if (can_plt_call) + { + /* plt.offset here is the offset into the stub section. */ + relocation = (htab->sstub->output_section->vma + + htab->sstub->output_offset + + h->plt.offset); + addend = 0; + unresolved_reloc = false; + } } if (h != NULL && h->root.type == bfd_link_hash_undefweak - && r_type == R_PPC64_REL24 - && addend == 0 - && relocation == 0) + && relocation == 0 + && addend == 0) { - /* Tweak calls to undefined weak functions to behave as - if the "called" function immediately returns. We can - thus call to a weak function without first checking - whether the function is defined. */ - relocation = 4; - if (has_nop) - relocation = 8; + /* Tweak calls to undefined weak functions to point at a + blr. We can thus call a weak function without first + checking whether the function is defined. We have a + blr at the end of .sfpr. */ + BFD_ASSERT (htab->sfpr->_raw_size != 0); + relocation = (htab->sfpr->_raw_size - 4 + + htab->sfpr->output_offset + + htab->sfpr->output_section->vma); + from = (offset + + input_section->output_offset + + input_section->output_section->vma); + + /* But let's not be silly about it. If the blr isn't in + reach, just go to the next instruction. */ + if (relocation - from + (1 << 25) >= (1 << 26) + || htab->sfpr->_raw_size == 0) + relocation = from + 4; } break; } @@ -4593,6 +4837,7 @@ ppc64_elf_finish_dynamic_sections (output_bfd, info) #define elf_backend_plt_header_size PLT_INITIAL_ENTRY_SIZE #define elf_backend_can_gc_sections 1 #define elf_backend_can_refcount 1 +#define elf_backend_rela_normal 1 #define bfd_elf64_bfd_reloc_type_lookup ppc64_elf_reloc_type_lookup #define bfd_elf64_bfd_set_private_flags ppc64_elf_set_private_flags diff --git a/bfd/elf64-ppc.h b/bfd/elf64-ppc.h index b261a584a2b..beb637b500e 100644 --- a/bfd/elf64-ppc.h +++ b/bfd/elf64-ppc.h @@ -17,6 +17,6 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -boolean ppc64_elf_set_toc PARAMS ((bfd *, struct bfd_link_info *)); +bfd_vma ppc64_elf_toc PARAMS ((bfd *)); boolean ppc64_elf_size_stubs PARAMS ((bfd *, struct bfd_link_info *, int *)); boolean ppc64_elf_build_stubs PARAMS ((bfd *, struct bfd_link_info *)); diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 23c1bfa9314..40f4908dcf3 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1587,6 +1587,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; + if (info->relocateable) + return true; + htab = elf_s390_hash_table (info); symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -1616,30 +1619,9 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, bfd_set_error (bfd_error_bad_value); return false; } - howto = elf_howto_table + r_type; + howto = elf_howto_table + r_type; r_symndx = ELF64_R_SYM (rel->r_info); - - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -2384,6 +2366,7 @@ const struct elf_size_info s390_elf64_size_info = #define elf_backend_want_plt_sym 0 #define elf_backend_got_header_size 24 #define elf_backend_plt_header_size PLT_ENTRY_SIZE +#define elf_backend_rela_normal 1 #define elf_info_to_howto elf_s390_info_to_howto diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index cc700132445..b980344888e 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1494,6 +1494,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; + if (info->relocateable) + return true; + htab = elf64_x86_64_hash_table (info); symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); @@ -1524,30 +1527,9 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, bfd_set_error (bfd_error_bad_value); return false; } - howto = x86_64_elf_howto_table + r_type; + howto = x86_64_elf_howto_table + r_type; r_symndx = ELF64_R_SYM (rel->r_info); - - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sec = local_sections[r_symndx]; - rel->r_addend += sec->output_offset + sym->st_value; - } - } - - continue; - } - - /* This is a final link. */ h = NULL; sym = NULL; sec = NULL; @@ -2230,6 +2212,7 @@ elf64_x86_64_finish_dynamic_sections (output_bfd, info) #define elf_backend_want_plt_sym 0 #define elf_backend_got_header_size (GOT_ENTRY_SIZE*3) #define elf_backend_plt_header_size PLT_ENTRY_SIZE +#define elf_backend_rela_normal 1 #define elf_info_to_howto elf64_x86_64_info_to_howto diff --git a/bfd/elfarm-nabi.c b/bfd/elfarm-nabi.c index 7ced6807365..2d791ded9e4 100644 --- a/bfd/elfarm-nabi.c +++ b/bfd/elfarm-nabi.c @@ -138,8 +138,8 @@ static reloc_howto_type elf32_arm_howto_table[] = bfd_elf_generic_reloc, /* special_function */ "R_ARM_ABS16", /* name */ false, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ false), /* pcrel_offset */ /* 12 bit absolute */ diff --git a/bfd/elflink.h b/bfd/elflink.h index 06035b31bee..bfe63742522 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -6754,6 +6754,12 @@ elf_link_input_bfd (finfo, input_bfd) void (*reloc_emitter) PARAMS ((bfd *, asection *, Elf_Internal_Shdr *, Elf_Internal_Rela *)); + boolean rela_normal; + + input_rel_hdr = &elf_section_data (o)->rel_hdr; + rela_normal = (bed->rela_normal + && (input_rel_hdr->sh_entsize + == sizeof (Elf_External_Rela))); /* Adjust the reloc addresses and symbol indices. */ @@ -6776,7 +6782,7 @@ elf_link_input_bfd (finfo, input_bfd) irela->r_offset += o->output_offset; /* Relocs in an executable have to be virtual addresses. */ - if (finfo->info->emitrelocations) + if (!finfo->info->relocateable) irela->r_offset += o->output_section->vma; r_symndx = ELF_R_SYM (irela->r_info); @@ -6827,10 +6833,9 @@ elf_link_input_bfd (finfo, input_bfd) processor specific section. If we have discarded a section, the output_section will be the absolute section. */ - if (sec != NULL - && (bfd_is_abs_section (sec) - || (sec->output_section != NULL - && bfd_is_abs_section (sec->output_section)))) + if (bfd_is_abs_section (sec) + || (sec != NULL + && bfd_is_abs_section (sec->output_section))) r_symndx = 0; else if (sec == NULL || sec->owner == NULL) { @@ -6842,6 +6847,11 @@ elf_link_input_bfd (finfo, input_bfd) r_symndx = sec->output_section->target_index; BFD_ASSERT (r_symndx != 0); } + + /* Adjust the addend according to where the + section winds up in the output section. */ + if (rela_normal) + irela->r_addend += sec->output_offset; } else { @@ -6900,7 +6910,6 @@ elf_link_input_bfd (finfo, input_bfd) else reloc_emitter = elf_link_output_relocs; - input_rel_hdr = &elf_section_data (o)->rel_hdr; (*reloc_emitter) (output_bfd, o, input_rel_hdr, internal_relocs); input_rel_hdr = elf_section_data (o)->rel_hdr2; @@ -6908,7 +6917,8 @@ elf_link_input_bfd (finfo, input_bfd) { internal_relocs += (NUM_SHDR_ENTRIES (input_rel_hdr) * bed->s->int_rels_per_ext_rel); - reloc_emitter (output_bfd, o, input_rel_hdr, internal_relocs); + (*reloc_emitter) (output_bfd, o, input_rel_hdr, + internal_relocs); } } diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index aadb963c2d9..f92ab6ae0d8 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -3502,6 +3502,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, elf_section_data(input_section->output_section) ->this_hdr.sh_flags |= flags; + return true; } gp_val = _bfd_get_gp_value (output_bfd); @@ -3534,29 +3535,9 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, ret_val = false; continue; } + howto = lookup_howto (r_type); r_symndx = ELFNN_R_SYM (rel->r_info); - - if (info->relocateable) - { - /* This is a relocateable link. We don't have to change - anything, unless the reloc is against a section symbol, - in which case we have to adjust according to where the - section symbol winds up in the output section. */ - if (r_symndx < symtab_hdr->sh_info) - { - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - { - sym_sec = local_sections[r_symndx]; - rel->r_addend += sym_sec->output_offset; - } - } - continue; - } - - /* This is a final link. */ - h = NULL; sym = NULL; sym_sec = NULL; @@ -4561,6 +4542,7 @@ elfNN_hpux_backend_section_from_bfd_section (abfd, sec, retval) #define elf_backend_copy_indirect_symbol elfNN_ia64_hash_copy_indirect #define elf_backend_hide_symbol elfNN_ia64_hash_hide_symbol #define elf_backend_reloc_type_class elfNN_ia64_reloc_type_class +#define elf_backend_rela_normal 1 #include "elfNN-target.h" diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 25ddd0e0b3b..e6b63d14a1d 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -390,6 +390,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define elf_backend_default_use_rela_p !USE_REL #endif +#ifndef elf_backend_rela_normal +#define elf_backend_rela_normal 0 +#endif + #ifndef ELF_MACHINE_ALT1 #define ELF_MACHINE_ALT1 0 #endif @@ -470,6 +474,7 @@ static const struct elf_backend_data elfNN_bed = elf_backend_may_use_rel_p, elf_backend_may_use_rela_p, elf_backend_default_use_rela_p, + elf_backend_rela_normal, elf_backend_sign_extend_vma, elf_backend_want_got_plt, elf_backend_plt_readonly, diff --git a/bfd/opncls.c b/bfd/opncls.c index 31af2bd0c35..200f6c78c59 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -96,6 +96,8 @@ _bfd_new_bfd_contained_in (obfd) bfd *nbfd; nbfd = _bfd_new_bfd (); + if (nbfd == NULL) + return NULL; nbfd->xvec = obfd->xvec; nbfd->my_archive = obfd; nbfd->direction = read_direction; diff --git a/bfd/syms.c b/bfd/syms.c index 4309c0d94f8..01f7eee2cce 100644 --- a/bfd/syms.c +++ b/bfd/syms.c @@ -1297,7 +1297,8 @@ _bfd_stab_section_find_nearest_line (abfd, symbols, section, offset, pfound, *pfound = true; - if (IS_ABSOLUTE_PATH(file_name) || directory_name == NULL) + if (file_name == NULL || IS_ABSOLUTE_PATH (file_name) + || directory_name == NULL) *pfilename = file_name; else { diff --git a/binutils/ChangeLog b/binutils/ChangeLog index ec1155716ec..91900a4f42f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,77 @@ +2002-05-09 Alan Modra + + * configure.in: Replace `*pe' with `pe' throughout. + * configure: Regenerate. + + Merge from mainline + 2002-05-06 Alan Modra + * dlltool.c (process_def_file): Add missing prototype. + (new_directive, assemble_file, main): Likewise. + (process_def_file, new_directive): Make static. + (inform): Rewrite using VA_FIXEDARG. + * dllwrap.c (mybasename): Add missing prototype. + (strhash, main): Likewise. + (inform): Rewrite using VA_FIXEDARG. + (warn): Likewise. + (cleanup_and_exit): Use old style function definition. + (strhash): Likewise. + * windres.c (define_resource): Use one memset to clear all of + struct res_resource. + * rcparse.y: Remove newcmd rule. Move rcparse_discard_strings + call to rules that need no lookahead. Check for no lookahead. + + 2002-05-06 Borut Razem + * rclex.l (get_string): Correct "strings" list handling. + * resrc.c (read_rc_file): Discard strings. + + 2002-05-04 Bob Byrnes + * size.c (display_archive): Add last_arfile and code to close archives. + + 2002-05-01 Alan Modra + * nm.c (print_symbol): Check returned filename from + bfd_find_nearest_line is non-NULL. + + 2002-04-17 Thiemo Seufer + * arparse.y: Fix syntax warning. + + 2002-04-16 Nick Clifton + * rcparse.y: Set MEMFLAG_DISCARDABLE by default. + + 2002-04-15 Nick Clifton + * resrc.c (write_rc_dialog): If charset is non-default value + display all of the DIALOGEX parameters. + + 2002-04-15 Eric Kohl + * rcparse.y: Allow two to five parameter in FONT statement of + DIALOGEX resources. + * resbin.c (bin_to_res_dialog): Fixed read/write code for dialogex + resource data. + (res_to_bin_dialog): Likewise. + * windres.h: Added misssing charset variable to dialog_ex + structure. + + 2002-04-10 Nick Clifton + * rcparse.y: Set MEMFLAG_PURE by default. + + 2002-04-09 Bernd Herd + * rcparse.y: CLASS definitions in DIALOG resources + are quoted. + Fix typo in BEDIT warning. + Don't add default dialog style when explicit style specified. + Add WS_CAPTION dialog style if CAPTION is specified. + * rclex.l (handle_quotes): "\xhex" encoding in strings corrected. + (handle_quotes) "\a" escape (used for right justified key + definitions in menus) is encodes as binary 8. + * resrc.c (write_rc_dialog): Print style even if it is 0. + (write_rc_directory): Fix overlooked sublang shift bug. + (bin_to_res_dialog): Don't print empty dialog caption. + * resbin.c (bin_to_res_dialog): Use signature to identify + DIALOGEX. + * windres.c (main): Set default LANGUAGE to english/us. + + 2002-04-09 Gunnar Degnbol + * resrc.c: print CLASS names in quotes + 2002-04-27 Alan Modra Merge from mainline diff --git a/binutils/arparse.y b/binutils/arparse.y index a03c2c42e2f..cf0ece1b92a 100644 --- a/binutils/arparse.y +++ b/binutils/arparse.y @@ -74,6 +74,7 @@ session: command_line: command NEWLINE { prompt(); } + ; command: open_command diff --git a/binutils/config.in b/binutils/config.in index 1e0aa93b9c4..02ec0a7d273 100644 --- a/binutils/config.in +++ b/binutils/config.in @@ -28,6 +28,9 @@ /* Define to `long' if doesn't define. */ #undef off_t +/* Define if you need to in order for stat and other things to work. */ +#undef _POSIX_SOURCE + /* Define to `unsigned' if doesn't define. */ #undef size_t diff --git a/binutils/configure b/binutils/configure index c63f2b06d1c..316d09bdddc 100755 --- a/binutils/configure +++ b/binutils/configure @@ -5495,12 +5495,12 @@ do DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM_EPOC -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - arm-*pe* | arm-*-wince) + arm-pe* | arm-*-wince) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - thumb-*pe*) + thumb-pe*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' @@ -5508,7 +5508,7 @@ do arm*-* | xscale-* | strongarm-* | d10v-*) OBJDUMP_DEFS="-DDISASSEMBLER_NEEDS_RELOCS" ;; - i[3-6]86-*pe* | i[3-6]86-*-cygwin* | i[3-6]86-*-mingw32*) + i[3-6]86-pe* | i[3-6]86-*-cygwin* | i[3-6]86-*-mingw32*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' @@ -5518,22 +5518,22 @@ do BUILD_DLLTOOL='$(DLLTOOL_PROG)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" ;; - powerpc*-*-*pe* | powerpc*-*-cygwin*) + powerpc*-*-pe* | powerpc*-*-cygwin*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - sh*-*-*pe) + sh*-*-pe) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - mips*-*-*pe) + mips*-*-pe) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MIPS" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - mcore-*pe) + mcore-pe) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' diff --git a/binutils/configure.in b/binutils/configure.in index 42381bb98c4..03ed567d56d 100644 --- a/binutils/configure.in +++ b/binutils/configure.in @@ -235,12 +235,12 @@ changequote([,])dnl DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM_EPOC -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - arm-*pe* | arm-*-wince) + arm-pe* | arm-*-wince) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - thumb-*pe*) + thumb-pe*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' @@ -249,7 +249,7 @@ changequote([,])dnl OBJDUMP_DEFS="-DDISASSEMBLER_NEEDS_RELOCS" ;; changequote(,)dnl - i[3-6]86-*pe* | i[3-6]86-*-cygwin* | i[3-6]86-*-mingw32*) + i[3-6]86-pe* | i[3-6]86-*-cygwin* | i[3-6]86-*-mingw32*) changequote([,])dnl BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" @@ -260,22 +260,22 @@ changequote([,])dnl BUILD_DLLTOOL='$(DLLTOOL_PROG)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386" ;; - powerpc*-*-*pe* | powerpc*-*-cygwin*) + powerpc*-*-pe* | powerpc*-*-cygwin*) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - sh*-*-*pe) + sh*-*-pe) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - mips*-*-*pe) + mips*-*-pe) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MIPS" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' ;; - mcore-*pe) + mcore-pe) BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)' DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE" BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)' diff --git a/binutils/dlltool.c b/binutils/dlltool.c index 0ea3f8ffe98..6864d22057f 100644 --- a/binutils/dlltool.c +++ b/binutils/dlltool.c @@ -658,6 +658,8 @@ static struct string_list *excludes; static const char *rvaafter PARAMS ((int)); static const char *rvabefore PARAMS ((int)); static const char *asm_prefix PARAMS ((int)); +static void process_def_file PARAMS ((const char *)); +static void new_directive PARAMS ((char *)); static void append_import PARAMS ((const char *, const char *, int)); static void run PARAMS ((const char *, char *)); static void scan_drectve_symbols PARAMS ((bfd *)); @@ -674,6 +676,7 @@ static int sfunc PARAMS ((const void *, const void *)); static void flush_page PARAMS ((FILE *, long *, int, int)); static void gen_def_file PARAMS ((void)); static void generate_idata_ofile PARAMS ((FILE *)); +static void assemble_file PARAMS ((const char *, const char *)); static void gen_exp_file PARAMS ((void)); static const char *xlate PARAMS ((const char *)); #if 0 @@ -697,28 +700,17 @@ static void inform PARAMS ((const char *, ...)); static void -#ifdef __STDC__ -inform (const char * message, ...) -#else -inform (message, va_alist) - const char * message; - va_dcl -#endif +inform VPARAMS ((const char *message, ...)) { - va_list args; - + VA_OPEN (args, message); + VA_FIXEDARG (args, const char *, message); + if (!verbose) return; -#ifdef __STDC__ - va_start (args, message); -#else - va_start (args); -#endif - report (message, args); - - va_end (args); + + VA_CLOSE (args); } static const char * @@ -820,7 +812,7 @@ asm_prefix (machine) static char **oav; -void +static void process_def_file (name) const char *name; { @@ -943,7 +935,7 @@ def_description (desc) d_list = d; } -void +static void new_directive (dir) char *dir; { @@ -3206,6 +3198,8 @@ static const struct option long_options[] = {NULL,0,NULL,0} }; +int main PARAMS ((int, char **)); + int main (ac, av) int ac; diff --git a/binutils/dllwrap.c b/binutils/dllwrap.c index f8449a8a780..7c9496ce439 100644 --- a/binutils/dllwrap.c +++ b/binutils/dllwrap.c @@ -115,14 +115,16 @@ static int delete_exp_file = 1; static int delete_def_file = 1; static int run PARAMS ((const char *, char *)); +static char *mybasename PARAMS ((const char *)); +static int strhash PARAMS ((const char *)); static void usage PARAMS ((FILE *, int)); static void display PARAMS ((const char *, va_list)); static void inform PARAMS ((const char *, ...)); -static void warn PARAMS ((const char *format, ...)); +static void warn PARAMS ((const char *, ...)); static char *look_for_prog PARAMS ((const char *, const char *, int)); static char *deduce_name PARAMS ((const char *)); static void delete_temp_files PARAMS ((void)); -static void cleanup_and_exit PARAMS ((int status)); +static void cleanup_and_exit PARAMS ((int)); /**********************************************************************/ @@ -147,58 +149,30 @@ display (message, args) } -#ifdef __STDC__ static void -inform (const char * message, ...) +inform VPARAMS ((const char *message, ...)) { - va_list args; + VA_OPEN (args, message); + VA_FIXEDARG (args, const char *, message); if (!verbose) return; - va_start (args, message); display (message, args); - va_end (args); -} - -static void -warn (const char *format, ...) -{ - va_list args; - - va_start (args, format); - display (format, args); - va_end (args); -} -#else - -static void -inform (message, va_alist) - const char * message; - va_dcl -{ - va_list args; - - if (!verbose) - return; - va_start (args); - display (message, args); - va_end (args); + VA_CLOSE (args); } static void -warn (format, va_alist) - const char *format; - va_dcl +warn VPARAMS ((const char *format, ...)) { - va_list args; + VA_OPEN (args, format); + VA_FIXEDARG (args, const char *, format); - va_start (args); display (format, args); - va_end (args); + + VA_CLOSE (args); } -#endif /* Look for the program formed by concatenating PROG_NAME and the string running from PREFIX to END_PREFIX. If the concatenated @@ -375,7 +349,8 @@ delete_temp_files () } static void -cleanup_and_exit (int status) +cleanup_and_exit (status) + int status; { delete_temp_files (); exit (status); @@ -487,7 +462,8 @@ mybasename (name) } static int -strhash (const char *str) +strhash (str) + const char *str; { const unsigned char *s; unsigned long hash; @@ -635,6 +611,8 @@ static const struct option long_options[] = {0, 0, 0, 0} }; +int main PARAMS ((int, char **)); + int main (argc, argv) int argc; diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in index 5d96d27659a..5ac149fa592 100644 --- a/binutils/doc/Makefile.in +++ b/binutils/doc/Makefile.in @@ -175,7 +175,7 @@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = gtar +TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: diff --git a/binutils/nm.c b/binutils/nm.c index 68eae77f55d..eb8a55f4eb4 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -1291,7 +1291,8 @@ print_symbol (abfd, sym, archive_bfd) bfd_asymbol_name (*r->sym_ptr_ptr)) == 0 && bfd_find_nearest_line (abfd, secs[i], syms, r->address, &filename, - &functionname, &lineno)) + &functionname, &lineno) + && filename != NULL) { /* We only print the first one we find. */ printf ("\t%s:%u", filename, lineno); diff --git a/binutils/rclex.l b/binutils/rclex.l index c9073e2ac38..600e38ec9f1 100644 --- a/binutils/rclex.l +++ b/binutils/rclex.l @@ -1,5 +1,5 @@ %{ /* rclex.l -- lexer for Windows rc files parser */ -/* Copyright 1997, 1998, 1999, 2001 Free Software Foundation, Inc. +/* Copyright 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -284,11 +284,11 @@ cpp_line (s) if (!initial_fn) { initial_fn = xmalloc (strlen (fn) + 1); - strcpy(initial_fn, fn); + strcpy (initial_fn, fn); } /* Allow the initial file, regardless of name. Suppress all other - files if they end in ".h" (this allows included "*.rc") */ + files if they end in ".h" (this allows included "*.rc"). */ if (strcmp (initial_fn, fn) == 0 || strcmp (fn + strlen (fn) - 2, ".h") != 0) suppress_cpp_data = 0; @@ -331,7 +331,7 @@ handle_quotes (input, len) break; case 'a': - *s++ = ESCAPE_A; + *s++ = ESCAPE_B; /* Strange, but true... */ ++t; break; @@ -394,9 +394,9 @@ handle_quotes (input, len) if (*t >= '0' && *t <= '9') ch = (ch << 4) | (*t - '0'); else if (*t >= 'a' && *t <= 'f') - ch = (ch << 4) | (*t - 'a'); + ch = (ch << 4) | (*t - 'a' + 10); else if (*t >= 'A' && *t <= 'F') - ch = (ch << 4) | (*t - 'A'); + ch = (ch << 4) | (*t - 'A' + 10); else break; ++t; @@ -452,7 +452,7 @@ get_string (len) as->s = xmalloc (len); as->next = strings; - strings = as->next; + strings = as; return as->s; } diff --git a/binutils/rcparse.y b/binutils/rcparse.y index 152c8ee3086..898e99fdfd1 100644 --- a/binutils/rcparse.y +++ b/binutils/rcparse.y @@ -1,5 +1,5 @@ %{ /* rcparse.y -- parser for Windows rc files - Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -153,28 +153,21 @@ static unsigned long class; input: /* empty */ - | input newcmd accelerator - | input newcmd bitmap - | input newcmd cursor - | input newcmd dialog - | input newcmd font - | input newcmd icon - | input newcmd language - | input newcmd menu - | input newcmd menuex - | input newcmd messagetable - | input newcmd rcdata - | input newcmd stringtable - | input newcmd user - | input newcmd versioninfo - | input newcmd IGNORED_TOKEN - ; - -newcmd: - /* empty */ - { - rcparse_discard_strings (); - } + | input accelerator + | input bitmap + | input cursor + | input dialog + | input font + | input icon + | input language + | input menu + | input menuex + | input messagetable + | input rcdata + | input stringtable + | input user + | input versioninfo + | input IGNORED_TOKEN ; /* Accelerator resources. */ @@ -183,6 +176,9 @@ accelerator: id ACCELERATORS suboptions BEG acc_entries END { define_accelerator ($1, &$3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -309,6 +305,9 @@ bitmap: id BITMAP memflags_move file_name { define_bitmap ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -318,6 +317,9 @@ cursor: id CURSOR memflags_move_discard file_name { define_cursor ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -340,10 +342,14 @@ dialog: dialog.ex = NULL; dialog.controls = NULL; sub_res_info = $3; + style = 0; } styles BEG controls END { define_dialog ($1, &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr cnumexpr @@ -363,10 +369,14 @@ dialog: memset (dialog.ex, 0, sizeof (struct dialog_ex)); dialog.controls = NULL; sub_res_info = $3; + style = 0; } styles BEG controls END { define_dialog ($1, &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } | id DIALOGEX memflags_move exstyle posnumexpr cnumexpr cnumexpr cnumexpr cnumexpr @@ -387,10 +397,14 @@ dialog: dialog.ex->help = $9; dialog.controls = NULL; sub_res_info = $3; + style = 0; } styles BEG controls END { define_dialog ($1, &sub_res_info, &dialog); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -409,6 +423,8 @@ styles: /* empty */ | styles CAPTION QUOTEDSTRING { + dialog.style |= WS_CAPTION; + style |= WS_CAPTION; unicode_from_ascii ((int *) NULL, &dialog.caption, $3); } | styles CLASS id @@ -416,7 +432,6 @@ styles: dialog.class = $3; } | styles STYLE - { style = dialog.style; } styleexpr { dialog.style = style; @@ -425,15 +440,57 @@ styles: { dialog.exstyle = $3; } + | styles CLASS QUOTEDSTRING + { + res_string_to_id (& dialog.class, $3); + } | styles FONT numexpr ',' QUOTEDSTRING { dialog.style |= DS_SETFONT; + style |= DS_SETFONT; dialog.pointsize = $3; unicode_from_ascii ((int *) NULL, &dialog.font, $5); + if (dialog.ex != NULL) + { + dialog.ex->weight = 0; + dialog.ex->italic = 0; + dialog.ex->charset = 1; + } + } + | styles FONT numexpr ',' QUOTEDSTRING cnumexpr + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = $3; + unicode_from_ascii ((int *) NULL, &dialog.font, $5); + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = $6; + dialog.ex->italic = 0; + dialog.ex->charset = 1; + } } | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr { dialog.style |= DS_SETFONT; + style |= DS_SETFONT; + dialog.pointsize = $3; + unicode_from_ascii ((int *) NULL, &dialog.font, $5); + if (dialog.ex == NULL) + rcparse_warning (_("extended FONT requires DIALOGEX")); + else + { + dialog.ex->weight = $6; + dialog.ex->italic = $7; + dialog.ex->charset = 1; + } + } + | styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr + { + dialog.style |= DS_SETFONT; + style |= DS_SETFONT; dialog.pointsize = $3; unicode_from_ascii ((int *) NULL, &dialog.font, $5); if (dialog.ex == NULL) @@ -442,6 +499,7 @@ styles: { dialog.ex->weight = $6; dialog.ex->italic = $7; + dialog.ex->charset = $8; } } | styles MENU id @@ -515,7 +573,7 @@ control: { $$ = $3; if (dialog.ex == NULL) - rcparse_warning (_("IEDIT requires DIALOGEX")); + rcparse_warning (_("BEDIT requires DIALOGEX")); res_string_to_id (&$$->class, "BEDIT"); } | CHECKBOX @@ -569,7 +627,7 @@ control: $$->data = $12; } $$->class.named = 1; - unicode_from_ascii(&$$->class.u.n.length, &$$->class.u.n.name, $5); + unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5); } | CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data @@ -580,7 +638,7 @@ control: $$->help = $12; $$->data = $13; $$->class.named = 1; - unicode_from_ascii(&$$->class.u.n.length, &$$->class.u.n.name, $5); + unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5); } | CTEXT { @@ -855,6 +913,9 @@ font: id FONT memflags_move_discard file_name { define_font ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -864,6 +925,9 @@ icon: id ICON memflags_move_discard file_name { define_icon ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -883,6 +947,9 @@ menu: id MENU suboptions BEG menuitems END { define_menu ($1, &$3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -970,6 +1037,9 @@ menuex: id MENUEX suboptions BEG menuexitems END { define_menu ($1, &$3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -1036,6 +1106,9 @@ messagetable: id MESSAGETABLE memflags_move file_name { define_messagetable ($1, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -1045,6 +1118,9 @@ rcdata: id RCDATA suboptions BEG optrcdata_data END { define_rcdata ($1, &$3, $5.first); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -1124,10 +1200,16 @@ string_data: | string_data numexpr QUOTEDSTRING { define_stringtable (&sub_res_info, $2, $3); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } | string_data numexpr ',' QUOTEDSTRING { define_stringtable (&sub_res_info, $2, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -1138,10 +1220,16 @@ user: id id suboptions BEG optrcdata_data END { define_user_data ($1, $2, &$3, $5.first); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } | id id suboptions file_name { define_user_file ($1, $2, &$3, $4); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -1151,6 +1239,9 @@ versioninfo: id VERSIONINFO fixedverinfo BEG verblocks END { define_versioninfo ($1, language, $3, $5); + if (yychar != YYEMPTY) + YYERROR; + rcparse_discard_strings (); } ; @@ -1310,7 +1401,7 @@ suboptions: memset (&$$, 0, sizeof (struct res_res_info)); $$.language = language; /* FIXME: Is this the right default? */ - $$.memflags = MEMFLAG_MOVEABLE; + $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE; } | suboptions memflag { @@ -1359,7 +1450,7 @@ memflags_move: { memset (&$$, 0, sizeof (struct res_res_info)); $$.language = language; - $$.memflags = MEMFLAG_MOVEABLE; + $$.memflags = MEMFLAG_MOVEABLE | MEMFLAG_PURE | MEMFLAG_DISCARDABLE; } | memflags_move memflag { diff --git a/binutils/resbin.c b/binutils/resbin.c index a5453437052..7ed84f93a2f 100644 --- a/binutils/resbin.c +++ b/binutils/resbin.c @@ -1,5 +1,5 @@ /* resbin.c -- manipulate the Windows binary resource format. - Copyright 1997, 1998, 1999 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -30,6 +30,7 @@ /* Macros to swap in values. */ +#define get_8(s) (*((unsigned char *)(s))) #define get_16(be, s) ((be) ? bfd_getb16 (s) : bfd_getl16 (s)) #define get_32(be, s) ((be) ? bfd_getb32 (s) : bfd_getl32 (s)) @@ -68,6 +69,9 @@ static struct res_resource *bin_to_res_version PARAMS ((const unsigned char *, unsigned long, int)); static struct res_resource *bin_to_res_userdata PARAMS ((const unsigned char *, unsigned long, int)); +static void get_version_header + PARAMS ((const unsigned char *, unsigned long, int, const char *, + unichar **, int *, int *, int *, int *)); /* Given a resource type ID, a pointer to data, a length, return a res_resource structure which represents that resource. The caller @@ -460,7 +464,7 @@ bin_to_res_dialog (data, length, big_endian) unsigned long length; int big_endian; { - int version; + int signature; struct dialog *d; int c, sublen, i; unsigned int off; @@ -472,8 +476,8 @@ bin_to_res_dialog (data, length, big_endian) d = (struct dialog *) res_alloc (sizeof *d); - version = get_16 (big_endian, data); - if (version != 1) + signature = get_16 (big_endian, data + 2); + if (signature != 0xffff) { d->ex = NULL; d->style = get_32 (big_endian, data); @@ -482,11 +486,11 @@ bin_to_res_dialog (data, length, big_endian) } else { - int signature; + int version; - signature = get_16 (big_endian, data + 2); - if (signature != 0xffff) - fatal (_("unexpected dialog signature %d"), signature); + version = get_16 (big_endian, data); + if (version != 1) + fatal (_("unexpected DIALOGEX version %d"), version); d->ex = (struct dialog_ex *) res_alloc (sizeof (struct dialog_ex)); d->ex->help = get_32 (big_endian, data + 4); @@ -514,6 +518,8 @@ bin_to_res_dialog (data, length, big_endian) d->caption = get_unicode (data + off, length - off, big_endian, &sublen); off += sublen * 2 + 2; + if (sublen == 0) + d->caption = NULL; if ((d->style & DS_SETFONT) == 0) { @@ -523,6 +529,7 @@ bin_to_res_dialog (data, length, big_endian) { d->ex->weight = 0; d->ex->italic = 0; + d->ex->charset = 1; /* Default charset. */ } } else @@ -538,7 +545,8 @@ bin_to_res_dialog (data, length, big_endian) if (length < off + 4) toosmall (_("dialogex font information")); d->ex->weight = get_16 (big_endian, data + off); - d->ex->italic = get_16 (big_endian, data + off + 2); + d->ex->italic = get_8 (data + off + 2); + d->ex->charset = get_8 (data + off + 3); off += 4; } @@ -808,7 +816,7 @@ static struct res_resource * bin_to_res_rcdata (data, length, big_endian) const unsigned char *data; unsigned long length; - int big_endian; + int big_endian ATTRIBUTE_UNUSED; { struct rcdata_item *ri; struct res_resource *r; @@ -1019,7 +1027,7 @@ bin_to_res_version (data, length, big_endian) struct res_resource *r; get_version_header (data, length, big_endian, "VS_VERSION_INFO", - (unichar *) NULL, &verlen, &vallen, &type, &off); + (unichar **) NULL, &verlen, &vallen, &type, &off); if ((unsigned int) verlen != length) fatal (_("version length %d does not match resource length %lu"), @@ -1091,7 +1099,7 @@ bin_to_res_version (data, length, big_endian) vi->type = VERINFO_STRING; get_version_header (data, length, big_endian, "StringFileInfo", - (unichar *) NULL, &verlen, &vallen, &type, + (unichar **) NULL, &verlen, &vallen, &type, &off); if (vallen != 0) @@ -1163,7 +1171,7 @@ bin_to_res_version (data, length, big_endian) vi->type = VERINFO_VAR; get_version_header (data, length, big_endian, "VarFileInfo", - (unichar *) NULL, &verlen, &vallen, &type, + (unichar **) NULL, &verlen, &vallen, &type, &off); if (vallen != 0) @@ -1231,7 +1239,7 @@ static struct res_resource * bin_to_res_userdata (data, length, big_endian) const unsigned char *data; unsigned long length; - int big_endian; + int big_endian ATTRIBUTE_UNUSED; { struct rcdata_item *ri; struct res_resource *r; @@ -1252,6 +1260,7 @@ bin_to_res_userdata (data, length, big_endian) /* Macros to swap out values. */ +#define put_8(v, s) (*((unsigned char *) (s)) = (unsigned char) (v)) #define put_16(be, v, s) ((be) ? bfd_putb16 ((v), (s)) : bfd_putl16 ((v), (s))) #define put_32(be, v, s) ((be) ? bfd_putb32 ((v), (s)) : bfd_putl32 ((v), (s))) @@ -1621,12 +1630,14 @@ res_to_bin_dialog (dialog, big_endian) if (dialog->ex == NULL) { put_16 (big_endian, 0, d->data + 2); - put_16 (big_endian, 0, d->data + 4); + put_8 (0, d->data + 4); + put_8 (1, d->data + 5); } else { put_16 (big_endian, dialog->ex->weight, d->data + 2); - put_16 (big_endian, dialog->ex->italic, d->data + 4); + put_8 (dialog->ex->italic, d->data + 4); + put_8 (dialog->ex->charset, d->data + 5); } } diff --git a/binutils/resrc.c b/binutils/resrc.c index eb7db96cd7e..fb0d36c0996 100644 --- a/binutils/resrc.c +++ b/binutils/resrc.c @@ -1,5 +1,5 @@ /* resrc.c -- read and write Windows rc files. - Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -131,7 +131,7 @@ static FILE *cpp_pipe; static char *cpp_temp_file; -/* Input stream is either a file or a pipe. */ +/* Input stream is either a file or a pipe. */ static enum {ISTREAM_PIPE, ISTREAM_FILE} istream_type; @@ -173,7 +173,7 @@ static void get_data PARAMS ((FILE *, unsigned char *, unsigned long, const char *)); static void define_fontdirs PARAMS ((void)); -/* Run `cmd' and redirect the output to `redir'. */ +/* Run `cmd' and redirect the output to `redir'. */ static int run_cmd (cmd, redir) @@ -481,6 +481,7 @@ read_rc_file (filename, preprocessor, preprocargs, language, use_temp_file) rcparse_set_language (language); yyin = cpp_pipe; yyparse (); + rcparse_discard_strings (); close_input_stream (); @@ -518,7 +519,7 @@ close_input_stream () pclose (cpp_pipe); } - /* Since this is also run via xatexit, safeguard. */ + /* Since this is also run via xatexit, safeguard. */ cpp_pipe = NULL; cpp_temp_file = NULL; } @@ -1580,7 +1581,7 @@ write_rc_directory (e, rd, type, name, language, level) case 2: /* If we're at level 2, the key of this resource is the name - we are going to use in the rc printout. */ + we are going to use in the rc printout. */ name = &re->id; break; @@ -1592,7 +1593,8 @@ write_rc_directory (e, rd, type, name, language, level) && (re->id.u.id & 0xffff) == re->id.u.id) { fprintf (e, "LANGUAGE %lu, %lu\n", - re->id.u.id & 0xff, (re->id.u.id >> 8) & 0xff); + re->id.u.id & ((1 << SUBLANG_SHIFT) - 1), + (re->id.u.id >> SUBLANG_SHIFT) & 0xff); *language = re->id.u.id; } break; @@ -2052,23 +2054,26 @@ write_rc_dialog (e, dialog) { const struct dialog_control *control; - if (dialog->style != 0) - fprintf (e, "STYLE 0x%lx\n", dialog->style); + fprintf (e, "STYLE 0x%lx\n", dialog->style); + if (dialog->exstyle != 0) fprintf (e, "EXSTYLE 0x%lx\n", dialog->exstyle); + if ((dialog->class.named && dialog->class.u.n.length > 0) || dialog->class.u.id != 0) { fprintf (e, "CLASS "); - res_id_print (e, dialog->class, 0); + res_id_print (e, dialog->class, 1); fprintf (e, "\n"); } + if (dialog->caption != NULL) { fprintf (e, "CAPTION \""); unicode_print (e, dialog->caption, -1); fprintf (e, "\"\n"); } + if ((dialog->menu.named && dialog->menu.u.n.length > 0) || dialog->menu.u.id != 0) { @@ -2076,14 +2081,18 @@ write_rc_dialog (e, dialog) res_id_print (e, dialog->menu, 0); fprintf (e, "\n"); } + if (dialog->font != NULL) { fprintf (e, "FONT %d, \"", dialog->pointsize); unicode_print (e, dialog->font, -1); fprintf (e, "\""); if (dialog->ex != NULL - && (dialog->ex->weight != 0 || dialog->ex->italic != 0)) - fprintf (e, ", %d, %d", dialog->ex->weight, dialog->ex->italic); + && (dialog->ex->weight != 0 + || dialog->ex->italic != 0 + || dialog->ex->charset != 1)) + fprintf (e, ", %d, %d, %d", + dialog->ex->weight, dialog->ex->italic, dialog->ex->charset); fprintf (e, "\n"); } diff --git a/binutils/size.c b/binutils/size.c index 3da75207b44..961593b33e8 100644 --- a/binutils/size.c +++ b/binutils/size.c @@ -316,6 +316,7 @@ display_archive (file) bfd *file; { bfd *arfile = (bfd *) NULL; + bfd *last_arfile = (bfd *) NULL; for (;;) { @@ -333,8 +334,14 @@ display_archive (file) } display_bfd (arfile); - /* Don't close the archive elements; we need them for next_archive. */ + + if (last_arfile != NULL) + bfd_close (last_arfile); + last_arfile = arfile; } + + if (last_arfile != NULL) + bfd_close (last_arfile); } static void diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 780314da391..876401e0149 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,3 +1,54 @@ +2002-05-09 Alan Modra + + Merge from mainline. + 2002-04-16 Eric Kohl + * binutils-all/windres/dialog0.rc: New test case: Check default + attributes for dialogs + * binutils-all/windres/dialog0.rsd: New file: Expected output. + * binutils-all/windres/dialog1.rc: New test case: Check + DISCARDABLE flag is propogated. + * binutils-all/windres/dialog1.rsd: New file: Expected output. + + 2002-04-15 Eric Kohl + * binutils-all/windres/dlgfont.rc: New test case: Checks FONT + statement in DIALOG and DIALOGEX resources. + * binutils-all/windres/dlgfont.rsd: Expected output. + + 2002-04-10 Nick Clifton + * binutils-all/windres/capstyle.rsd: Regenerate using MSVC. + * binutils-all/windres/deflang.rsd: Regenerate using MSVC. + * binutils-all/windres/dialogsignature.rsd: Regenerate using MSVC. + * binutils-all/windres/escapea.rsd: Regenerate using MSVC. + * binutils-all/windres/escapex.rsd: Regenerate using MSVC. + * binutils-all/windres/nocaption.rsd: Regenerate using MSVC. + * binutils-all/windres/printstyle.rsd: Regenerate using MSVC. + * binutils-all/windres/sublang.rsd: Regenerate using MSVC. + + 2002-04-09 Nick Clifton + * binutils-all/windres/capstyle.rc: New test case: Set default + style for captions. + * binutils-all/windres/capstyle.rsd: Expected output. + * binutils-all/windres/deflang.rc: New test case: Check default + language. + * binutils-all/windres/deflang.rsd: Expected output. + * binutils-all/windres/dialogsignature.rc: New test case for + decoding the dialog signature. + * binutils-all/windres/dialogsignature.rsd: Expected output. + * binutils-all/windres/escapea.rc: New test case for encoding \a + escape sequence. + * binutils-all/windres/escapea.rsd: Expected output. + * binutils-all/windres/escapex.rc: New test case for hex constants + in strings. + * binutils-all/windres/escapex.rsd: Expected output + * binutils-all/windres/nocaption.rc: New test case dialogs without + captions. + * binutils-all/windres/nocaption.rsd: Expected output + * binutils-all/windres/quoteclass.rc: New test case for quoted + CLASS definitions in DIALOG resources. + * binutils-all/windres/sublang.rc: New test case: Check assignment + of sub-language. + * binutils-all/windres/sublang.rsd: Expected output. + 2002-04-27 Alan Modra Merge from mainline. diff --git a/binutils/windres.c b/binutils/windres.c index 0b56bc2d326..27cc0f0e485 100644 --- a/binutils/windres.c +++ b/binutils/windres.c @@ -145,6 +145,8 @@ static enum res_format format_from_filename PARAMS ((const char *, int)); static void usage PARAMS ((FILE *, int)); static int cmp_res_entry PARAMS ((const PTR, const PTR)); static struct res_directory *sort_resources PARAMS ((struct res_directory *)); +static void reswr_init PARAMS ((void)); +static const char * quot PARAMS ((const char *)); /* When we are building a resource tree, we allocate everything onto an obstack, so that we can free it all at once if we want. */ @@ -441,11 +443,9 @@ define_resource (resources, cids, ids, dupok) re->u.res = ((struct res_resource *) res_alloc (sizeof (struct res_resource))); + memset (re->u.res, 0, sizeof (struct res_resource)); re->u.res->type = RES_TYPE_UNINITIALIZED; - memset (&re->u.res->res_info, 0, sizeof (struct res_res_info)); - memset (&re->u.res->coff_info, 0, sizeof (struct res_coff_info)); - return re->u.res; } @@ -765,6 +765,9 @@ quot (string) return buf; } +/* This keeps gcc happy when using -Wmissing-prototypes -Wstrict-prototypes. */ +int main PARAMS ((int, char **)); + /* The main function. */ int @@ -809,7 +812,7 @@ main (argc, argv) target = NULL; preprocessor = NULL; preprocargs = NULL; - language = -1; + language = 0x409; /* LANG_ENGLISH, SUBLANG_ENGLISH_US. */ use_temp_file = 0; while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:hHvV", long_options, diff --git a/binutils/windres.h b/binutils/windres.h index 157d7514f4a..64b6050430a 100644 --- a/binutils/windres.h +++ b/binutils/windres.h @@ -1,5 +1,5 @@ /* windres.h -- header file for windres program. - Copyright 1997, 1998, 2000 Free Software Foundation, Inc. + Copyright 1997, 1998, 2000, 2002 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of GNU Binutils. @@ -315,7 +315,9 @@ struct dialog_ex /* Font weight. */ unsigned short weight; /* Whether the font is italic. */ - unsigned short italic; + unsigned char italic; + /* Character set. */ + unsigned char charset; }; /* Window style flags, from the winsup Defines.h header file. These @@ -519,7 +521,7 @@ struct fontdir short index; /* Length of font information. */ unsigned long length; - /* Font information. */ + /* Font information. */ const unsigned char *data; }; diff --git a/gas/ChangeLog b/gas/ChangeLog index 34ba3e3145d..d887b0e7151 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,27 @@ +2002-05-09 Alan Modra + + * config/tc-i386.c (md_estimate_size_before_relax) Don't lose + reloc when no_cond_jump_promotion. + + Merge from mainline + 2002-05-08 Jim Wilson + * config/tc-i960.c (md_estimate_size_before_relax): Return size of + current variable part of frag. + + 2002-05-02 Alan Modra + * config/tc-ppc.c (mapping): Map sectoff to BFD_RELOC_16_BASEREL. + (ppc_elf_validate_fix): Replace BFD_RELOC_32_BASEREL with + BFD_RELOC_16_BASEREL. + (md_assemble): Likewise. + (md_apply_fix3): Likewise. + + 2002-05-01 Andrew Macleod + * config/tc-i386.c (extra_symbol_chars): Add '[' to the list. + + 2002-04-28 Alan Modra + * config/tc-i386.c: Formatting fixes, add missing space in error + message. + 2002-05-03 Alexandre Oliva * config/tc-s390.c (md_gather_operands): Emit dwarf2 line-number diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index ec1da5c6b34..f681014e278 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -182,9 +182,9 @@ typedef struct _i386_insn i386_insn; /* List of chars besides those in app.c:symbol_chars that can start an operand. Used to prevent the scrubber eating vital white-space. */ #ifdef LEX_AT -const char extra_symbol_chars[] = "*%-(@"; +const char extra_symbol_chars[] = "*%-(@["; #else -const char extra_symbol_chars[] = "*%-("; +const char extra_symbol_chars[] = "*%-(["; #endif #if (defined (TE_I386AIX) \ @@ -2208,15 +2208,15 @@ process_suffix () /* For movzx and movsx, need to check the register type. */ if (intel_syntax - && (i.tm.base_opcode == 0xfb6 || i.tm.base_opcode == 0xfbe)) - if (i.suffix && i.suffix == BYTE_MNEM_SUFFIX) - { - unsigned int prefix = DATA_PREFIX_OPCODE; + && (i.tm.base_opcode == 0xfb6 || i.tm.base_opcode == 0xfbe) + && i.suffix == BYTE_MNEM_SUFFIX) + { + unsigned int prefix = DATA_PREFIX_OPCODE; - if ((i.op[1].regs->reg_type & Reg16) != 0) - if (!add_prefix (prefix)) - return 0; - } + if ((i.op[1].regs->reg_type & Reg16) != 0) + if (!add_prefix (prefix)) + return 0; + } if (i.suffix && i.suffix != BYTE_MNEM_SUFFIX) { @@ -2228,6 +2228,7 @@ process_suffix () else i.tm.base_opcode |= 1; } + /* Now select between word & dword operations via the operand size prefix, except for instructions that will ignore this prefix anyway. */ @@ -2309,7 +2310,7 @@ check_byte_reg () if (flag_code == CODE_64BIT && (i.tm.operand_types[op] & InOutPortReg) == 0) { - as_bad (_("Incorrect register `%%%s' used with`%c' suffix"), + as_bad (_("Incorrect register `%%%s' used with `%c' suffix"), i.op[op].regs->reg_name, i.suffix); return 0; @@ -2368,7 +2369,7 @@ check_long_reg () lowering is more complicated. */ if (flag_code == CODE_64BIT) { - as_bad (_("Incorrect register `%%%s' used with`%c' suffix"), + as_bad (_("Incorrect register `%%%s' used with `%c' suffix"), i.op[op].regs->reg_name, i.suffix); return 0; @@ -2385,7 +2386,7 @@ check_long_reg () else if ((i.types[op] & Reg64) != 0 && (i.tm.operand_types[op] & (Reg32 | Acc)) != 0) { - as_bad (_("Incorrect register `%%%s' used with`%c' suffix"), + as_bad (_("Incorrect register `%%%s' used with `%c' suffix"), i.op[op].regs->reg_name, i.suffix); return 0; @@ -2417,7 +2418,7 @@ check_qword_reg () { /* Prohibit these changes in the 64bit mode, since the lowering is more complicated. */ - as_bad (_("Incorrect register `%%%s' used with`%c' suffix"), + as_bad (_("Incorrect register `%%%s' used with `%c' suffix"), i.op[op].regs->reg_name, i.suffix); return 0; @@ -2450,7 +2451,7 @@ check_word_reg () lowering is more complicated. */ if (flag_code == CODE_64BIT) { - as_bad (_("Incorrect register `%%%s' used with`%c' suffix"), + as_bad (_("Incorrect register `%%%s' used with `%c' suffix"), i.op[op].regs->reg_name, i.suffix); return 0; @@ -4234,10 +4235,8 @@ md_estimate_size_before_relax (fragP, segment) break; case COND_JUMP86: - if (no_cond_jump_promotion) - goto relax_guess; - - if (size == 2) + if (size == 2 + && (!no_cond_jump_promotion || fragP->fr_var != NO_RELOC)) { /* Negate the condition, and branch past an unconditional jump. */ @@ -4257,8 +4256,15 @@ md_estimate_size_before_relax (fragP, segment) /* Fall through. */ case COND_JUMP: - if (no_cond_jump_promotion) - goto relax_guess; + if (no_cond_jump_promotion && fragP->fr_var == NO_RELOC) + { + fragP->fr_fix += 1; + fix_new (fragP, old_fr_fix, 1, + fragP->fr_symbol, + fragP->fr_offset, 1, + BFD_RELOC_8_PCREL); + break; + } /* This changes the byte-displacement jump 0x7N to the (d)word-displacement jump 0x0f,0x8N. */ @@ -4280,7 +4286,6 @@ md_estimate_size_before_relax (fragP, segment) return fragP->fr_fix - old_fr_fix; } - relax_guess: /* Guess size depending on current relax state. Initially the relax state will correspond to a short jump and we return 1, because the variable part of the frag (the branch offset) is one byte diff --git a/gas/config/tc-i960.c b/gas/config/tc-i960.c index 568b8ab56bb..40bf8691000 100644 --- a/gas/config/tc-i960.c +++ b/gas/config/tc-i960.c @@ -1,6 +1,6 @@ /* tc-i960.c - All the i80960-specific stuff Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001 + 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GAS. @@ -1085,7 +1085,8 @@ md_estimate_size_before_relax (fragP, segment_type) relax_cobr (fragP); return 4; } - return 0; + + return md_relax_table[fragP->fr_subtype].rlx_length; } /* md_estimate_size_before_relax() */ #if defined(OBJ_AOUT) | defined(OBJ_BOUT) diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 560622b15c7..f7872a055d4 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -1374,7 +1374,7 @@ ppc_elf_suffix (str_p, exp_p) MAP ("plt@h", (int) BFD_RELOC_HI16_PLTOFF), MAP ("plt@ha", (int) BFD_RELOC_HI16_S_PLTOFF), MAP ("sdarel", (int) BFD_RELOC_GPREL16), - MAP ("sectoff", (int) BFD_RELOC_32_BASEREL), + MAP ("sectoff", (int) BFD_RELOC_16_BASEREL), MAP ("sectoff@l", (int) BFD_RELOC_LO16_BASEREL), MAP ("sectoff@h", (int) BFD_RELOC_HI16_BASEREL), MAP ("sectoff@ha", (int) BFD_RELOC_HI16_S_BASEREL), @@ -1683,7 +1683,7 @@ ppc_elf_validate_fix (fixp, seg) && fixp->fx_r_type != BFD_RELOC_HI16_GOTOFF && fixp->fx_r_type != BFD_RELOC_LO16_GOTOFF && fixp->fx_r_type != BFD_RELOC_HI16_S_GOTOFF - && fixp->fx_r_type != BFD_RELOC_32_BASEREL + && fixp->fx_r_type != BFD_RELOC_16_BASEREL && fixp->fx_r_type != BFD_RELOC_LO16_BASEREL && fixp->fx_r_type != BFD_RELOC_HI16_BASEREL && fixp->fx_r_type != BFD_RELOC_HI16_S_BASEREL @@ -2236,7 +2236,7 @@ md_assemble (str) case BFD_RELOC_LO16_PLTOFF: reloc = BFD_RELOC_PPC64_PLT16_LO_DS; break; - case BFD_RELOC_32_BASEREL: + case BFD_RELOC_16_BASEREL: reloc = BFD_RELOC_PPC64_SECTOFF_DS; break; case BFD_RELOC_LO16_BASEREL: @@ -5280,7 +5280,6 @@ md_apply_fix3 (fixP, valP, seg) case BFD_RELOC_RVA: case BFD_RELOC_32_PCREL: - case BFD_RELOC_32_BASEREL: case BFD_RELOC_PPC_EMB_NADDR32: md_number_to_chars (fixP->fx_frag->fr_literal + fixP->fx_where, value, 4); @@ -5305,6 +5304,7 @@ md_apply_fix3 (fixP, valP, seg) case BFD_RELOC_LO16_GOTOFF: case BFD_RELOC_HI16_GOTOFF: case BFD_RELOC_HI16_S_GOTOFF: + case BFD_RELOC_16_BASEREL: case BFD_RELOC_LO16_BASEREL: case BFD_RELOC_HI16_BASEREL: case BFD_RELOC_HI16_S_BASEREL: diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index a5a8d329752..0b405a1a9b6 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2002-05-09 Alan Modra + + Merge from mainline. + 2002-04-17 matthew green + * gas/ppc/altivec.d: Fix dssall test. + * gas/ppc/altivec.s: Likewise. + 2002-04-30 Chris Demetriou Merge from mainline: diff --git a/gas/testsuite/gas/ppc/altivec.d b/gas/testsuite/gas/ppc/altivec.d index 6fc1b7e2ec0..5cfe23aeb7c 100644 --- a/gas/testsuite/gas/ppc/altivec.d +++ b/gas/testsuite/gas/ppc/altivec.d @@ -8,7 +8,7 @@ Disassembly of section \.text: 00000000 : 0: 7c 60 06 6c dss 3 - 4: 7e 40 06 6c dssall 2 + 4: 7e 00 06 6c dssall 8: 7c 25 22 ac dst r5,r4,1 c: 7e 08 3a ac dstt r8,r7,0 10: 7c 65 32 ec dstst r5,r6,3 diff --git a/gas/testsuite/gas/ppc/altivec.s b/gas/testsuite/gas/ppc/altivec.s index 40e143d9899..2f7e4df167a 100644 --- a/gas/testsuite/gas/ppc/altivec.s +++ b/gas/testsuite/gas/ppc/altivec.s @@ -3,7 +3,7 @@ .section ".text" start: dss 3 - dssall 2 + dssall dst 5,4,1 dstt 8,7,0 dstst 5,6,3 diff --git a/ld/ChangeLog b/ld/ChangeLog index 346d5325c01..00968dc7511 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,18 @@ +2002-05-09 Alan Modra + + Merge from mainline. + 2002-05-02 Alan Modra + * emultempl/ppc64elf.em (gld${EMULATION_NAME}_after_allocation): + Adjust for ppc64_elf_set_toc change. #include libbfd.h. + + 2002-04-28 Alan Modra + * Makefile.am (mpw): New maintainer mode rule to make mpw-*.c files. + * Makefile.in: Regenerate. + * mpw-elfmips.c: Delete. + * mpw-eppcmac.c: Delete. + * mpw-esh.c: Delete. + * mpw-idtmips.c: Delete. + 2002-04-27 Alan Modra Merge from mainline diff --git a/ld/Makefile.am b/ld/Makefile.am index 3959ac586a8..595228a1009 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -1196,6 +1196,29 @@ dep-am: DEP .PHONY: dep dep-in dep-am +@MAINT@.PHONY: mpw +@MAINT@mpw: $(srcdir)/mpw-ei386go32.c $(srcdir)/mpw-elfmips.c \ +@MAINT@ $(srcdir)/mpw-em68kcoff.c $(srcdir)/mpw-eppcmac.c \ +@MAINT@ $(srcdir)/mpw-esh.c $(srcdir)/mpw-idtmips.c +@MAINT@ +@MAINT@$(srcdir)/mpw-ei386go32.c: ei386go32.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-elfmips.c: eelf32ebmip.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-em68kcoff.c: em68kcoff.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-eppcmac.c: eppcmacos.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-esh.c: esh.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-idtmips.c: emipsidt.c +@MAINT@ $(srcdir)/../move-if-change $< $@ + # What appears below is generated by a hacked mkdep using gcc -MM. # DO NOT DELETE THIS LINE -- mkdep uses it. diff --git a/ld/Makefile.in b/ld/Makefile.in index 1521f5e73f8..3a652fe284e 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -1891,6 +1891,29 @@ dep-am: DEP .PHONY: dep dep-in dep-am +@MAINT@.PHONY: mpw +@MAINT@mpw: $(srcdir)/mpw-ei386go32.c $(srcdir)/mpw-elfmips.c \ +@MAINT@ $(srcdir)/mpw-em68kcoff.c $(srcdir)/mpw-eppcmac.c \ +@MAINT@ $(srcdir)/mpw-esh.c $(srcdir)/mpw-idtmips.c +@MAINT@ +@MAINT@$(srcdir)/mpw-ei386go32.c: ei386go32.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-elfmips.c: eelf32ebmip.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-em68kcoff.c: em68kcoff.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-eppcmac.c: eppcmacos.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-esh.c: esh.c +@MAINT@ $(srcdir)/../move-if-change $< $@ +@MAINT@ +@MAINT@$(srcdir)/mpw-idtmips.c: emipsidt.c +@MAINT@ $(srcdir)/../move-if-change $< $@ + # What appears below is generated by a hacked mkdep using gcc -MM. # DO NOT DELETE THIS LINE -- mkdep uses it. diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em index 27b20ce1f65..2128fe7511f 100644 --- a/ld/emultempl/ppc64elf.em +++ b/ld/emultempl/ppc64elf.em @@ -23,6 +23,7 @@ # cat >>e${EMULATION_NAME}.c < - ELF support by Ian Lance Taylor - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#define TARGET_IS_elf32ebmip - -#include "bfd.h" -#include "sysdep.h" -#include "safe-ctype.h" - -#include "bfdlink.h" - -#include "ld.h" -#include "ldmain.h" -#include "ldmisc.h" -#include "ldexp.h" -#include "ldlang.h" -#include "ldgram.h" -#include "ldfile.h" -#include "ldemul.h" - -static void gldelf32ebmip_before_parse PARAMS ((void)); -static boolean gldelf32ebmip_open_dynamic_archive - PARAMS ((const char *, search_dirs_type *, lang_input_statement_type *)); -static void gldelf32ebmip_after_open PARAMS ((void)); -static void gldelf32ebmip_check_needed - PARAMS ((lang_input_statement_type *)); -static void gldelf32ebmip_stat_needed - PARAMS ((lang_input_statement_type *)); -static boolean gldelf32ebmip_search_needed - PARAMS ((const char *, const char *)); -static boolean gldelf32ebmip_try_needed PARAMS ((const char *)); -static void gldelf32ebmip_before_allocation PARAMS ((void)); -static void gldelf32ebmip_find_statement_assignment - PARAMS ((lang_statement_union_type *)); -static void gldelf32ebmip_find_exp_assignment PARAMS ((etree_type *)); -static boolean gldelf32ebmip_place_orphan - PARAMS ((lang_input_statement_type *, asection *)); -static void gldelf32ebmip_place_section - PARAMS ((lang_statement_union_type *)); -static char *gldelf32ebmip_get_script PARAMS ((int *isfile)); - -static void -gldelf32ebmip_before_parse() -{ - ldfile_output_architecture = bfd_arch_mips; - config.dynamic_link = true; -} - -/* Try to open a dynamic archive. This is where we know that ELF - dynamic libraries have an extension of .so. */ - -static boolean -gldelf32ebmip_open_dynamic_archive (arch, search, entry) - const char *arch; - search_dirs_type *search; - lang_input_statement_type *entry; -{ - const char *filename; - char *string; - - if (! entry->is_archive) - return false; - - filename = entry->filename; - - string = (char *) xmalloc (strlen (search->name) - + strlen (filename) - + strlen (arch) - + sizeof "/lib.so"); - - sprintf (string, "%s/lib%s%s.so", search->name, filename, arch); - - if (! ldfile_try_open_bfd (string, entry)) - { - free (string); - return false; - } - - entry->filename = string; - - /* We have found a dynamic object to include in the link. The ELF - backend linker will create a DT_NEEDED entry in the .dynamic - section naming this file. If this file includes a DT_SONAME - entry, it will be used. Otherwise, the ELF linker will just use - the name of the file. For an archive found by searching, like - this one, the DT_NEEDED entry should consist of just the name of - the file, without the path information used to find it. Note - that we only need to do this if we have a dynamic object; an - archive will never be referenced by a DT_NEEDED entry. - - FIXME: This approach--using bfd_elf_set_dt_needed_name--is not - very pretty. I haven't been able to think of anything that is - pretty, though. */ - if (bfd_check_format (entry->the_bfd, bfd_object) - && (entry->the_bfd->flags & DYNAMIC) != 0) - { - char *needed_name; - - ASSERT (entry->is_archive && entry->search_dirs_flag); - needed_name = (char *) xmalloc (strlen (filename) - + strlen (arch) - + sizeof "lib.so"); - sprintf (needed_name, "lib%s%s.so", filename, arch); - bfd_elf_set_dt_needed_name (entry->the_bfd, needed_name); - } - - return true; -} - - -/* These variables are required to pass information back and forth - between after_open and check_needed and stat_needed. */ - -static struct bfd_link_needed_list *global_needed; -static struct stat global_stat; -static boolean global_found; - -/* This is called after all the input files have been opened. */ - -static void -gldelf32ebmip_after_open () -{ - struct bfd_link_needed_list *needed, *l; - - /* We only need to worry about this when doing a final link. */ - if (link_info.relocateable || link_info.shared) - return; - - /* Get the list of files which appear in DT_NEEDED entries in - dynamic objects included in the link (often there will be none). - For each such file, we want to track down the corresponding - library, and include the symbol table in the link. This is what - the runtime dynamic linker will do. Tracking the files down here - permits one dynamic object to include another without requiring - special action by the person doing the link. Note that the - needed list can actually grow while we are stepping through this - loop. */ - needed = bfd_elf_get_needed_list (output_bfd, &link_info); - for (l = needed; l != NULL; l = l->next) - { - struct bfd_link_needed_list *ll; - const char *lib_path; - size_t len; - search_dirs_type *search; - - /* If we've already seen this file, skip it. */ - for (ll = needed; ll != l; ll = ll->next) - if (strcmp (ll->name, l->name) == 0) - break; - if (ll != l) - continue; - - /* See if this file was included in the link explicitly. */ - global_needed = l; - global_found = false; - lang_for_each_input_file (gldelf32ebmip_check_needed); - if (global_found) - continue; - - /* We need to find this file and include the symbol table. We - want to search for the file in the same way that the dynamic - linker will search. That means that we want to use - rpath_link, rpath, then the environment variable - LD_LIBRARY_PATH (native only), then the linker script - LIB_SEARCH_DIRS. We do not search using the -L arguments. */ - if (gldelf32ebmip_search_needed (command_line.rpath_link, - l->name)) - continue; - if (gldelf32ebmip_search_needed (command_line.rpath, l->name)) - continue; - if (command_line.rpath_link == NULL - && command_line.rpath == NULL) - { - lib_path = (const char *) getenv ("LD_RUN_PATH"); - if (gldelf32ebmip_search_needed (lib_path, l->name)) - continue; - } - len = strlen (l->name); - for (search = search_head; search != NULL; search = search->next) - { - char *filename; - - if (search->cmdline) - continue; - filename = (char *) xmalloc (strlen (search->name) + len + 2); - sprintf (filename, "%s/%s", search->name, l->name); - if (gldelf32ebmip_try_needed (filename)) - break; - free (filename); - } - if (search != NULL) - continue; - - einfo (_("%P: warning: %s, needed by %B, not found\n"), - l->name, l->by); - } -} - -/* Search for a needed file in a path. */ - -static boolean -gldelf32ebmip_search_needed (path, name) - const char *path; - const char *name; -{ - const char *s; - size_t len; - - if (path == NULL || *path == '\0') - return false; - len = strlen (name); - while (1) - { - char *filename, *sset; - - s = strchr (path, ':'); - if (s == NULL) - s = path + strlen (path); - - filename = (char *) xmalloc (s - path + len + 2); - if (s == path) - sset = filename; - else - { - memcpy (filename, path, s - path); - filename[s - path] = '/'; - sset = filename + (s - path) + 1; - } - strcpy (sset, name); - - if (gldelf32ebmip_try_needed (filename)) - return true; - - free (filename); - - if (*s == '\0') - break; - path = s + 1; - } - - return false; -} - -/* This function is called for each possible name for a dynamic object - named by a DT_NEEDED entry. */ - -static boolean -gldelf32ebmip_try_needed (name) - const char *name; -{ - bfd *abfd; - - abfd = bfd_openr (name, bfd_get_target (output_bfd)); - if (abfd == NULL) - return false; - if (! bfd_check_format (abfd, bfd_object)) - { - (void) bfd_close (abfd); - return false; - } - if ((bfd_get_file_flags (abfd) & DYNAMIC) == 0) - { - (void) bfd_close (abfd); - return false; - } - - /* We've found a dynamic object matching the DT_NEEDED entry. */ - - /* We have already checked that there is no other input file of the - same name. We must now check again that we are not including the - same file twice. We need to do this because on many systems - libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will - reference libc.so.1. If we have already included libc.so, we - don't want to include libc.so.1 if they are the same file, and we - can only check that using stat. */ - - if (bfd_stat (abfd, &global_stat) != 0) - einfo (_("%F%P:%B: bfd_stat failed: %E\n"), abfd); - global_found = false; - lang_for_each_input_file (gldelf32ebmip_stat_needed); - if (global_found) - { - /* Return true to indicate that we found the file, even though - we aren't going to do anything with it. */ - return true; - } - - /* Tell the ELF backend that don't want the output file to have a - DT_NEEDED entry for this file. */ - bfd_elf_set_dt_needed_name (abfd, ""); - - /* Add this file into the symbol table. */ - if (! bfd_link_add_symbols (abfd, &link_info)) - einfo (_("%F%B: could not read symbols: %E\n"), abfd); - - return true; -} - -/* See if an input file matches a DT_NEEDED entry by name. */ - -static void -gldelf32ebmip_check_needed (s) - lang_input_statement_type *s; -{ - if (global_found) - return; - - if (s->filename != NULL - && strcmp (s->filename, global_needed->name) == 0) - { - global_found = true; - return; - } - - if (s->the_bfd != NULL) - { - const char *soname; - - soname = bfd_elf_get_dt_soname (s->the_bfd); - if (soname != NULL - && strcmp (soname, global_needed->name) == 0) - { - global_found = true; - return; - } - } - - if (s->search_dirs_flag - && s->filename != NULL - && strchr (global_needed->name, '/') == NULL) - { - const char *f; - - f = strrchr (s->filename, '/'); - if (f != NULL - && strcmp (f + 1, global_needed->name) == 0) - { - global_found = true; - return; - } - } -} - -/* See if an input file matches a DT_NEEDED entry by running stat on - the file. */ - -static void -gldelf32ebmip_stat_needed (s) - lang_input_statement_type *s; -{ - struct stat st; - const char *suffix; - const char *soname; - const char *f; - - if (global_found) - return; - if (s->the_bfd == NULL) - return; - - if (bfd_stat (s->the_bfd, &st) != 0) - { - einfo (_("%P:%B: bfd_stat failed: %E\n"), s->the_bfd); - return; - } - - if (st.st_dev == global_stat.st_dev - && st.st_ino == global_stat.st_ino) - { - global_found = true; - return; - } - - /* We issue a warning if it looks like we are including two - different versions of the same shared library. For example, - there may be a problem if -lc picks up libc.so.6 but some other - shared library has a DT_NEEDED entry of libc.so.5. This is a - hueristic test, and it will only work if the name looks like - NAME.so.VERSION. FIXME: Depending on file names is error-prone. - If we really want to issue warnings about mixing version numbers - of shared libraries, we need to find a better way. */ - - if (strchr (global_needed->name, '/') != NULL) - return; - suffix = strstr (global_needed->name, ".so."); - if (suffix == NULL) - return; - suffix += sizeof ".so." - 1; - - soname = bfd_elf_get_dt_soname (s->the_bfd); - if (soname == NULL) - soname = s->filename; - - f = strrchr (soname, '/'); - if (f != NULL) - ++f; - else - f = soname; - - if (strncmp (f, global_needed->name, suffix - global_needed->name) == 0) - einfo (_("%P: warning: %s, needed by %B, may conflict with %s\n"), - global_needed->name, global_needed->by, f); -} - -/* This is called after the sections have been attached to output - sections, but before any sizes or addresses have been set. */ - -static void -gldelf32ebmip_before_allocation () -{ - const char *rpath; - asection *sinterp; - - /* If we are going to make any variable assignments, we need to let - the ELF backend know about them in case the variables are - referred to by dynamic objects. */ - lang_for_each_statement (gldelf32ebmip_find_statement_assignment); - - /* Let the ELF backend work out the sizes of any sections required - by dynamic linking. */ - rpath = command_line.rpath; - if (rpath == NULL) - rpath = (const char *) getenv ("LD_RUN_PATH"); - if (! (bfd_elf32_size_dynamic_sections - (output_bfd, command_line.soname, rpath, - command_line.filter_shlib, - (const char * const *) command_line.auxiliary_filters, - &link_info, &sinterp, lang_elf_version_info))) - einfo (_("%P%F: failed to set dynamic section sizes: %E\n")); - - /* Let the user override the dynamic linker we are using. */ - if (command_line.interpreter != NULL - && sinterp != NULL) - { - sinterp->contents = (bfd_byte *) command_line.interpreter; - sinterp->_raw_size = strlen (command_line.interpreter) + 1; - } - - /* Look for any sections named .gnu.warning. As a GNU extensions, - we treat such sections as containing warning messages. We print - out the warning message, and then zero out the section size so - that it does not get copied into the output file. */ - - { - LANG_FOR_EACH_INPUT_STATEMENT (is) - { - asection *s; - bfd_size_type sz; - char *msg; - boolean ret; - - if (is->just_syms_flag) - continue; - - s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning"); - if (s == NULL) - continue; - - sz = bfd_section_size (is->the_bfd, s); - msg = xmalloc ((size_t) sz + 1); - if (! bfd_get_section_contents (is->the_bfd, s, msg, (file_ptr) 0, sz)) - einfo (_("%F%B: Can't read contents of section .gnu.warning: %E\n"), - is->the_bfd); - msg[sz] = '\0'; - ret = link_info.callbacks->warning (&link_info, msg, - (const char *) NULL, - is->the_bfd, (asection *) NULL, - (bfd_vma) 0); - ASSERT (ret); - free (msg); - - /* Clobber the section size, so that we don't waste copying the - warning into the output file. */ - s->_raw_size = 0; - } - } -} - -/* This is called by the before_allocation routine via - lang_for_each_statement. It locates any assignment statements, and - tells the ELF backend about them, in case they are assignments to - symbols which are referred to by dynamic objects. */ - -static void -gldelf32ebmip_find_statement_assignment (s) - lang_statement_union_type *s; -{ - if (s->header.type == lang_assignment_statement_enum) - gldelf32ebmip_find_exp_assignment (s->assignment_statement.exp); -} - -/* Look through an expression for an assignment statement. */ - -static void -gldelf32ebmip_find_exp_assignment (exp) - etree_type *exp; -{ - struct bfd_link_hash_entry *h; - - switch (exp->type.node_class) - { - case etree_provide: - case etree_provided: - h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst, - false, false, false); - if (h == NULL) - break; - - /* We call record_link_assignment even if the symbol is defined. - This is because if it is defined by a dynamic object, we - actually want to use the value defined by the linker script, - not the value from the dynamic object (because we are setting - symbols like etext). If the symbol is defined by a regular - object, then, as it happens, calling record_link_assignment - will do no harm. */ - - /* Fall through. */ - case etree_assign: - if (strcmp (exp->assign.dst, ".") != 0) - { - if (! (bfd_elf32_record_link_assignment - (output_bfd, &link_info, exp->assign.dst, - exp->type.node_class != etree_assign ? true : false))) - einfo (_("%P%F: failed to record assignment to %s: %E\n"), - exp->assign.dst); - } - gldelf32ebmip_find_exp_assignment (exp->assign.src); - break; - - case etree_binary: - gldelf32ebmip_find_exp_assignment (exp->binary.lhs); - gldelf32ebmip_find_exp_assignment (exp->binary.rhs); - break; - - case etree_trinary: - gldelf32ebmip_find_exp_assignment (exp->trinary.cond); - gldelf32ebmip_find_exp_assignment (exp->trinary.lhs); - gldelf32ebmip_find_exp_assignment (exp->trinary.rhs); - break; - - case etree_unary: - gldelf32ebmip_find_exp_assignment (exp->unary.child); - break; - - default: - break; - } -} - -/* Place an orphan section. We use this to put random SHF_ALLOC - sections in the right segment. */ - -static asection *hold_section; -static lang_output_section_statement_type *hold_use; -static lang_output_section_statement_type *hold_text; -static lang_output_section_statement_type *hold_rodata; -static lang_output_section_statement_type *hold_data; -static lang_output_section_statement_type *hold_bss; -static lang_output_section_statement_type *hold_rel; - -/*ARGSUSED*/ -static boolean -gldelf32ebmip_place_orphan (file, s) - lang_input_statement_type *file; - asection *s; -{ - lang_output_section_statement_type *place; - asection *snew, **pps; - lang_statement_list_type *old; - lang_statement_list_type add; - etree_type *address; - const char *secname, *ps; - lang_output_section_statement_type *os; - - if ((s->flags & SEC_ALLOC) == 0) - return false; - - /* Look through the script to see where to place this section. */ - hold_section = s; - hold_use = NULL; - lang_for_each_statement (gldelf32ebmip_place_section); - - if (hold_use != NULL) - { - /* We have already placed a section with this name. */ - lang_add_section (&hold_use->children, s, hold_use, file); - return true; - } - - secname = bfd_get_section_name (s->owner, s); - - /* If this is a final link, then always put .gnu.warning.SYMBOL - sections into the .text section to get them out of the way. */ - if (! link_info.shared - && ! link_info.relocateable - && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0 - && hold_text != NULL) - { - lang_add_section (&hold_text->children, s, hold_text, file); - return true; - } - - /* Decide which segment the section should go in based on the - section name and section flags. */ - place = NULL; - if ((s->flags & SEC_HAS_CONTENTS) == 0 - && hold_bss != NULL) - place = hold_bss; - else if ((s->flags & SEC_READONLY) == 0 - && hold_data != NULL) - place = hold_data; - else if (strncmp (secname, ".rel", 4) == 0 - && hold_rel != NULL) - place = hold_rel; - else if ((s->flags & SEC_CODE) == 0 - && (s->flags & SEC_READONLY) != 0 - && hold_rodata != NULL) - place = hold_rodata; - else if ((s->flags & SEC_READONLY) != 0 - && hold_text != NULL) - place = hold_text; - if (place == NULL) - return false; - - /* Create the section in the output file, and put it in the right - place. This shuffling is to make the output file look neater. */ - snew = bfd_make_section (output_bfd, secname); - if (snew == NULL) - einfo (_("%P%F: output format %s cannot represent section called %s\n"), - output_bfd->xvec->name, secname); - if (place->bfd_section != NULL) - { - for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next) - ; - *pps = snew->next; - snew->next = place->bfd_section->next; - place->bfd_section->next = snew; - } - - /* Start building a list of statements for this section. */ - old = stat_ptr; - stat_ptr = &add; - lang_list_init (stat_ptr); - - /* If the name of the section is representable in C, then create - symbols to mark the start and the end of the section. */ - for (ps = secname; *ps != '\0'; ps++) - if (! ISALNUM (*ps) && *ps != '_') - break; - if (*ps == '\0' && config.build_constructors) - { - char *symname; - - symname = (char *) xmalloc (ps - secname + sizeof "__start_"); - sprintf (symname, "__start_%s", secname); - lang_add_assignment (exp_assop ('=', symname, - exp_unop (ALIGN_K, - exp_intop ((bfd_vma) 1 - << s->alignment_power)))); - } - - if (! link_info.relocateable) - address = NULL; - else - address = exp_intop ((bfd_vma) 0); - - lang_enter_output_section_statement (secname, address, 0, - (bfd_vma) 0, - (etree_type *) NULL, - (etree_type *) NULL, - (etree_type *) NULL); - - os = lang_output_section_statement_lookup (secname); - lang_add_section (&os->children, s, os, file); - - lang_leave_output_section_statement - ((bfd_vma) 0, "*default*", - (struct lang_output_section_phdr_list *) NULL, "*default*"); - stat_ptr = &add; - - if (*ps == '\0' && config.build_constructors) - { - char *symname; - - symname = (char *) xmalloc (ps - secname + sizeof "__stop_"); - sprintf (symname, "__stop_%s", secname); - lang_add_assignment (exp_assop ('=', symname, - exp_nameop (NAME, "."))); - } - - /* Now stick the new statement list right after PLACE. */ - *add.tail = place->header.next; - place->header.next = add.head; - - stat_ptr = old; - - return true; -} - -static void -gldelf32ebmip_place_section (s) - lang_statement_union_type *s; -{ - lang_output_section_statement_type *os; - - if (s->header.type != lang_output_section_statement_enum) - return; - - os = &s->output_section_statement; - - if (strcmp (os->name, hold_section->name) == 0) - hold_use = os; - - if (strcmp (os->name, ".text") == 0) - hold_text = os; - else if (strcmp (os->name, ".rodata") == 0) - hold_rodata = os; - else if (strcmp (os->name, ".data") == 0) - hold_data = os; - else if (strcmp (os->name, ".bss") == 0) - hold_bss = os; - else if (hold_rel == NULL - && os->bfd_section != NULL - && strncmp (os->name, ".rel", 4) == 0) - hold_rel = os; -} - -static char * -gldelf32ebmip_get_script(isfile) - int *isfile; -{ - *isfile = 0; - - if (link_info.relocateable == true && config.build_constructors == true) - return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\ - \"elf32-littlemips\")\n\ -OUTPUT_ARCH(mips)\n\ -ENTRY(_start)\n\ - /* For some reason, the Solaris linker makes bad executables\n\ - if gld -r is used and the intermediate file has sections starting\n\ - at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld\n\ - bug. But for now assigning the zero vmas works. */\n\ -SECTIONS\n\ -{\n\ - /* Read-only sections, merged into text segment: */\n\ - .interp 0 : { *(.interp) }\n\ - .reginfo 0 : { *(.reginfo) }\n\ - .dynamic 0 : { *(.dynamic) }\n\ - .dynstr 0 : { *(.dynstr) }\n\ - .dynsym 0 : { *(.dynsym) }\n\ - .hash 0 : { *(.hash) }\n\ - .rel.text 0 : { *(.rel.text) }\n\ - .rela.text 0 : { *(.rela.text) }\n\ - .rel.data 0 : { *(.rel.data) }\n\ - .rela.data 0 : { *(.rela.data) }\n\ - .rel.rodata 0 : { *(.rel.rodata) }\n\ - .rela.rodata 0 : { *(.rela.rodata) }\n\ - .rel.got 0 : { *(.rel.got) }\n\ - .rela.got 0 : { *(.rela.got) }\n\ - .rel.ctors 0 : { *(.rel.ctors) }\n\ - .rela.ctors 0 : { *(.rela.ctors) }\n\ - .rel.dtors 0 : { *(.rel.dtors) }\n\ - .rela.dtors 0 : { *(.rela.dtors) }\n\ - .rel.init 0 : { *(.rel.init) }\n\ - .rela.init 0 : { *(.rela.init) }\n\ - .rel.fini 0 : { *(.rel.fini) }\n\ - .rela.fini 0 : { *(.rela.fini) }\n\ - .rel.bss 0 : { *(.rel.bss) }\n\ - .rela.bss 0 : { *(.rela.bss) }\n\ - .rel.plt 0 : { *(.rel.plt) }\n\ - .rela.plt 0 : { *(.rela.plt) }\n\ - .rodata 0 : { *(.rodata) }\n\ - .rodata1 0 : { *(.rodata1) }\n\ - .init 0 : { *(.init) } =0\n\ - .text 0 :\n\ - {\n\ - *(.text)\n\ - *(.stub)\n\ - /* .gnu.warning sections are handled specially by elf32.em. */\n\ - *(.gnu.warning)\n\ - } =0\n\ - .fini 0 : { *(.fini) } =0\n\ - /* Adjust the address for the data segment. We want to adjust up to\n\ - the same address within the page on the next page up. It would\n\ - be more correct to do this:\n\ - The current expression does not correctly handle the case of a\n\ - text segment ending precisely at the end of a page; it causes the\n\ - data segment to skip a page. The above expression does not have\n\ - this problem, but it will currently (2/95) cause BFD to allocate\n\ - a single segment, combining both text and data, for this case.\n\ - This will prevent the text segment from being shared among\n\ - multiple executions of the program; I think that is more\n\ - important than losing a page of the virtual address space (note\n\ - that no actual memory is lost; the page which is skipped can not\n\ - be referenced). */\n\ - .data 0 :\n\ - {\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - .data1 0 : { *(.data1) }\n\ - .ctors 0 : { *(.ctors) }\n\ - .dtors 0 : { *(.dtors) }\n\ - .got 0 :\n\ - {\n\ - *(.got.plt) *(.got)\n\ - }\n\ - /* We want the small data sections together, so single-instruction offsets\n\ - can access them all, and initialized data all before uninitialized, so\n\ - we can shorten the on-disk segment size. */\n\ - .sdata 0 : { *(.sdata) }\n\ - .sbss 0 : { *(.sbss) *(.scommon) }\n\ - .bss 0 :\n\ - {\n\ - *(.dynbss)\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - /* These are needed for ELF backends which have not yet been\n\ - converted to the new style linker. */\n\ - .stab 0 : { *(.stab) }\n\ - .stabstr 0 : { *(.stabstr) }\n\ - /* DWARF debug sections.\n\ - Symbols in the .debug DWARF section are relative to the beginning of the\n\ - section so we begin .debug at 0. It's not clear yet what needs to happen\n\ - for the others. */\n\ - .debug 0 : { *(.debug) }\n\ - .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\ - .debug_aranges 0 : { *(.debug_aranges) }\n\ - .debug_pubnames 0 : { *(.debug_pubnames) }\n\ - .debug_sfnames 0 : { *(.debug_sfnames) }\n\ - .line 0 : { *(.line) }\n\ - /* These must appear regardless of . */\n\ - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\ - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\ -}\n\n"; - else if (link_info.relocateable == true) - return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\ - \"elf32-littlemips\")\n\ -OUTPUT_ARCH(mips)\n\ -ENTRY(_start)\n\ - /* For some reason, the Solaris linker makes bad executables\n\ - if gld -r is used and the intermediate file has sections starting\n\ - at non-zero addresses. Could be a Solaris ld bug, could be a GNU ld\n\ - bug. But for now assigning the zero vmas works. */\n\ -SECTIONS\n\ -{\n\ - /* Read-only sections, merged into text segment: */\n\ - .interp 0 : { *(.interp) }\n\ - .reginfo 0 : { *(.reginfo) }\n\ - .dynamic 0 : { *(.dynamic) }\n\ - .dynstr 0 : { *(.dynstr) }\n\ - .dynsym 0 : { *(.dynsym) }\n\ - .hash 0 : { *(.hash) }\n\ - .rel.text 0 : { *(.rel.text) }\n\ - .rela.text 0 : { *(.rela.text) }\n\ - .rel.data 0 : { *(.rel.data) }\n\ - .rela.data 0 : { *(.rela.data) }\n\ - .rel.rodata 0 : { *(.rel.rodata) }\n\ - .rela.rodata 0 : { *(.rela.rodata) }\n\ - .rel.got 0 : { *(.rel.got) }\n\ - .rela.got 0 : { *(.rela.got) }\n\ - .rel.ctors 0 : { *(.rel.ctors) }\n\ - .rela.ctors 0 : { *(.rela.ctors) }\n\ - .rel.dtors 0 : { *(.rel.dtors) }\n\ - .rela.dtors 0 : { *(.rela.dtors) }\n\ - .rel.init 0 : { *(.rel.init) }\n\ - .rela.init 0 : { *(.rela.init) }\n\ - .rel.fini 0 : { *(.rel.fini) }\n\ - .rela.fini 0 : { *(.rela.fini) }\n\ - .rel.bss 0 : { *(.rel.bss) }\n\ - .rela.bss 0 : { *(.rela.bss) }\n\ - .rel.plt 0 : { *(.rel.plt) }\n\ - .rela.plt 0 : { *(.rela.plt) }\n\ - .rodata 0 : { *(.rodata) }\n\ - .rodata1 0 : { *(.rodata1) }\n\ - .init 0 : { *(.init) } =0\n\ - .text 0 :\n\ - {\n\ - *(.text)\n\ - *(.stub)\n\ - /* .gnu.warning sections are handled specially by elf32.em. */\n\ - *(.gnu.warning)\n\ - } =0\n\ - .fini 0 : { *(.fini) } =0\n\ - /* Adjust the address for the data segment. We want to adjust up to\n\ - the same address within the page on the next page up. It would\n\ - be more correct to do this:\n\ - The current expression does not correctly handle the case of a\n\ - text segment ending precisely at the end of a page; it causes the\n\ - data segment to skip a page. The above expression does not have\n\ - this problem, but it will currently (2/95) cause BFD to allocate\n\ - a single segment, combining both text and data, for this case.\n\ - This will prevent the text segment from being shared among\n\ - multiple executions of the program; I think that is more\n\ - important than losing a page of the virtual address space (note\n\ - that no actual memory is lost; the page which is skipped can not\n\ - be referenced). */\n\ - .data 0 :\n\ - {\n\ - *(.data)\n\ - }\n\ - .data1 0 : { *(.data1) }\n\ - .ctors 0 : { *(.ctors) }\n\ - .dtors 0 : { *(.dtors) }\n\ - .got 0 :\n\ - {\n\ - *(.got.plt) *(.got)\n\ - }\n\ - /* We want the small data sections together, so single-instruction offsets\n\ - can access them all, and initialized data all before uninitialized, so\n\ - we can shorten the on-disk segment size. */\n\ - .sdata 0 : { *(.sdata) }\n\ - .sbss 0 : { *(.sbss) *(.scommon) }\n\ - .bss 0 :\n\ - {\n\ - *(.dynbss)\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - /* These are needed for ELF backends which have not yet been\n\ - converted to the new style linker. */\n\ - .stab 0 : { *(.stab) }\n\ - .stabstr 0 : { *(.stabstr) }\n\ - /* DWARF debug sections.\n\ - Symbols in the .debug DWARF section are relative to the beginning of the\n\ - section so we begin .debug at 0. It's not clear yet what needs to happen\n\ - for the others. */\n\ - .debug 0 : { *(.debug) }\n\ - .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\ - .debug_aranges 0 : { *(.debug_aranges) }\n\ - .debug_pubnames 0 : { *(.debug_pubnames) }\n\ - .debug_sfnames 0 : { *(.debug_sfnames) }\n\ - .line 0 : { *(.line) }\n\ - /* These must appear regardless of . */\n\ - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\ - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\ -}\n\n"; - else if (!config.text_read_only) - return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\ - \"elf32-littlemips\")\n\ -OUTPUT_ARCH(mips)\n\ -ENTRY(_start)\n\ - SEARCH_DIR(/usr/local/mips-elf/lib);\n\ -/* Do we need any of these for elf?\n\ - __DYNAMIC = 0; */\n\ -SECTIONS\n\ -{\n\ - /* Read-only sections, merged into text segment: */\n\ - . = 0x0400000;\n\ - .interp : { *(.interp) }\n\ - .reginfo : { *(.reginfo) }\n\ - .dynamic : { *(.dynamic) }\n\ - .dynstr : { *(.dynstr) }\n\ - .dynsym : { *(.dynsym) }\n\ - .hash : { *(.hash) }\n\ - .rel.text : { *(.rel.text) }\n\ - .rela.text : { *(.rela.text) }\n\ - .rel.data : { *(.rel.data) }\n\ - .rela.data : { *(.rela.data) }\n\ - .rel.rodata : { *(.rel.rodata) }\n\ - .rela.rodata : { *(.rela.rodata) }\n\ - .rel.got : { *(.rel.got) }\n\ - .rela.got : { *(.rela.got) }\n\ - .rel.ctors : { *(.rel.ctors) }\n\ - .rela.ctors : { *(.rela.ctors) }\n\ - .rel.dtors : { *(.rel.dtors) }\n\ - .rela.dtors : { *(.rela.dtors) }\n\ - .rel.init : { *(.rel.init) }\n\ - .rela.init : { *(.rela.init) }\n\ - .rel.fini : { *(.rel.fini) }\n\ - .rela.fini : { *(.rela.fini) }\n\ - .rel.bss : { *(.rel.bss) }\n\ - .rela.bss : { *(.rela.bss) }\n\ - .rel.plt : { *(.rel.plt) }\n\ - .rela.plt : { *(.rela.plt) }\n\ - .rodata : { *(.rodata) }\n\ - .rodata1 : { *(.rodata1) }\n\ - .init : { *(.init) } =0\n\ - .text :\n\ - {\n\ - _ftext = . ;\n\ - *(.text)\n\ - *(.stub)\n\ - /* .gnu.warning sections are handled specially by elf32.em. */\n\ - *(.gnu.warning)\n\ - } =0\n\ - _etext = .;\n\ - PROVIDE (etext = .);\n\ - .fini : { *(.fini) } =0\n\ - /* Adjust the address for the data segment. We want to adjust up to\n\ - the same address within the page on the next page up. It would\n\ - be more correct to do this:\n\ - . = .;\n\ - The current expression does not correctly handle the case of a\n\ - text segment ending precisely at the end of a page; it causes the\n\ - data segment to skip a page. The above expression does not have\n\ - this problem, but it will currently (2/95) cause BFD to allocate\n\ - a single segment, combining both text and data, for this case.\n\ - This will prevent the text segment from being shared among\n\ - multiple executions of the program; I think that is more\n\ - important than losing a page of the virtual address space (note\n\ - that no actual memory is lost; the page which is skipped can not\n\ - be referenced). */\n\ - . += . - 0x0400000;\n\ - .data :\n\ - {\n\ - _fdata = . ;\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - .data1 : { *(.data1) }\n\ - .ctors : { *(.ctors) }\n\ - .dtors : { *(.dtors) }\n\ - _gp = ALIGN(16) + 0x7ff0;\n\ - .got :\n\ - {\n\ - *(.got.plt) *(.got)\n\ - }\n\ - /* We want the small data sections together, so single-instruction offsets\n\ - can access them all, and initialized data all before uninitialized, so\n\ - we can shorten the on-disk segment size. */\n\ - .sdata : { *(.sdata) }\n\ - .lit8 : { *(.lit8) }\n\ - .lit4 : { *(.lit4) }\n\ - _edata = .;\n\ - PROVIDE (edata = .);\n\ - __bss_start = .;\n\ - _fbss = .;\n\ - .sbss : { *(.sbss) *(.scommon) }\n\ - .bss :\n\ - {\n\ - *(.dynbss)\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - _end = . ;\n\ - PROVIDE (end = .);\n\ - /* These are needed for ELF backends which have not yet been\n\ - converted to the new style linker. */\n\ - .stab 0 : { *(.stab) }\n\ - .stabstr 0 : { *(.stabstr) }\n\ - /* DWARF debug sections.\n\ - Symbols in the .debug DWARF section are relative to the beginning of the\n\ - section so we begin .debug at 0. It's not clear yet what needs to happen\n\ - for the others. */\n\ - .debug 0 : { *(.debug) }\n\ - .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\ - .debug_aranges 0 : { *(.debug_aranges) }\n\ - .debug_pubnames 0 : { *(.debug_pubnames) }\n\ - .debug_sfnames 0 : { *(.debug_sfnames) }\n\ - .line 0 : { *(.line) }\n\ - /* These must appear regardless of . */\n\ - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\ - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\ -}\n\n"; - else if (!config.magic_demand_paged) - return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\ - \"elf32-littlemips\")\n\ -OUTPUT_ARCH(mips)\n\ -ENTRY(_start)\n\ - SEARCH_DIR(/usr/local/mips-elf/lib);\n\ -/* Do we need any of these for elf?\n\ - __DYNAMIC = 0; */\n\ -SECTIONS\n\ -{\n\ - /* Read-only sections, merged into text segment: */\n\ - . = 0x0400000;\n\ - .interp : { *(.interp) }\n\ - .reginfo : { *(.reginfo) }\n\ - .dynamic : { *(.dynamic) }\n\ - .dynstr : { *(.dynstr) }\n\ - .dynsym : { *(.dynsym) }\n\ - .hash : { *(.hash) }\n\ - .rel.text : { *(.rel.text) }\n\ - .rela.text : { *(.rela.text) }\n\ - .rel.data : { *(.rel.data) }\n\ - .rela.data : { *(.rela.data) }\n\ - .rel.rodata : { *(.rel.rodata) }\n\ - .rela.rodata : { *(.rela.rodata) }\n\ - .rel.got : { *(.rel.got) }\n\ - .rela.got : { *(.rela.got) }\n\ - .rel.ctors : { *(.rel.ctors) }\n\ - .rela.ctors : { *(.rela.ctors) }\n\ - .rel.dtors : { *(.rel.dtors) }\n\ - .rela.dtors : { *(.rela.dtors) }\n\ - .rel.init : { *(.rel.init) }\n\ - .rela.init : { *(.rela.init) }\n\ - .rel.fini : { *(.rel.fini) }\n\ - .rela.fini : { *(.rela.fini) }\n\ - .rel.bss : { *(.rel.bss) }\n\ - .rela.bss : { *(.rela.bss) }\n\ - .rel.plt : { *(.rel.plt) }\n\ - .rela.plt : { *(.rela.plt) }\n\ - .rodata : { *(.rodata) }\n\ - .rodata1 : { *(.rodata1) }\n\ - .init : { *(.init) } =0\n\ - .text :\n\ - {\n\ - _ftext = . ;\n\ - *(.text)\n\ - *(.stub)\n\ - /* .gnu.warning sections are handled specially by elf32.em. */\n\ - *(.gnu.warning)\n\ - } =0\n\ - _etext = .;\n\ - PROVIDE (etext = .);\n\ - .fini : { *(.fini) } =0\n\ - /* Adjust the address for the data segment. We want to adjust up to\n\ - the same address within the page on the next page up. It would\n\ - be more correct to do this:\n\ - . = 0x10000000;\n\ - The current expression does not correctly handle the case of a\n\ - text segment ending precisely at the end of a page; it causes the\n\ - data segment to skip a page. The above expression does not have\n\ - this problem, but it will currently (2/95) cause BFD to allocate\n\ - a single segment, combining both text and data, for this case.\n\ - This will prevent the text segment from being shared among\n\ - multiple executions of the program; I think that is more\n\ - important than losing a page of the virtual address space (note\n\ - that no actual memory is lost; the page which is skipped can not\n\ - be referenced). */\n\ - . += 0x10000000 - 0x0400000;\n\ - .data :\n\ - {\n\ - _fdata = . ;\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - .data1 : { *(.data1) }\n\ - .ctors : { *(.ctors) }\n\ - .dtors : { *(.dtors) }\n\ - _gp = ALIGN(16) + 0x7ff0;\n\ - .got :\n\ - {\n\ - *(.got.plt) *(.got)\n\ - }\n\ - /* We want the small data sections together, so single-instruction offsets\n\ - can access them all, and initialized data all before uninitialized, so\n\ - we can shorten the on-disk segment size. */\n\ - .sdata : { *(.sdata) }\n\ - .lit8 : { *(.lit8) }\n\ - .lit4 : { *(.lit4) }\n\ - _edata = .;\n\ - PROVIDE (edata = .);\n\ - __bss_start = .;\n\ - _fbss = .;\n\ - .sbss : { *(.sbss) *(.scommon) }\n\ - .bss :\n\ - {\n\ - *(.dynbss)\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - _end = . ;\n\ - PROVIDE (end = .);\n\ - /* These are needed for ELF backends which have not yet been\n\ - converted to the new style linker. */\n\ - .stab 0 : { *(.stab) }\n\ - .stabstr 0 : { *(.stabstr) }\n\ - /* DWARF debug sections.\n\ - Symbols in the .debug DWARF section are relative to the beginning of the\n\ - section so we begin .debug at 0. It's not clear yet what needs to happen\n\ - for the others. */\n\ - .debug 0 : { *(.debug) }\n\ - .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\ - .debug_aranges 0 : { *(.debug_aranges) }\n\ - .debug_pubnames 0 : { *(.debug_pubnames) }\n\ - .debug_sfnames 0 : { *(.debug_sfnames) }\n\ - .line 0 : { *(.line) }\n\ - /* These must appear regardless of . */\n\ - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\ - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\ -}\n\n"; - else if (link_info.shared) - return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\ - \"elf32-littlemips\")\n\ -OUTPUT_ARCH(mips)\n\ -ENTRY(_start)\n\ - SEARCH_DIR(/usr/local/mips-elf/lib);\n\ -/* Do we need any of these for elf?\n\ - __DYNAMIC = 0; */\n\ -SECTIONS\n\ -{\n\ - /* Read-only sections, merged into text segment: */\n\ - . = 0x5ffe0000 + SIZEOF_HEADERS;\n\ - .reginfo : { *(.reginfo) }\n\ - .dynamic : { *(.dynamic) }\n\ - .dynstr : { *(.dynstr) }\n\ - .dynsym : { *(.dynsym) }\n\ - .hash : { *(.hash) }\n\ - .rel.text : { *(.rel.text) }\n\ - .rela.text : { *(.rela.text) }\n\ - .rel.data : { *(.rel.data) }\n\ - .rela.data : { *(.rela.data) }\n\ - .rel.rodata : { *(.rel.rodata) }\n\ - .rela.rodata : { *(.rela.rodata) }\n\ - .rel.got : { *(.rel.got) }\n\ - .rela.got : { *(.rela.got) }\n\ - .rel.ctors : { *(.rel.ctors) }\n\ - .rela.ctors : { *(.rela.ctors) }\n\ - .rel.dtors : { *(.rel.dtors) }\n\ - .rela.dtors : { *(.rela.dtors) }\n\ - .rel.init : { *(.rel.init) }\n\ - .rela.init : { *(.rela.init) }\n\ - .rel.fini : { *(.rel.fini) }\n\ - .rela.fini : { *(.rela.fini) }\n\ - .rel.bss : { *(.rel.bss) }\n\ - .rela.bss : { *(.rela.bss) }\n\ - .rel.plt : { *(.rel.plt) }\n\ - .rela.plt : { *(.rela.plt) }\n\ - .rodata : { *(.rodata) }\n\ - .rodata1 : { *(.rodata1) }\n\ - .init : { *(.init) } =0\n\ - .text :\n\ - {\n\ - *(.text)\n\ - *(.stub)\n\ - /* .gnu.warning sections are handled specially by elf32.em. */\n\ - *(.gnu.warning)\n\ - } =0\n\ - .fini : { *(.fini) } =0\n\ - /* Adjust the address for the data segment. We want to adjust up to\n\ - the same address within the page on the next page up. It would\n\ - be more correct to do this:\n\ - . = 0x10000000;\n\ - The current expression does not correctly handle the case of a\n\ - text segment ending precisely at the end of a page; it causes the\n\ - data segment to skip a page. The above expression does not have\n\ - this problem, but it will currently (2/95) cause BFD to allocate\n\ - a single segment, combining both text and data, for this case.\n\ - This will prevent the text segment from being shared among\n\ - multiple executions of the program; I think that is more\n\ - important than losing a page of the virtual address space (note\n\ - that no actual memory is lost; the page which is skipped can not\n\ - be referenced). */\n\ - . += 0x10000;\n\ - .data :\n\ - {\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - .data1 : { *(.data1) }\n\ - .ctors : { *(.ctors) }\n\ - .dtors : { *(.dtors) }\n\ - _gp = ALIGN(16) + 0x7ff0;\n\ - .got :\n\ - {\n\ - *(.got.plt) *(.got)\n\ - }\n\ - /* We want the small data sections together, so single-instruction offsets\n\ - can access them all, and initialized data all before uninitialized, so\n\ - we can shorten the on-disk segment size. */\n\ - .sdata : { *(.sdata) }\n\ - .lit8 : { *(.lit8) }\n\ - .lit4 : { *(.lit4) }\n\ - .sbss : { *(.sbss) *(.scommon) }\n\ - .bss :\n\ - {\n\ - *(.dynbss)\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - /* These are needed for ELF backends which have not yet been\n\ - converted to the new style linker. */\n\ - .stab 0 : { *(.stab) }\n\ - .stabstr 0 : { *(.stabstr) }\n\ - /* DWARF debug sections.\n\ - Symbols in the .debug DWARF section are relative to the beginning of the\n\ - section so we begin .debug at 0. It's not clear yet what needs to happen\n\ - for the others. */\n\ - .debug 0 : { *(.debug) }\n\ - .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\ - .debug_aranges 0 : { *(.debug_aranges) }\n\ - .debug_pubnames 0 : { *(.debug_pubnames) }\n\ - .debug_sfnames 0 : { *(.debug_sfnames) }\n\ - .line 0 : { *(.line) }\n\ - /* These must appear regardless of . */\n\ - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\ - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\ -}\n\n"; - else - return "OUTPUT_FORMAT(\"elf32-bigmips\", \"elf32-bigmips\",\n\ - \"elf32-littlemips\")\n\ -OUTPUT_ARCH(mips)\n\ -ENTRY(_start)\n\ - SEARCH_DIR(/usr/local/mips-elf/lib);\n\ -/* Do we need any of these for elf?\n\ - __DYNAMIC = 0; */\n\ -SECTIONS\n\ -{\n\ - /* Read-only sections, merged into text segment: */\n\ - . = 0x0400000;\n\ - .interp : { *(.interp) }\n\ - .reginfo : { *(.reginfo) }\n\ - .dynamic : { *(.dynamic) }\n\ - .dynstr : { *(.dynstr) }\n\ - .dynsym : { *(.dynsym) }\n\ - .hash : { *(.hash) }\n\ - .rel.text : { *(.rel.text) }\n\ - .rela.text : { *(.rela.text) }\n\ - .rel.data : { *(.rel.data) }\n\ - .rela.data : { *(.rela.data) }\n\ - .rel.rodata : { *(.rel.rodata) }\n\ - .rela.rodata : { *(.rela.rodata) }\n\ - .rel.got : { *(.rel.got) }\n\ - .rela.got : { *(.rela.got) }\n\ - .rel.ctors : { *(.rel.ctors) }\n\ - .rela.ctors : { *(.rela.ctors) }\n\ - .rel.dtors : { *(.rel.dtors) }\n\ - .rela.dtors : { *(.rela.dtors) }\n\ - .rel.init : { *(.rel.init) }\n\ - .rela.init : { *(.rela.init) }\n\ - .rel.fini : { *(.rel.fini) }\n\ - .rela.fini : { *(.rela.fini) }\n\ - .rel.bss : { *(.rel.bss) }\n\ - .rela.bss : { *(.rela.bss) }\n\ - .rel.plt : { *(.rel.plt) }\n\ - .rela.plt : { *(.rela.plt) }\n\ - .rodata : { *(.rodata) }\n\ - .rodata1 : { *(.rodata1) }\n\ - .init : { *(.init) } =0\n\ - .text :\n\ - {\n\ - _ftext = . ;\n\ - *(.text)\n\ - *(.stub)\n\ - /* .gnu.warning sections are handled specially by elf32.em. */\n\ - *(.gnu.warning)\n\ - } =0\n\ - _etext = .;\n\ - PROVIDE (etext = .);\n\ - .fini : { *(.fini) } =0\n\ - /* Adjust the address for the data segment. We want to adjust up to\n\ - the same address within the page on the next page up. It would\n\ - be more correct to do this:\n\ - . = 0x10000000;\n\ - The current expression does not correctly handle the case of a\n\ - text segment ending precisely at the end of a page; it causes the\n\ - data segment to skip a page. The above expression does not have\n\ - this problem, but it will currently (2/95) cause BFD to allocate\n\ - a single segment, combining both text and data, for this case.\n\ - This will prevent the text segment from being shared among\n\ - multiple executions of the program; I think that is more\n\ - important than losing a page of the virtual address space (note\n\ - that no actual memory is lost; the page which is skipped can not\n\ - be referenced). */\n\ - . += 0x10000000 - 0x0400000;\n\ - .data :\n\ - {\n\ - _fdata = . ;\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - .data1 : { *(.data1) }\n\ - .ctors : { *(.ctors) }\n\ - .dtors : { *(.dtors) }\n\ - _gp = ALIGN(16) + 0x7ff0;\n\ - .got :\n\ - {\n\ - *(.got.plt) *(.got)\n\ - }\n\ - /* We want the small data sections together, so single-instruction offsets\n\ - can access them all, and initialized data all before uninitialized, so\n\ - we can shorten the on-disk segment size. */\n\ - .sdata : { *(.sdata) }\n\ - .lit8 : { *(.lit8) }\n\ - .lit4 : { *(.lit4) }\n\ - _edata = .;\n\ - PROVIDE (edata = .);\n\ - __bss_start = .;\n\ - _fbss = .;\n\ - .sbss : { *(.sbss) *(.scommon) }\n\ - .bss :\n\ - {\n\ - *(.dynbss)\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - _end = . ;\n\ - PROVIDE (end = .);\n\ - /* These are needed for ELF backends which have not yet been\n\ - converted to the new style linker. */\n\ - .stab 0 : { *(.stab) }\n\ - .stabstr 0 : { *(.stabstr) }\n\ - /* DWARF debug sections.\n\ - Symbols in the .debug DWARF section are relative to the beginning of the\n\ - section so we begin .debug at 0. It's not clear yet what needs to happen\n\ - for the others. */\n\ - .debug 0 : { *(.debug) }\n\ - .debug_srcinfo 0 : { *(.debug_srcinfo) }\n\ - .debug_aranges 0 : { *(.debug_aranges) }\n\ - .debug_pubnames 0 : { *(.debug_pubnames) }\n\ - .debug_sfnames 0 : { *(.debug_sfnames) }\n\ - .line 0 : { *(.line) }\n\ - /* These must appear regardless of . */\n\ - .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }\n\ - .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }\n\ -}\n\n"; -} - -struct ld_emulation_xfer_struct ld_elf32ebmip_emulation = -{ - gldelf32ebmip_before_parse, - syslib_default, - hll_default, - after_parse_default, - gldelf32ebmip_after_open, - after_allocation_default, - set_output_arch_default, - ldemul_default_target, - gldelf32ebmip_before_allocation, - gldelf32ebmip_get_script, - "elf32ebmip", - "elf32-bigmips", - NULL, - NULL, - gldelf32ebmip_open_dynamic_archive, - gldelf32ebmip_place_orphan -}; diff --git a/ld/mpw-eppcmac.c b/ld/mpw-eppcmac.c deleted file mode 100644 index 12780975a19..00000000000 --- a/ld/mpw-eppcmac.c +++ /dev/null @@ -1,1224 +0,0 @@ -/* This file is is generated by a shell script. DO NOT EDIT! */ - -/* AIX emulation code for ppcmacos - Copyright 1991, 1993, 1995, 1996, 1997, 2000, 2001 - Free Software Foundation, Inc. - Written by Steve Chamberlain - AIX support by Ian Lance Taylor - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#define TARGET_IS_ppcmacos - -#include "bfd.h" -#include "sysdep.h" -#include "libiberty.h" -#include "safe-ctype.h" -#include "getopt.h" -#include "bfdlink.h" - -#include "ld.h" -#include "ldmain.h" -#include "ldmisc.h" -#include "ldexp.h" -#include "ldlang.h" -#include "ldctor.h" -#include "ldgram.h" -#include "ldfile.h" -#include "ldemul.h" - -static void gldppcmacos_before_parse PARAMS ((void)); -static int gldppcmacos_parse_args PARAMS ((int, char **)); -static void gldppcmacos_after_open PARAMS ((void)); -static void gldppcmacos_before_allocation PARAMS ((void)); -static void gldppcmacos_read_file PARAMS ((const char *, boolean)); -static void gldppcmacos_free PARAMS ((PTR)); -static void gldppcmacos_find_relocs - PARAMS ((lang_statement_union_type *)); -static void gldppcmacos_find_exp_assignment PARAMS ((etree_type *)); -static char *gldppcmacos_get_script PARAMS ((int *isfile)); - -/* The file alignment required for each section. */ -static unsigned long file_align; - -/* The maximum size the stack is permitted to grow. This is stored in - the a.out header. */ -static unsigned long maxstack; - -/* The maximum data size. This is stored in the a.out header. */ -static unsigned long maxdata; - -/* Whether to perform garbage collection. */ -static int gc = 1; - -/* The module type to use. */ -static unsigned short modtype = ('1' << 8) | 'L'; - -/* Whether the .text section must be read-only (i.e., no relocs - permitted). */ -static int textro; - -/* Whether to implement Unix like linker semantics. */ -static int unix_ld; - -/* Structure used to hold import file list. */ - -struct filelist -{ - struct filelist *next; - const char *name; -}; - -/* List of import files. */ -static struct filelist *import_files; - -/* List of export symbols read from the export files. */ - -struct export_symbol_list -{ - struct export_symbol_list *next; - const char *name; - boolean syscall; -}; - -static struct export_symbol_list *export_symbols; - -/* This routine is called before anything else is done. */ - -static void -gldppcmacos_before_parse() -{ -#ifndef TARGET_ /* I.e., if not generic. */ - ldfile_output_architecture = bfd_arch_powerpc; -#endif /* not TARGET_ */ -} - -/* Handle AIX specific options. */ - -static int -gldppcmacos_parse_args (argc, argv) - int argc; - char **argv; -{ - int prevoptind = optind; - int prevopterr = opterr; - int indx; - int longind; - int optc; - long val; - char *end; - -#define OPTION_IGNORE (300) -#define OPTION_AUTOIMP (OPTION_IGNORE + 1) -#define OPTION_ERNOTOK (OPTION_AUTOIMP + 1) -#define OPTION_EROK (OPTION_ERNOTOK + 1) -#define OPTION_EXPORT (OPTION_EROK + 1) -#define OPTION_IMPORT (OPTION_EXPORT + 1) -#define OPTION_LOADMAP (OPTION_IMPORT + 1) -#define OPTION_MAXDATA (OPTION_LOADMAP + 1) -#define OPTION_MAXSTACK (OPTION_MAXDATA + 1) -#define OPTION_MODTYPE (OPTION_MAXSTACK + 1) -#define OPTION_NOAUTOIMP (OPTION_MODTYPE + 1) -#define OPTION_NOSTRCMPCT (OPTION_NOAUTOIMP + 1) -#define OPTION_PD (OPTION_NOSTRCMPCT + 1) -#define OPTION_PT (OPTION_PD + 1) -#define OPTION_STRCMPCT (OPTION_PT + 1) -#define OPTION_UNIX (OPTION_STRCMPCT + 1) - - static struct option longopts[] = { - {"basis", no_argument, NULL, OPTION_IGNORE}, - {"bautoimp", no_argument, NULL, OPTION_AUTOIMP}, - {"bcomprld", no_argument, NULL, OPTION_IGNORE}, - {"bcrld", no_argument, NULL, OPTION_IGNORE}, - {"bcror31", no_argument, NULL, OPTION_IGNORE}, - {"bD", required_argument, NULL, OPTION_MAXDATA}, - {"bE", required_argument, NULL, OPTION_EXPORT}, - {"bernotok", no_argument, NULL, OPTION_ERNOTOK}, - {"berok", no_argument, NULL, OPTION_EROK}, - {"berrmsg", no_argument, NULL, OPTION_IGNORE}, - {"bexport", required_argument, NULL, OPTION_EXPORT}, - {"bf", no_argument, NULL, OPTION_ERNOTOK}, - {"bgc", no_argument, &gc, 1}, - {"bh", required_argument, NULL, OPTION_IGNORE}, - {"bhalt", required_argument, NULL, OPTION_IGNORE}, - {"bI", required_argument, NULL, OPTION_IMPORT}, - {"bimport", required_argument, NULL, OPTION_IMPORT}, - {"bl", required_argument, NULL, OPTION_LOADMAP}, - {"bloadmap", required_argument, NULL, OPTION_LOADMAP}, - {"bmaxdata", required_argument, NULL, OPTION_MAXDATA}, - {"bmaxstack", required_argument, NULL, OPTION_MAXSTACK}, - {"bM", required_argument, NULL, OPTION_MODTYPE}, - {"bmodtype", required_argument, NULL, OPTION_MODTYPE}, - {"bnoautoimp", no_argument, NULL, OPTION_NOAUTOIMP}, - {"bnodelcsect", no_argument, NULL, OPTION_IGNORE}, - {"bnoentry", no_argument, NULL, OPTION_IGNORE}, - {"bnogc", no_argument, &gc, 0}, - {"bnso", no_argument, NULL, OPTION_NOAUTOIMP}, - {"bnostrcmpct", no_argument, NULL, OPTION_NOSTRCMPCT}, - {"bnotextro", no_argument, &textro, 0}, - {"bnro", no_argument, &textro, 0}, - {"bpD", required_argument, NULL, OPTION_PD}, - {"bpT", required_argument, NULL, OPTION_PT}, - {"bro", no_argument, &textro, 1}, - {"bS", required_argument, NULL, OPTION_MAXSTACK}, - {"bso", no_argument, NULL, OPTION_AUTOIMP}, - {"bstrcmpct", no_argument, NULL, OPTION_STRCMPCT}, - {"btextro", no_argument, &textro, 1}, - {"static", no_argument, NULL, OPTION_NOAUTOIMP}, - {"unix", no_argument, NULL, OPTION_UNIX}, - {NULL, no_argument, NULL, 0} - }; - - /* Options supported by the AIX linker which we do not support: -f, - -S, -v, -Z, -bbindcmds, -bbinder, -bbindopts, -bcalls, -bcaps, - -bcror15, -bdebugopt, -bdbg, -bdelcsect, -bex?, -bfilelist, -bfl, - -bgcbypass, -bglink, -binsert, -bi, -bloadmap, -bl, -bmap, -bnl, - -bnobind, -bnocomprld, -bnocrld, -bnoerrmsg, -bnoglink, - -bnoloadmap, -bnl, -bnoobjreorder, -bnoquiet, -bnoreorder, - -bnotypchk, -bnox, -bquiet, -bR, -brename, -breorder, -btypchk, - -bx, -bX, -bxref. */ - - /* If the current option starts with -b, change the first : to an =. - The AIX linker uses : to separate the option from the argument; - changing it to = lets us treat it as a getopt option. */ - indx = optind; - if (indx == 0) - indx = 1; - if (indx < argc && strncmp (argv[indx], "-b", 2) == 0) - { - char *s; - - for (s = argv[indx]; *s != '\0'; s++) - { - if (*s == ':') - { - *s = '='; - break; - } - } - } - - opterr = 0; - optc = getopt_long_only (argc, argv, "-D:H:KT:z", longopts, &longind); - opterr = prevopterr; - - switch (optc) - { - default: - optind = prevoptind; - return 0; - - case 0: - /* Long option which just sets a flag. */ - break; - - case 'D': - val = strtol (optarg, &end, 0); - if (*end != '\0') - einfo (_("%P: warning: ignoring invalid -D number %s\n"), optarg); - else if (val != -1) - lang_section_start (".data", exp_intop (val)); - break; - - case 'H': - val = strtoul (optarg, &end, 0); - if (*end != '\0' - || (val & (val - 1)) != 0) - einfo (_("%P: warning: ignoring invalid -H number %s\n"), optarg); - else - file_align = val; - break; - - case 'K': - case 'z': - /* FIXME: This should use the page size for the target system. */ - file_align = 4096; - break; - - case 'T': - /* On AIX this is the same as GNU ld -Ttext. When we see -T - number, we assume the AIX option is intended. Otherwise, we - assume the usual GNU ld -T option is intended. We can't just - ignore the AIX option, because gcc passes it to the linker. */ - val = strtoul (optarg, &end, 0); - if (*end != '\0') - { - optind = prevoptind; - return 0; - } - lang_section_start (".text", exp_intop (val)); - break; - - case OPTION_IGNORE: - break; - - case OPTION_AUTOIMP: - link_info.static_link = false; - break; - - case OPTION_ERNOTOK: - force_make_executable = false; - break; - - case OPTION_EROK: - force_make_executable = true; - break; - - case OPTION_EXPORT: - gldppcmacos_read_file (optarg, false); - break; - - case OPTION_IMPORT: - { - struct filelist *n; - struct filelist **flpp; - - n = (struct filelist *) xmalloc (sizeof (struct filelist)); - n->next = NULL; - n->name = optarg; - flpp = &import_files; - while (*flpp != NULL) - flpp = &(*flpp)->next; - *flpp = n; - } - break; - - case OPTION_LOADMAP: - config.map_filename = optarg; - break; - - case OPTION_MAXDATA: - val = strtoul (optarg, &end, 0); - if (*end != '\0') - einfo (_("%P: warning: ignoring invalid -bmaxdata number %s\n"), - optarg); - else - maxdata = val; - break; - - case OPTION_MAXSTACK: - val = strtoul (optarg, &end, 0); - if (*end != '\0') - einfo (_("%P: warning: ignoring invalid -bmaxstack number %s\n"), - optarg); - else - maxstack = val; - break; - - case OPTION_MODTYPE: - if (*optarg == 'S') - { - link_info.shared = true; - ++optarg; - } - if (*optarg == '\0' || optarg[1] == '\0') - einfo (_("%P: warning: ignoring invalid module type %s\n"), optarg); - else - modtype = (*optarg << 8) | optarg[1]; - break; - - case OPTION_NOAUTOIMP: - link_info.static_link = true; - break; - - case OPTION_NOSTRCMPCT: - link_info.traditional_format = true; - break; - - case OPTION_PD: - /* This sets the page that the .data section is supposed to - start on. The offset within the page should still be the - offset within the file, so we need to build an appropriate - expression. */ - val = strtoul (optarg, &end, 0); - if (*end != '\0') - einfo (_("%P: warning: ignoring invalid -pD number %s\n"), optarg); - else - { - etree_type *t; - - t = exp_binop ('+', - exp_intop (val), - exp_binop ('&', - exp_nameop (NAME, "."), - exp_intop (0xfff))); - t = exp_binop ('&', - exp_binop ('+', t, exp_intop (7)), - exp_intop (~ (bfd_vma) 7)); - lang_section_start (".data", t); - } - break; - - case OPTION_PT: - /* This set the page that the .text section is supposed to start - on. The offset within the page should still be the offset - within the file. */ - val = strtoul (optarg, &end, 0); - if (*end != '\0') - einfo (_("%P: warning: ignoring invalid -pT number %s\n"), optarg); - else - { - etree_type *t; - - t = exp_binop ('+', - exp_intop (val), - exp_nameop (SIZEOF_HEADERS, NULL)); - t = exp_binop ('&', - exp_binop ('+', t, exp_intop (7)), - exp_intop (~ (bfd_vma) 7)); - lang_section_start (".text", t); - } - break; - - case OPTION_STRCMPCT: - link_info.traditional_format = false; - break; - - case OPTION_UNIX: - unix_ld = true; - break; - } - - return 1; -} - -/* This is called when an input file can not be recognized as a BFD - object or an archive. If the file starts with #!, we must treat it - as an import file. This is for AIX compatibility. */ - -static boolean -gldppcmacos_unrecognized_file (entry) - lang_input_statement_type *entry; -{ - FILE *e; - boolean ret; - - e = fopen (entry->filename, FOPEN_RT); - if (e == NULL) - return false; - - ret = false; - - if (getc (e) == '#' && getc (e) == '!') - { - struct filelist *n; - struct filelist **flpp; - - n = (struct filelist *) xmalloc (sizeof (struct filelist)); - n->next = NULL; - n->name = entry->filename; - flpp = &import_files; - while (*flpp != NULL) - flpp = &(*flpp)->next; - *flpp = n; - - ret = true; - entry->loaded = true; - } - - fclose (e); - - return ret; -} - -/* This is called after the input files have been opened. */ - -static void -gldppcmacos_after_open () -{ - boolean r; - struct set_info *p; - - /* Call ldctor_build_sets, after pretending that this is a - relocateable link. We do this because AIX requires relocation - entries for all references to symbols, even in a final - executable. Of course, we only want to do this if we are - producing an XCOFF output file. */ - r = link_info.relocateable; - if (strstr (bfd_get_target (output_bfd), "xcoff") != NULL) - link_info.relocateable = true; - ldctor_build_sets (); - link_info.relocateable = r; - - /* For each set, record the size, so that the XCOFF backend can - output the correct csect length. */ - for (p = sets; p != (struct set_info *) NULL; p = p->next) - { - bfd_size_type size; - - /* If the symbol is defined, we may have been invoked from - collect, and the sets may already have been built, so we do - not do anything. */ - if (p->h->type == bfd_link_hash_defined - || p->h->type == bfd_link_hash_defweak) - continue; - - if (p->reloc != BFD_RELOC_CTOR) - { - /* Handle this if we need to. */ - abort (); - } - - size = (p->count + 2) * 4; - if (! bfd_xcoff_link_record_set (output_bfd, &link_info, p->h, size)) - einfo (_("%F%P: bfd_xcoff_link_record_set failed: %E\n")); - } -} - -/* This is called after the sections have been attached to output - sections, but before any sizes or addresses have been set. */ - -static void -gldppcmacos_before_allocation () -{ - struct filelist *fl; - struct export_symbol_list *el; - char *libpath; - asection *special_sections[6]; - int i; - - /* Handle the import and export files, if any. */ - for (fl = import_files; fl != NULL; fl = fl->next) - gldppcmacos_read_file (fl->name, true); - for (el = export_symbols; el != NULL; el = el->next) - { - struct bfd_link_hash_entry *h; - - h = bfd_link_hash_lookup (link_info.hash, el->name, false, false, false); - if (h == NULL) - einfo (_("%P%F: bfd_link_hash_lookup of export symbol failed: %E\n")); - if (! bfd_xcoff_export_symbol (output_bfd, &link_info, h, el->syscall)) - einfo (_("%P%F: bfd_xcoff_export_symbol failed: %E\n")); - } - - /* Track down all relocations called for by the linker script (these - are typically constructor/destructor entries created by - CONSTRUCTORS) and let the backend know it will need to create - .loader relocs for them. */ - lang_for_each_statement (gldppcmacos_find_relocs); - - /* We need to build LIBPATH from the -L arguments. If any -rpath - arguments were used, though, we use -rpath instead, as a GNU - extension. */ - if (command_line.rpath != NULL) - libpath = command_line.rpath; - else if (search_head == NULL) - libpath = (char *) ""; - else - { - size_t len; - search_dirs_type *search; - - len = strlen (search_head->name); - libpath = xmalloc (len + 1); - strcpy (libpath, search_head->name); - for (search = search_head->next; search != NULL; search = search->next) - { - size_t nlen; - - nlen = strlen (search->name); - libpath = xrealloc (libpath, len + nlen + 2); - libpath[len] = ':'; - strcpy (libpath + len + 1, search->name); - len += nlen + 1; - } - } - - /* Let the XCOFF backend set up the .loader section. */ - if (! bfd_xcoff_size_dynamic_sections (output_bfd, &link_info, libpath, - entry_symbol, file_align, - maxstack, maxdata, - gc && ! unix_ld ? true : false, - modtype, - textro ? true : false, - unix_ld, - special_sections)) - einfo (_("%P%F: failed to set dynamic section sizes: %E\n")); - - /* Look through the special sections, and put them in the right - place in the link ordering. This is especially magic. */ - for (i = 0; i < 6; i++) - { - asection *sec; - lang_output_section_statement_type *os; - lang_statement_union_type **pls; - lang_input_section_type *is; - const char *oname; - boolean start; - - sec = special_sections[i]; - if (sec == NULL) - continue; - - /* Remove this section from the list of the output section. - This assumes we know what the script looks like. */ - is = NULL; - os = lang_output_section_find (sec->output_section->name); - if (os == NULL) - einfo (_("%P%F: can't find output section %s\n"), - sec->output_section->name); - for (pls = &os->children.head; *pls != NULL; pls = &(*pls)->header.next) - { - if ((*pls)->header.type == lang_input_section_enum - && (*pls)->input_section.section == sec) - { - is = (lang_input_section_type *) *pls; - *pls = (*pls)->header.next; - break; - } - if ((*pls)->header.type == lang_wild_statement_enum) - { - lang_statement_union_type **pwls; - - for (pwls = &(*pls)->wild_statement.children.head; - *pwls != NULL; - pwls = &(*pwls)->header.next) - { - if ((*pwls)->header.type == lang_input_section_enum - && (*pwls)->input_section.section == sec) - { - is = (lang_input_section_type *) *pwls; - *pwls = (*pwls)->header.next; - break; - } - } - if (is != NULL) - break; - } - } - - if (is == NULL) - einfo (_("%P%F: can't find %s in output section\n"), - bfd_get_section_name (sec->owner, sec)); - - /* Now figure out where the section should go. */ - switch (i) - { - default: /* to avoid warnings */ - case 0: - /* _text */ - oname = ".text"; - start = true; - break; - case 1: - /* _etext */ - oname = ".text"; - start = false; - break; - case 2: - /* _data */ - oname = ".data"; - start = true; - break; - case 3: - /* _edata */ - oname = ".data"; - start = false; - break; - case 4: - case 5: - /* _end and end */ - oname = ".bss"; - start = false; - break; - } - - os = lang_output_section_find (oname); - - if (start) - { - is->header.next = os->children.head; - os->children.head = (lang_statement_union_type *) is; - } - else - { - is->header.next = NULL; - lang_statement_append (&os->children, - (lang_statement_union_type *) is, - &is->header.next); - } - } -} - -/* Read an import or export file. For an import file, this is called - by the before_allocation emulation routine. For an export file, - this is called by the parse_args emulation routine. */ - -static void -gldppcmacos_read_file (filename, import) - const char *filename; - boolean import; -{ - struct obstack *o; - FILE *f; - int lineno; - int c; - boolean keep; - const char *imppath; - const char *impfile; - const char *impmember; - - o = (struct obstack *) xmalloc (sizeof (struct obstack)); - obstack_specify_allocation (o, 0, 0, xmalloc, gldppcmacos_free); - - f = fopen (filename, FOPEN_RT); - if (f == NULL) - { - bfd_set_error (bfd_error_system_call); - einfo ("%F%s: %E\n", filename); - } - - keep = false; - - imppath = NULL; - impfile = NULL; - impmember = NULL; - - lineno = 0; - while ((c = getc (f)) != EOF) - { - char *s; - char *symname; - boolean syscall; - bfd_vma address; - struct bfd_link_hash_entry *h; - - if (c != '\n') - { - obstack_1grow (o, c); - continue; - } - - obstack_1grow (o, '\0'); - ++lineno; - - s = (char *) obstack_base (o); - while (ISSPACE (*s)) - ++s; - if (*s == '\0' - || *s == '*' - || (*s == '#' && s[1] == ' ') - || (! import && *s == '#' && s[1] == '!')) - { - obstack_free (o, obstack_base (o)); - continue; - } - - if (*s == '#' && s[1] == '!') - { - s += 2; - while (ISSPACE (*s)) - ++s; - if (*s == '\0') - { - imppath = NULL; - impfile = NULL; - impmember = NULL; - obstack_free (o, obstack_base (o)); - } - else if (*s == '(') - einfo (_("%F%s%d: #! ([member]) is not supported in import files\n"), - filename, lineno); - else - { - char cs; - char *file; - - (void) obstack_finish (o); - keep = true; - imppath = s; - file = NULL; - while (! ISSPACE (*s) && *s != '(' && *s != '\0') - { - if (*s == '/') - file = s + 1; - ++s; - } - if (file != NULL) - { - file[-1] = '\0'; - impfile = file; - if (imppath == file - 1) - imppath = "/"; - } - else - { - impfile = imppath; - imppath = ""; - } - cs = *s; - *s = '\0'; - while (ISSPACE (cs)) - { - ++s; - cs = *s; - } - if (cs != '(') - { - impmember = ""; - if (cs != '\0') - einfo (_("%s:%d: warning: syntax error in import file\n"), - filename, lineno); - } - else - { - ++s; - impmember = s; - while (*s != ')' && *s != '\0') - ++s; - if (*s == ')') - *s = '\0'; - else - einfo (_("%s:%d: warning: syntax error in import file\n"), - filename, lineno); - } - } - - continue; - } - - /* This is a symbol to be imported or exported. */ - symname = s; - syscall = false; - address = (bfd_vma) -1; - - while (! ISSPACE (*s) && *s != '\0') - ++s; - if (*s != '\0') - { - char *se; - - *s++ = '\0'; - - while (ISSPACE (*s)) - ++s; - - se = s; - while (! ISSPACE (*se) && *se != '\0') - ++se; - if (*se != '\0') - { - *se++ = '\0'; - while (ISSPACE (*se)) - ++se; - if (*se != '\0') - einfo (_("%s%d: warning: syntax error in import/export file\n"), - filename, lineno); - } - - if (strcasecmp (s, "svc") == 0 - || strcasecmp (s, "syscall") == 0) - syscall = true; - else - { - char *end; - - address = strtoul (s, &end, 0); - if (*end != '\0') - einfo (_("%s:%d: warning: syntax error in import/export file\n"), - filename, lineno); - } - } - - if (! import) - { - struct export_symbol_list *n; - - ldlang_add_undef (symname); - n = ((struct export_symbol_list *) - xmalloc (sizeof (struct export_symbol_list))); - n->next = export_symbols; - n->name = xstrdup (symname); - n->syscall = syscall; - export_symbols = n; - } - else - { - h = bfd_link_hash_lookup (link_info.hash, symname, false, false, - true); - if (h == NULL || h->type == bfd_link_hash_new) - { - /* We can just ignore attempts to import an unreferenced - symbol. */ - } - else - { - if (! bfd_xcoff_import_symbol (output_bfd, &link_info, h, - address, imppath, impfile, - impmember)) - einfo (_("%X%s:%d: failed to import symbol %s: %E\n"), - filename, lineno, symname); - } - } - - obstack_free (o, obstack_base (o)); - } - - if (obstack_object_size (o) > 0) - { - einfo (_("%s:%d: warning: ignoring unterminated last line\n"), - filename, lineno); - obstack_free (o, obstack_base (o)); - } - - if (! keep) - { - obstack_free (o, NULL); - free (o); - } -} - -/* This routine saves us from worrying about declaring free. */ - -static void -gldppcmacos_free (p) - PTR p; -{ - free (p); -} - -/* This is called by the before_allocation routine via - lang_for_each_statement. It looks for relocations and assignments - to symbols. */ - -static void -gldppcmacos_find_relocs (s) - lang_statement_union_type *s; -{ - if (s->header.type == lang_reloc_statement_enum) - { - lang_reloc_statement_type *rs; - - rs = &s->reloc_statement; - if (rs->name == NULL) - einfo (_("%F%P: only relocations against symbols are permitted\n")); - if (! bfd_xcoff_link_count_reloc (output_bfd, &link_info, rs->name)) - einfo (_("%F%P: bfd_xcoff_link_count_reloc failed: %E\n")); - } - - if (s->header.type == lang_assignment_statement_enum) - gldppcmacos_find_exp_assignment (s->assignment_statement.exp); -} - -/* Look through an expression for an assignment statement. */ - -static void -gldppcmacos_find_exp_assignment (exp) - etree_type *exp; -{ - struct bfd_link_hash_entry *h; - - switch (exp->type.node_class) - { - case etree_provide: - h = bfd_link_hash_lookup (link_info.hash, exp->assign.dst, - false, false, false); - if (h == NULL) - break; - /* Fall through. */ - case etree_assign: - if (strcmp (exp->assign.dst, ".") != 0) - { - if (! bfd_xcoff_record_link_assignment (output_bfd, &link_info, - exp->assign.dst)) - einfo (_("%P%F: failed to record assignment to %s: %E\n"), - exp->assign.dst); - } - gldppcmacos_find_exp_assignment (exp->assign.src); - break; - - case etree_binary: - gldppcmacos_find_exp_assignment (exp->binary.lhs); - gldppcmacos_find_exp_assignment (exp->binary.rhs); - break; - - case etree_trinary: - gldppcmacos_find_exp_assignment (exp->trinary.cond); - gldppcmacos_find_exp_assignment (exp->trinary.lhs); - gldppcmacos_find_exp_assignment (exp->trinary.rhs); - break; - - case etree_unary: - gldppcmacos_find_exp_assignment (exp->unary.child); - break; - - default: - break; - } -} - -static char * -gldppcmacos_get_script(isfile) - int *isfile; -{ - *isfile = 0; - - if (link_info.relocateable == true && config.build_constructors == true) - return -"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ -OUTPUT_ARCH(powerpc)\n\ -ENTRY(__start)\n\ -SECTIONS\n\ -{\n\ - .pad 0 : { *(.pad) }\n\ - .text 0 : {\n\ - *(.text)\n\ - *(.pr)\n\ - *(.ro)\n\ - *(.db)\n\ - *(.gl)\n\ - *(.xo)\n\ - *(.ti)\n\ - *(.tb)\n\ - }\n\ - .data 0 : {\n\ - *(.data)\n\ - *(.rw)\n\ - *(.sv)\n\ - *(.ua)\n\ - . = ALIGN(4);\n\ - CONSTRUCTORS\n\ - *(.ds)\n\ - *(.tc0)\n\ - *(.tc)\n\ - *(.td)\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(.bs)\n\ - *(.uc)\n\ - *(COMMON)\n\ - }\n\ - .loader 0 : {\n\ - *(.loader)\n\ - }\n\ - .debug 0 : {\n\ - *(.debug)\n\ - }\n\ -}\n\n" - ; else if (link_info.relocateable == true) return -"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ -OUTPUT_ARCH(powerpc)\n\ -ENTRY(__start)\n\ -SECTIONS\n\ -{\n\ - .pad 0 : { *(.pad) }\n\ - .text 0 : {\n\ - *(.text)\n\ - *(.pr)\n\ - *(.ro)\n\ - *(.db)\n\ - *(.gl)\n\ - *(.xo)\n\ - *(.ti)\n\ - *(.tb)\n\ - }\n\ - .data 0 : {\n\ - *(.data)\n\ - *(.rw)\n\ - *(.sv)\n\ - *(.ua)\n\ - . = ALIGN(4);\n\ - *(.ds)\n\ - *(.tc0)\n\ - *(.tc)\n\ - *(.td)\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(.bs)\n\ - *(.uc)\n\ - *(COMMON)\n\ - }\n\ - .loader 0 : {\n\ - *(.loader)\n\ - }\n\ - .debug 0 : {\n\ - *(.debug)\n\ - }\n\ -}\n\n" - ; else if (!config.text_read_only) return -"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ -OUTPUT_ARCH(powerpc)\n\ - SEARCH_DIR(/usr/local/powerpc-apple-macos/lib);\n\ -ENTRY(__start)\n\ -SECTIONS\n\ -{\n\ - .pad 0 : { *(.pad) }\n\ - .text : {\n\ - PROVIDE (_text = .);\n\ - *(.text)\n\ - *(.pr)\n\ - *(.ro)\n\ - *(.db)\n\ - *(.gl)\n\ - *(.xo)\n\ - *(.ti)\n\ - *(.tb)\n\ - PROVIDE (_etext = .);\n\ - }\n\ - .data 0 : {\n\ - PROVIDE (_data = .);\n\ - *(.data)\n\ - *(.rw)\n\ - *(.sv)\n\ - *(.ua)\n\ - . = ALIGN(4);\n\ - CONSTRUCTORS\n\ - *(.ds)\n\ - *(.tc0)\n\ - *(.tc)\n\ - *(.td)\n\ - PROVIDE (_edata = .);\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(.bs)\n\ - *(.uc)\n\ - *(COMMON)\n\ - PROVIDE (_end = .);\n\ - PROVIDE (end = .);\n\ - }\n\ - .loader 0 : {\n\ - *(.loader)\n\ - }\n\ - .debug 0 : {\n\ - *(.debug)\n\ - }\n\ -}\n\n" - ; else if (!config.magic_demand_paged) return -"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ -OUTPUT_ARCH(powerpc)\n\ - SEARCH_DIR(/usr/local/powerpc-apple-macos/lib);\n\ -ENTRY(__start)\n\ -SECTIONS\n\ -{\n\ - .pad 0 : { *(.pad) }\n\ - .text : {\n\ - PROVIDE (_text = .);\n\ - *(.text)\n\ - *(.pr)\n\ - *(.ro)\n\ - *(.db)\n\ - *(.gl)\n\ - *(.xo)\n\ - *(.ti)\n\ - *(.tb)\n\ - PROVIDE (_etext = .);\n\ - }\n\ - .data 0 : {\n\ - PROVIDE (_data = .);\n\ - *(.data)\n\ - *(.rw)\n\ - *(.sv)\n\ - *(.ua)\n\ - . = ALIGN(4);\n\ - CONSTRUCTORS\n\ - *(.ds)\n\ - *(.tc0)\n\ - *(.tc)\n\ - *(.td)\n\ - PROVIDE (_edata = .);\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(.bs)\n\ - *(.uc)\n\ - *(COMMON)\n\ - PROVIDE (_end = .);\n\ - PROVIDE (end = .);\n\ - }\n\ - .loader 0 : {\n\ - *(.loader)\n\ - }\n\ - .debug 0 : {\n\ - *(.debug)\n\ - }\n\ -}\n\n" - ; else return -"OUTPUT_FORMAT(\"xcoff-powermac\")\n\ -OUTPUT_ARCH(powerpc)\n\ - SEARCH_DIR(/usr/local/powerpc-apple-macos/lib);\n\ -ENTRY(__start)\n\ -SECTIONS\n\ -{\n\ - .pad 0 : { *(.pad) }\n\ - .text : {\n\ - PROVIDE (_text = .);\n\ - *(.text)\n\ - *(.pr)\n\ - *(.ro)\n\ - *(.db)\n\ - *(.gl)\n\ - *(.xo)\n\ - *(.ti)\n\ - *(.tb)\n\ - PROVIDE (_etext = .);\n\ - }\n\ - .data 0 : {\n\ - PROVIDE (_data = .);\n\ - *(.data)\n\ - *(.rw)\n\ - *(.sv)\n\ - *(.ua)\n\ - . = ALIGN(4);\n\ - CONSTRUCTORS\n\ - *(.ds)\n\ - *(.tc0)\n\ - *(.tc)\n\ - *(.td)\n\ - PROVIDE (_edata = .);\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(.bs)\n\ - *(.uc)\n\ - *(COMMON)\n\ - PROVIDE (_end = .);\n\ - PROVIDE (end = .);\n\ - }\n\ - .loader 0 : {\n\ - *(.loader)\n\ - }\n\ - .debug 0 : {\n\ - *(.debug)\n\ - }\n\ -}\n\n" -; } - -struct ld_emulation_xfer_struct ld_ppcmacos_emulation = -{ - gldppcmacos_before_parse, - syslib_default, - hll_default, - after_parse_default, - gldppcmacos_after_open, - after_allocation_default, - set_output_arch_default, - ldemul_default_target, - gldppcmacos_before_allocation, - gldppcmacos_get_script, - "ppcmacos", - "xcoff-powermac", - 0, /* finish */ - 0, /* create_output_section_statements */ - 0, /* open_dynamic_archive */ - 0, /* place_orphan */ - 0, /* set_symbols */ - gldppcmacos_parse_args, - gldppcmacos_unrecognized_file -}; diff --git a/ld/mpw-esh.c b/ld/mpw-esh.c deleted file mode 100644 index 2a0302c530a..00000000000 --- a/ld/mpw-esh.c +++ /dev/null @@ -1,318 +0,0 @@ -/* This file is is generated by a shell script. DO NOT EDIT! */ - -/* emulate the original gld for the given sh - Copyright 1991, 1993, 1995, 2000 Free Software Foundation, Inc. - Written by Steve Chamberlain steve@cygnus.com - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#define TARGET_IS_sh - -#include "libiberty.h" -#include "bfd.h" -#include "sysdep.h" -#include "bfdlink.h" - -#include "ld.h" -#include "ldmain.h" -#include "ldmisc.h" - -#include "ldexp.h" -#include "ldlang.h" -#include "ldfile.h" -#include "ldemul.h" - -static void gldsh_before_parse PARAMS ((void)); -static char *gldsh_get_script PARAMS ((int *isfile)); - -static void -gldsh_before_parse() -{ -#ifndef TARGET_ /* I.e., if not generic. */ - ldfile_output_architecture = bfd_arch_sh; -#endif /* not TARGET_ */ -} - -static char * -gldsh_get_script(isfile) - int *isfile; -{ - *isfile = 0; - - if (link_info.relocateable == true && config.build_constructors == true) - return -concat( -"OUTPUT_FORMAT(\"coff-sh\")\n\ -OUTPUT_ARCH(sh)\n\ -MEMORY\n\ -{\n\ - ram : o = 0x1000, l = 512k\n\ -}\n\ - "," SECTIONS\n\ -{\n\ - "," .text :\n\ - {\n\ - *(.text)\n\ - *(.strings)\n\ - } \n\ - .tors :\n\ - {\n\ - ___ctors = . ;\n\ - *(.ctors)\n\ - ___ctors_end = . ;\n\ - ___dtors = . ;\n\ - *(.dtors)\n\ - ___dtors_end = . ;\n\ - } \n\ - "," .data :\n\ - {\n\ - *(.data)\n\ - } \n\ - "," .bss :\n\ - {\n\ - *(.bss)\n\ - *(COMMON)\n\ - } \n\ - "," .stack :\n\ - {\n\ - *(.stack)\n\ - } \n\ - "," .stab 0 :\n\ - {\n\ - *(.stab)\n\ - }\n\ - "," .stabstr 0 :\n\ - {\n\ - *(.stabstr)\n\ - }\n\ -}\n\n", NULL) - ; else if (link_info.relocateable == true) return -concat ( -"OUTPUT_FORMAT(\"coff-sh\")\n\ -OUTPUT_ARCH(sh)\n\ - "," MEMORY\n\ -{\n\ - ram : o = 0x1000, l = 512k\n\ -}\n\ - "," SECTIONS\n\ -{\n\ - "," .text :\n\ - {\n\ - *(.text)\n\ - *(.strings)\n\ - } \n\ - "," .tors :\n\ - {\n\ - ___ctors = . ;\n\ - *(.ctors)\n\ - ___ctors_end = . ;\n\ - ___dtors = . ;\n\ - *(.dtors)\n\ - ___dtors_end = . ;\n\ - } \n\ - "," .data :\n\ - {\n\ - *(.data)\n\ - } \n\ - "," .bss :\n\ - {\n\ - *(.bss)\n\ - *(COMMON)\n\ - } \n\ - "," .stack :\n\ - {\n\ - *(.stack)\n\ - } \n\ - "," .stab 0 :\n\ - {\n\ - *(.stab)\n\ - }\n\ - "," .stabstr 0 :\n\ - {\n\ - *(.stabstr)\n\ - }\n\ -}\n\n", NULL) - ; else if (!config.text_read_only) return -concat ( -"OUTPUT_FORMAT(\"coff-sh\")\n\ -OUTPUT_ARCH(sh)\n\ -MEMORY\n\ -{\n\ - ram : o = 0x1000, l = 512k\n\ -}\n\ -SECTIONS\n\ -{\n\ - "," .text :\n\ - {\n\ - *(.text)\n\ - *(.strings)\n\ - _etext = . ; \n\ - } > ram\n\ - "," .tors :\n\ - {\n\ - ___ctors = . ;\n\ - *(.ctors)\n\ - ___ctors_end = . ;\n\ - ___dtors = . ;\n\ - *(.dtors)\n\ - ___dtors_end = . ;\n\ - } > ram\n\ - "," .data :\n\ - {\n\ - *(.data)\n\ - _edata = . ; \n\ - } > ram\n\ - "," .bss :\n\ - {\n\ - _bss_start = . ; \n\ - *(.bss)\n\ - *(COMMON)\n\ - _end = . ; \n\ - } > ram\n\ - "," .stack 0x30000 :\n\ - {\n\ - _stack = . ; \n\ - *(.stack)\n\ - } > ram\n\ - "," .stab 0 (NOLOAD) :\n\ - {\n\ - *(.stab)\n\ - }\n\ - "," .stabstr 0 (NOLOAD) :\n\ - {\n\ - *(.stabstr)\n\ - }\n\ -}\n\n", NULL) - ; else if (!config.magic_demand_paged) return -concat ( -"OUTPUT_FORMAT(\"coff-sh\")\n\ -OUTPUT_ARCH(sh)\n\ -MEMORY\n\ -{\n\ - ram : o = 0x1000, l = 512k\n\ -}\n\ -SECTIONS\n\ -{\n\ - "," .text :\n\ - {\n\ - *(.text)\n\ - *(.strings)\n\ - _etext = . ; \n\ - } > ram\n\ - "," .tors :\n\ - {\n\ - ___ctors = . ;\n\ - *(.ctors)\n\ - ___ctors_end = . ;\n\ - ___dtors = . ;\n\ - *(.dtors)\n\ - ___dtors_end = . ;\n\ - } > ram\n\ - "," .data :\n\ - {\n\ - *(.data)\n\ - _edata = . ; \n\ - } > ram\n\ - "," .bss :\n\ - {\n\ - _bss_start = . ; \n\ - *(.bss)\n\ - *(COMMON)\n\ - _end = . ; \n\ - } > ram\n\ - "," .stack 0x30000 :\n\ - {\n\ - _stack = . ; \n\ - *(.stack)\n\ - } > ram\n\ - "," .stab 0 (NOLOAD) :\n\ - {\n\ - *(.stab)\n\ - }\n\ - "," .stabstr 0 (NOLOAD) :\n\ - {\n\ - *(.stabstr)\n\ - }\n\ -}\n\n", NULL) - ; else return -concat ( -"OUTPUT_FORMAT(\"coff-sh\")\n\ -OUTPUT_ARCH(sh)\n\ -MEMORY\n\ -{\n\ - ram : o = 0x1000, l = 512k\n\ -}\n\ -SECTIONS\n\ -{\n\ - "," .text :\n\ - {\n\ - *(.text)\n\ - *(.strings)\n\ - _etext = . ; \n\ - } > ram\n\ - "," .tors :\n\ - {\n\ - ___ctors = . ;\n\ - *(.ctors)\n\ - ___ctors_end = . ;\n\ - ___dtors = . ;\n\ - *(.dtors)\n\ - ___dtors_end = . ;\n\ - } > ram\n\ - "," .data :\n\ - {\n\ - *(.data)\n\ - _edata = . ; \n\ - } > ram\n\ - "," .bss :\n\ - {\n\ - _bss_start = . ; \n\ - *(.bss)\n\ - *(COMMON)\n\ - _end = . ; \n\ - } > ram\n\ - "," .stack 0x30000 :\n\ - {\n\ - _stack = . ; \n\ - *(.stack)\n\ - } > ram\n\ - "," .stab 0 (NOLOAD) :\n\ - {\n\ - *(.stab)\n\ - }\n\ - "," .stabstr 0 (NOLOAD) :\n\ - {\n\ - *(.stabstr)\n\ - }\n\ -}\n\n", NULL) -; } - -struct ld_emulation_xfer_struct ld_sh_emulation = -{ - gldsh_before_parse, - syslib_default, - hll_default, - after_parse_default, - after_open_default, - after_allocation_default, - set_output_arch_default, - ldemul_default_target, - before_allocation_default, - gldsh_get_script, - "sh", - "coff-sh" -}; diff --git a/ld/mpw-idtmips.c b/ld/mpw-idtmips.c deleted file mode 100644 index a602397a84a..00000000000 --- a/ld/mpw-idtmips.c +++ /dev/null @@ -1,433 +0,0 @@ -/* This file is is generated by a shell script. DO NOT EDIT! */ - -/* Handle embedded relocs for MIPS. - Copyright 1994, 1997, 2000 Free Software Foundation, Inc. - Written by Ian Lance Taylor based on generic.em. - -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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#define TARGET_IS_mipsidt - -#include "libiberty.h" -#include "bfd.h" -#include "sysdep.h" -#include "bfdlink.h" - -#include "ld.h" -#include "ldmain.h" -#include "ldmisc.h" - -#include "ldexp.h" -#include "ldlang.h" -#include "ldfile.h" -#include "ldemul.h" - -static void gldmipsidt_before_parse PARAMS ((void)); -static void gldmipsidt_after_open PARAMS ((void)); -static void check_sections PARAMS ((bfd *, asection *, PTR)); -static void gldmipsidt_after_allocation PARAMS ((void)); -static char *gldmipsidt_get_script PARAMS ((int *isfile)); - -static void -gldmipsidt_before_parse() -{ -#ifndef TARGET_ /* I.e., if not generic. */ - ldfile_output_architecture = bfd_arch_mips; -#endif /* not TARGET_ */ -} - -/* This function is run after all the input files have been opened. - We create a .rel.sdata section for each input file with a non zero - .sdata section. The BFD backend will fill in these sections with - magic numbers which can be used to relocate the data section at run - time. This will only do the right thing if all the input files - have been compiled using -membedded-pic. */ - -static void -gldmipsidt_after_open () -{ - bfd *abfd; - - if (! command_line.embedded_relocs - || link_info.relocateable) - return; - - for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next) - { - asection *datasec; - - datasec = bfd_get_section_by_name (abfd, ".sdata"); - - /* Note that we assume that the reloc_count field has already - been set up. We could call bfd_get_reloc_upper_bound, but - that returns the size of a memory buffer rather than a reloc - count. We do not want to call bfd_canonicalize_reloc, - because although it would always work it would force us to - read in the relocs into BFD canonical form, which would waste - a significant amount of time and memory. */ - if (datasec != NULL && datasec->reloc_count > 0) - { - asection *relsec; - - relsec = bfd_make_section (abfd, ".rel.sdata"); - if (relsec == NULL - || ! bfd_set_section_flags (abfd, relsec, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY)) - || ! bfd_set_section_alignment (abfd, relsec, 2) - || ! bfd_set_section_size (abfd, relsec, - datasec->reloc_count * 4)) - einfo (_("%F%B: can not create .rel.sdata section: %E\n")); - } - - /* Double check that all other data sections are empty, as is - required for embedded PIC code. */ - bfd_map_over_sections (abfd, check_sections, (PTR) datasec); - } -} - -/* Check that of the data sections, only the .sdata section has - relocs. This is called via bfd_map_over_sections. */ - -static void -check_sections (abfd, sec, sdatasec) - bfd *abfd; - asection *sec; - PTR sdatasec; -{ - if ((bfd_get_section_flags (abfd, sec) & SEC_CODE) == 0 - && sec != (asection *) sdatasec - && sec->reloc_count != 0) - einfo (_("%F%X: section %s has relocs; can not use --embedded-relocs\n"), - abfd, bfd_get_section_name (abfd, sec)); -} - -/* This function is called after the section sizes and offsets have - been set. If we are generating embedded relocs, it calls a special - BFD backend routine to do the work. */ - -static void -gldmipsidt_after_allocation () -{ - bfd *abfd; - - if (! command_line.embedded_relocs - || link_info.relocateable) - return; - - for (abfd = link_info.input_bfds; abfd != NULL; abfd = abfd->link_next) - { - asection *datasec, *relsec; - char *errmsg; - - datasec = bfd_get_section_by_name (abfd, ".sdata"); - - if (datasec == NULL || datasec->reloc_count == 0) - continue; - - relsec = bfd_get_section_by_name (abfd, ".rel.sdata"); - ASSERT (relsec != NULL); - - if (! bfd_mips_ecoff_create_embedded_relocs (abfd, &link_info, - datasec, relsec, - &errmsg)) - { - if (errmsg == NULL) - einfo (_("%B%X: can not create runtime reloc information: %E\n"), - abfd); - else - einfo (_("%X%B: can not create runtime reloc information: %s\n"), - abfd, errmsg); - } - } -} - -static char * -gldmipsidt_get_script(isfile) - int *isfile; -{ - *isfile = 0; - - if (link_info.relocateable == true && config.build_constructors == true) - return -concat( -"OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\ - \"ecoff-littlemips\")\n\ - SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\ -ENTRY(start)\n\ -SECTIONS\n\ -{\n\ - .text : {\n\ - ;\n\ - *(.init)\n\ - ;\n\ - *(.text)\n\ - *(.rel.sdata)\n\ - *(.fini)\n\ - ;\n\ - ;\n\ - }\n\ - "," .rdata : {\n\ - *(.rdata)\n\ - }\n\ - .data : {\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - .lit8 : {\n\ - *(.lit8)\n\ - }\n\ - .lit4 : {\n\ - *(.lit4)\n\ - }\n\ - "," .sdata : {\n\ - *(.sdata)\n\ - }\n\ - .sbss : {\n\ - *(.sbss)\n\ - *(.scommon)\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ -}\n\n", NULL) - ; else if (link_info.relocateable == true) return -"OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\ - \"ecoff-littlemips\")\n\ - SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\ -ENTRY(start)\n\ -SECTIONS\n\ -{\n\ - .text : {\n\ - ;\n\ - *(.init)\n\ - ;\n\ - *(.text)\n\ - *(.rel.sdata)\n\ - *(.fini)\n\ - ;\n\ - ;\n\ - }\n\ - .rdata : {\n\ - *(.rdata)\n\ - }\n\ - .data : {\n\ - *(.data)\n\ - }\n\ - .lit8 : {\n\ - *(.lit8)\n\ - }\n\ - .lit4 : {\n\ - *(.lit4)\n\ - }\n\ - .sdata : {\n\ - *(.sdata)\n\ - }\n\ - .sbss : {\n\ - *(.sbss)\n\ - *(.scommon)\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ -}\n\n" - ; else if (!config.text_read_only) return -concat( -"OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\ - \"ecoff-littlemips\")\n\ - SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\ -ENTRY(start)\n\ -SECTIONS\n\ -{\n\ - . = 0xa0012000;\n\ - .text : {\n\ - _ftext = . ;\n\ - *(.init)\n\ - eprol = .;\n\ - *(.text)\n\ - PROVIDE (__runtime_reloc_start = .);\n\ - *(.rel.sdata)\n\ - PROVIDE (__runtime_reloc_stop = .);\n\ - *(.fini)\n\ - etext = .;\n\ - _etext = .;\n\ -"," }\n\ - . = .;\n\ - .rdata : {\n\ - *(.rdata)\n\ - }\n\ - _fdata = ALIGN(16);\n\ - .data : {\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - _gp = ALIGN(16) + 0x8000;\n\ - .lit8 : {\n\ - *(.lit8)\n\ - }\n\ - .lit4 : {\n\ - *(.lit4)\n\ - }\n\ - .sdata : {\n\ - *(.sdata)\n\ - }\n\ -"," edata = .;\n\ - _edata = .;\n\ - _fbss = .;\n\ - .sbss : {\n\ - *(.sbss)\n\ - *(.scommon)\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - end = .;\n\ - _end = .;\n\ -}\n\n" -, NULL) - ; else if (!config.magic_demand_paged) return -concat ( -"OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\ - \"ecoff-littlemips\")\n\ - SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\ -ENTRY(start)\n\ -SECTIONS\n\ -{\n\ - . = 0xa0012000;\n\ - .text : {\n\ - _ftext = . ;\n\ - *(.init)\n\ - eprol = .;\n\ - *(.text)\n\ - PROVIDE (__runtime_reloc_start = .);\n\ - *(.rel.sdata)\n\ - PROVIDE (__runtime_reloc_stop = .);\n\ - *(.fini)\n\ - etext = .;\n\ - _etext = .;\n\ - "," }\n\ - . = .;\n\ - .rdata : {\n\ - *(.rdata)\n\ - }\n\ - _fdata = ALIGN(16);\n\ - .data : {\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - _gp = ALIGN(16) + 0x8000;\n\ - .lit8 : {\n\ - *(.lit8)\n\ - "," }\n\ - .lit4 : {\n\ - *(.lit4)\n\ - }\n\ - .sdata : {\n\ - *(.sdata)\n\ - }\n\ - edata = .;\n\ - _edata = .;\n\ - _fbss = .;\n\ - .sbss : {\n\ - *(.sbss)\n\ - *(.scommon)\n\ - "," }\n\ - .bss : {\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - end = .;\n\ - _end = .;\n\ -}\n\n" -, NULL) - ; else return -concat ( -"OUTPUT_FORMAT(\"ecoff-bigmips\", \"ecoff-bigmips\",\n\ - \"ecoff-littlemips\")\n\ - SEARCH_DIR(/usr/local/mips-idt-ecoff/lib);\n\ -ENTRY(start)\n\ -SECTIONS\n\ -{\n\ - . = 0xa0012000;\n\ - .text : {\n\ - _ftext = . ;\n\ - *(.init)\n\ - eprol = .;\n\ - *(.text)\n\ - PROVIDE (__runtime_reloc_start = .);\n\ - *(.rel.sdata)\n\ - PROVIDE (__runtime_reloc_stop = .);\n\ - *(.fini)\n\ - etext = .;\n\ - _etext = .;\n\ - "," }\n\ - . = .;\n\ - .rdata : {\n\ - *(.rdata)\n\ - }\n\ - _fdata = ALIGN(16);\n\ - .data : {\n\ - *(.data)\n\ - CONSTRUCTORS\n\ - }\n\ - _gp = ALIGN(16) + 0x8000;\n\ - .lit8 : {\n\ - *(.lit8)\n\ - }\n\ - .lit4 : {\n\ - *(.lit4)\n\ - "," }\n\ - .sdata : {\n\ - *(.sdata)\n\ - }\n\ - edata = .;\n\ - _edata = .;\n\ - _fbss = .;\n\ - .sbss : {\n\ - *(.sbss)\n\ - *(.scommon)\n\ - }\n\ - .bss : {\n\ - *(.bss)\n\ - *(COMMON)\n\ - }\n\ - end = .;\n\ - _end = .;\n\ -}\n\n" -, NULL) -; } - -struct ld_emulation_xfer_struct ld_mipsidt_emulation = -{ - gldmipsidt_before_parse, - syslib_default, - hll_default, - after_parse_default, - gldmipsidt_after_open, - gldmipsidt_after_allocation, - set_output_arch_default, - ldemul_default_target, - before_allocation_default, - gldmipsidt_get_script, - "mipsidt", - "ecoff-bigmips" -}; diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 17eb4eec958..c29dd31fa2a 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,16 @@ +2002-05-09 Anton Blanchard + + * ppc-opc.c: Add "tlbiel" for POWER4. + +2002-05-09 Alan Modra + + Merge from mainline. + 2002-05-01 Alan Modra + * ppc-opc.c: Add "tlbsx." and "tlbsxe." for booke. + + 2002-04-17 matthew green + * ppc-opc.c (powerpc_opcode): Fix dssall operand list. + 2002-04-29 Chris Demetriou Merge from mainline: diff --git a/opcodes/ppc-opc.c b/opcodes/ppc-opc.c index c868ccc1d98..70167f7e9cb 100644 --- a/opcodes/ppc-opc.c +++ b/opcodes/ppc-opc.c @@ -3065,6 +3065,8 @@ const struct powerpc_opcode powerpc_opcodes[] = { { "addo.", XO(31,266,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "caxo.", XO(31,266,1,1), XO_MASK, PWRCOM, { RT, RA, RB } }, +{ "tlbiel", X(31,274), XRTRA_MASK, POWER4, { RB } }, + { "mfapidi", X(31,275), X_MASK, BOOKE, { RT, RA } }, { "lscbx", XRC(31,277,0), X_MASK, M601, { RT, RA, RB } }, @@ -3672,7 +3674,7 @@ const struct powerpc_opcode powerpc_opcodes[] = { { "rac", X(31,818), X_MASK, PWRCOM, { RT, RA, RB } }, { "dss", XDSS(31,822,0), XDSS_MASK, PPCVEC, { STRM } }, -{ "dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, { STRM } }, +{ "dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, { 0 } }, { "srawi", XRC(31,824,0), X_MASK, PPCCOM, { RA, RS, SH } }, { "srai", XRC(31,824,0), X_MASK, PWRCOM, { RA, RS, SH } }, @@ -3688,7 +3690,9 @@ const struct powerpc_opcode powerpc_opcodes[] = { { "tlbsx.", XRC(31,914,1), X_MASK, PPC403, { RT, RA, RB } }, { "tlbsx", XRC(31,914,0), X_MASK, BOOKE, { RA, RB } }, +{ "tlbsx.", XRC(31,914,1), X_MASK, BOOKE, { RA, RB } }, { "tlbsxe", XRC(31,915,0), X_MASK, BOOKE, { RA, RB } }, +{ "tlbsxe.", XRC(31,915,1), X_MASK, BOOKE, { RA, RB } }, { "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } },