2004-07-06 16:58:43 +00:00
|
|
|
/* Renesas / SuperH specific support for Symbian 32-bit ELF files
|
2016-01-01 11:25:12 +00:00
|
|
|
Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
2004-07-06 16:58:43 +00:00
|
|
|
Contributed by Red Hat
|
|
|
|
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
|
|
|
|
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
|
2007-07-03 14:26:43 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2004-07-06 16:58:43 +00:00
|
|
|
(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
|
2007-07-03 14:26:43 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA. */
|
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
/* Stop elf32-sh.c from defining any target vectors. */
|
|
|
|
#define SH_TARGET_ALREADY_DEFINED
|
2004-07-09 12:32:35 +00:00
|
|
|
#define sh_find_elf_flags sh_symbian_find_elf_flags
|
2013-01-10 20:03:55 +00:00
|
|
|
#define sh_elf_get_flags_from_mach sh_symbian_elf_get_flags_from_mach
|
2004-07-06 16:58:43 +00:00
|
|
|
#include "elf32-sh.c"
|
|
|
|
|
|
|
|
|
2006-05-02 09:56:00 +00:00
|
|
|
//#define SYMBIAN_DEBUG 1
|
|
|
|
#define SYMBIAN_DEBUG 0
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
#define DIRECTIVE_HEADER "#<SYMEDIT>#\n"
|
|
|
|
#define DIRECTIVE_IMPORT "IMPORT "
|
|
|
|
#define DIRECTIVE_EXPORT "EXPORT "
|
|
|
|
#define DIRECTIVE_AS "AS "
|
|
|
|
|
|
|
|
/* Macro to advance 's' until either it reaches 'e' or the
|
|
|
|
character pointed to by 's' is equal to 'c'. If 'e' is
|
2006-05-02 09:56:00 +00:00
|
|
|
reached and SYMBIAN_DEBUG is enabled then the error message 'm'
|
2004-07-06 16:58:43 +00:00
|
|
|
is displayed. */
|
|
|
|
#define SKIP_UNTIL(s,e,c,m) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
while (s < e && *s != c) \
|
|
|
|
++ s; \
|
|
|
|
if (s >= e) \
|
|
|
|
{ \
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG) \
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "Corrupt directive: %s\n", m); \
|
|
|
|
result = FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0); \
|
|
|
|
if (!result) \
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Like SKIP_UNTIL except there are two terminator characters
|
|
|
|
c1 and c2. */
|
|
|
|
#define SKIP_UNTIL2(s,e,c1,c2,m) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
while (s < e && *s != c1 && *s != c2) \
|
|
|
|
++ s; \
|
|
|
|
if (s >= e) \
|
|
|
|
{ \
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG) \
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "Corrupt directive: %s\n", m); \
|
|
|
|
result = FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0); \
|
|
|
|
if (!result) \
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Macro to advance 's' until either it reaches 'e' or the
|
|
|
|
character pointed to by 's' is not equal to 'c'. If 'e'
|
2006-05-02 09:56:00 +00:00
|
|
|
is reached and SYMBIAN_DEBUG is enabled then the error message
|
2004-07-06 16:58:43 +00:00
|
|
|
'm' is displayed. */
|
|
|
|
#define SKIP_WHILE(s,e,c,m) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
while (s < e && *s == c) \
|
|
|
|
++ s; \
|
|
|
|
if (s >= e) \
|
|
|
|
{ \
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG) \
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "Corrupt directive: %s\n", m); \
|
|
|
|
result = FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0); \
|
|
|
|
if (!result) \
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct symbol_rename
|
|
|
|
{
|
|
|
|
struct symbol_rename * next;
|
2005-02-20 14:59:07 +00:00
|
|
|
char * current_name;
|
|
|
|
char * new_name;
|
2004-07-06 16:58:43 +00:00
|
|
|
struct elf_link_hash_entry * current_hash;
|
|
|
|
unsigned long new_symndx;
|
|
|
|
}
|
|
|
|
symbol_rename;
|
|
|
|
|
|
|
|
static symbol_rename * rename_list = NULL;
|
|
|
|
|
|
|
|
/* Accumulate a list of symbols to be renamed. */
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
sh_symbian_import_as (struct bfd_link_info *info, bfd * abfd,
|
2005-02-20 14:59:07 +00:00
|
|
|
char * current_name, char * new_name)
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
|
|
|
struct elf_link_hash_entry * new_hash;
|
|
|
|
symbol_rename * node;
|
|
|
|
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT '%s' AS '%s'\n", current_name, new_name);
|
|
|
|
|
|
|
|
for (node = rename_list; node; node = node->next)
|
|
|
|
if (strcmp (node->current_name, current_name) == 0)
|
|
|
|
{
|
|
|
|
if (strcmp (node->new_name, new_name) == 0)
|
|
|
|
/* Already added to rename list. */
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 03:16:01 +00:00
|
|
|
_bfd_error_handler (_("%B: IMPORT AS directive for %s conceals previous IMPORT AS"),
|
|
|
|
abfd, current_name);
|
2013-01-10 20:03:55 +00:00
|
|
|
return FALSE;
|
2004-07-06 16:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((node = bfd_malloc (sizeof * node)) == NULL)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT AS: No mem for new rename node\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((node->current_name = bfd_malloc (strlen (current_name) + 1)) == NULL)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT AS: No mem for current name field in rename node\n");
|
|
|
|
free (node);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy (node->current_name, current_name);
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
if ((node->new_name = bfd_malloc (strlen (new_name) + 1)) == NULL)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT AS: No mem for new name field in rename node\n");
|
|
|
|
free (node->current_name);
|
|
|
|
free (node);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy (node->new_name, new_name);
|
|
|
|
|
|
|
|
node->next = rename_list;
|
|
|
|
node->current_hash = NULL;
|
|
|
|
node->new_symndx = 0;
|
|
|
|
rename_list = node;
|
|
|
|
|
|
|
|
new_hash = elf_link_hash_lookup (elf_hash_table (info), node->new_name, TRUE, FALSE, TRUE);
|
|
|
|
bfd_elf_link_record_dynamic_symbol (info, new_hash);
|
|
|
|
if (new_hash->root.type == bfd_link_hash_new)
|
|
|
|
new_hash->root.type = bfd_link_hash_undefined;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
2005-02-20 14:59:07 +00:00
|
|
|
sh_symbian_import (bfd * abfd ATTRIBUTE_UNUSED, char * name)
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT '%s'\n", name);
|
|
|
|
|
|
|
|
/* XXX: Generate an import somehow ? */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bfd_boolean
|
2005-02-20 14:59:07 +00:00
|
|
|
sh_symbian_export (bfd * abfd ATTRIBUTE_UNUSED, char * name)
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "EXPORT '%s'\n", name);
|
|
|
|
|
|
|
|
/* XXX: Generate an export somehow ? */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process any magic embedded commands in the .directive. section.
|
|
|
|
Returns TRUE upon sucecss, but if it fails it sets bfd_error and
|
|
|
|
returns FALSE. */
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
sh_symbian_process_embedded_commands (struct bfd_link_info *info, bfd * abfd,
|
|
|
|
asection * sec, bfd_byte * contents)
|
|
|
|
{
|
2005-02-20 14:59:07 +00:00
|
|
|
char *s;
|
|
|
|
char *e;
|
2004-07-06 16:58:43 +00:00
|
|
|
bfd_boolean result = TRUE;
|
|
|
|
bfd_size_type sz = sec->rawsize ? sec->rawsize : sec->size;
|
|
|
|
|
2005-02-20 14:59:07 +00:00
|
|
|
for (s = (char *) contents, e = s + sz; s < e;)
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
2005-02-20 14:59:07 +00:00
|
|
|
char * directive = s;
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
switch (*s)
|
|
|
|
{
|
|
|
|
/* I want to use "case DIRECTIVE_HEADER [0]:" here but gcc won't let me :-( */
|
|
|
|
case '#':
|
|
|
|
if (strcmp (s, DIRECTIVE_HEADER))
|
|
|
|
result = FALSE;
|
|
|
|
else
|
|
|
|
/* Just ignore the header.
|
|
|
|
XXX: Strictly speaking we ought to check that the header
|
|
|
|
is present and that it is the first thing in the file. */
|
|
|
|
s += strlen (DIRECTIVE_HEADER) + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'I':
|
2006-09-16 18:12:17 +00:00
|
|
|
if (! CONST_STRNEQ (s, DIRECTIVE_IMPORT))
|
2004-07-06 16:58:43 +00:00
|
|
|
result = FALSE;
|
|
|
|
else
|
|
|
|
{
|
2005-02-20 14:59:07 +00:00
|
|
|
char * new_name;
|
|
|
|
char * new_name_end;
|
|
|
|
char name_end_char;
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
/* Skip the IMPORT directive. */
|
|
|
|
s += strlen (DIRECTIVE_IMPORT);
|
|
|
|
|
|
|
|
new_name = s;
|
|
|
|
/* Find the end of the new name. */
|
|
|
|
while (s < e && *s != ' ' && *s != '\n')
|
|
|
|
++ s;
|
|
|
|
if (s >= e)
|
|
|
|
{
|
|
|
|
/* We have reached the end of the .directive section
|
|
|
|
without encountering a string terminator. This is
|
|
|
|
allowed for IMPORT directives. */
|
|
|
|
new_name_end = e - 1;
|
|
|
|
name_end_char = * new_name_end;
|
|
|
|
* new_name_end = 0;
|
|
|
|
result = sh_symbian_import (abfd, new_name);
|
|
|
|
* new_name_end = name_end_char;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remember where the name ends. */
|
|
|
|
new_name_end = s;
|
|
|
|
/* Skip any whitespace before the 'AS'. */
|
|
|
|
SKIP_WHILE (s, e, ' ', "IMPORT: Name just followed by spaces");
|
|
|
|
/* Terminate the new name. (Do this after skiping...) */
|
|
|
|
name_end_char = * new_name_end;
|
|
|
|
* new_name_end = 0;
|
|
|
|
|
2006-09-16 18:12:17 +00:00
|
|
|
/* Check to see if 'AS '... is present. If so we have an
|
|
|
|
IMPORT AS directive, otherwise we have an IMPORT directive. */
|
|
|
|
if (! CONST_STRNEQ (s, DIRECTIVE_AS))
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
|
|
|
/* Skip the new-line at the end of the name. */
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG && name_end_char != '\n')
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT: No newline at end of directive\n");
|
|
|
|
else
|
|
|
|
s ++;
|
|
|
|
|
|
|
|
result = sh_symbian_import (abfd, new_name);
|
|
|
|
|
|
|
|
/* Skip past the NUL character. */
|
|
|
|
if (* s ++ != 0)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT: No NUL at end of directive\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-02-20 14:59:07 +00:00
|
|
|
char * current_name;
|
|
|
|
char * current_name_end;
|
|
|
|
char current_name_end_char;
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
/* Skip the 'AS '. */
|
|
|
|
s += strlen (DIRECTIVE_AS);
|
|
|
|
/* Skip any white space after the 'AS '. */
|
|
|
|
SKIP_WHILE (s, e, ' ', "IMPORT AS: Nothing after AS");
|
|
|
|
current_name = s;
|
|
|
|
/* Find the end of the current name. */
|
|
|
|
SKIP_UNTIL2 (s, e, ' ', '\n', "IMPORT AS: No newline at the end of the current name");
|
|
|
|
/* Skip (backwards) over spaces at the end of the current name. */
|
|
|
|
current_name_end = s;
|
|
|
|
current_name_end_char = * current_name_end;
|
|
|
|
|
|
|
|
SKIP_WHILE (s, e, ' ', "IMPORT AS: Current name just followed by spaces");
|
|
|
|
/* Skip past the newline character. */
|
|
|
|
if (* s ++ != '\n')
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT AS: No newline at end of directive\n");
|
|
|
|
|
|
|
|
/* Terminate the current name after having performed the skips. */
|
|
|
|
* current_name_end = 0;
|
|
|
|
|
|
|
|
result = sh_symbian_import_as (info, abfd, current_name, new_name);
|
|
|
|
|
|
|
|
/* The next character should be a NUL. */
|
|
|
|
if (* s != 0)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT AS: Junk at end of directive\n");
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
s ++;
|
|
|
|
|
|
|
|
* current_name_end = current_name_end_char;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore the characters we overwrote, since
|
|
|
|
the .directive section will be emitted. */
|
|
|
|
* new_name_end = name_end_char;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'E':
|
2006-09-16 18:12:17 +00:00
|
|
|
if (! CONST_STRNEQ (s, DIRECTIVE_EXPORT))
|
2004-07-06 16:58:43 +00:00
|
|
|
result = FALSE;
|
|
|
|
else
|
|
|
|
{
|
2005-02-20 14:59:07 +00:00
|
|
|
char * name;
|
|
|
|
char * name_end;
|
|
|
|
char name_end_char;
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
/* Skip the directive. */
|
|
|
|
s += strlen (DIRECTIVE_EXPORT);
|
|
|
|
name = s;
|
|
|
|
/* Find the end of the name to be exported. */
|
|
|
|
SKIP_UNTIL (s, e, '\n', "EXPORT: no newline at end of directive");
|
|
|
|
/* Skip (backwards) over spaces at end of exported name. */
|
|
|
|
for (name_end = s; name_end[-1] == ' '; name_end --)
|
|
|
|
;
|
|
|
|
/* name_end now points at the first character after the
|
|
|
|
end of the exported name, so we can termiante it */
|
|
|
|
name_end_char = * name_end;
|
|
|
|
* name_end = 0;
|
|
|
|
/* Skip passed the newline character. */
|
|
|
|
s ++;
|
|
|
|
|
|
|
|
result = sh_symbian_export (abfd, name);
|
|
|
|
|
|
|
|
/* The next character should be a NUL. */
|
|
|
|
if (* s != 0)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "EXPORT: Junk at end of directive\n");
|
|
|
|
result = FALSE;
|
|
|
|
}
|
|
|
|
s++;
|
|
|
|
|
|
|
|
/* Restore the character we deleted. */
|
|
|
|
* name_end = name_end_char;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
result = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! result)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2005-02-24 13:34:38 +00:00
|
|
|
fprintf (stderr, "offset into .directive section: %ld\n",
|
|
|
|
(long) (directive - (char *) contents));
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
bfd_set_error (bfd_error_invalid_operation);
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 03:16:01 +00:00
|
|
|
_bfd_error_handler (_("%B: Unrecognised .directive command: %s"),
|
|
|
|
abfd, directive);
|
2004-07-06 16:58:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Scan a bfd for a .directive section, and if found process it.
|
|
|
|
Returns TRUE upon success, FALSE otherwise. */
|
|
|
|
|
2008-10-20 11:05:47 +00:00
|
|
|
static bfd_boolean
|
|
|
|
sh_symbian_process_directives (bfd *abfd, struct bfd_link_info *info)
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
|
|
|
bfd_boolean result = FALSE;
|
|
|
|
bfd_byte * contents;
|
|
|
|
asection * sec = bfd_get_section_by_name (abfd, ".directive");
|
|
|
|
bfd_size_type sz;
|
|
|
|
|
|
|
|
if (!sec)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
sz = sec->rawsize ? sec->rawsize : sec->size;
|
|
|
|
contents = bfd_malloc (sz);
|
|
|
|
|
|
|
|
if (!contents)
|
|
|
|
bfd_set_error (bfd_error_no_memory);
|
2013-01-10 20:03:55 +00:00
|
|
|
else
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
|
|
|
if (bfd_get_section_contents (abfd, sec, contents, 0, sz))
|
|
|
|
result = sh_symbian_process_embedded_commands (info, abfd, sec, contents);
|
|
|
|
free (contents);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Intercept the normal sh_relocate_section() function
|
|
|
|
and magle the relocs to allow for symbol renaming. */
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
sh_symbian_relocate_section (bfd * output_bfd,
|
|
|
|
struct bfd_link_info * info,
|
|
|
|
bfd * input_bfd,
|
|
|
|
asection * input_section,
|
|
|
|
bfd_byte * contents,
|
|
|
|
Elf_Internal_Rela * relocs,
|
|
|
|
Elf_Internal_Sym * local_syms,
|
|
|
|
asection ** local_sections)
|
|
|
|
{
|
|
|
|
/* When performing a final link we implement the IMPORT AS directives. */
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 12:51:03 +00:00
|
|
|
if (!bfd_link_relocatable (info))
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
|
|
|
Elf_Internal_Rela * rel;
|
|
|
|
Elf_Internal_Rela * relend;
|
|
|
|
Elf_Internal_Shdr * symtab_hdr;
|
|
|
|
struct elf_link_hash_entry ** sym_hashes;
|
|
|
|
struct elf_link_hash_entry ** sym_hashes_end;
|
|
|
|
struct elf_link_hash_table * hash_table;
|
|
|
|
symbol_rename * ptr;
|
|
|
|
bfd_size_type num_global_syms;
|
|
|
|
unsigned long num_local_syms;
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
BFD_ASSERT (! elf_bad_symtab (input_bfd));
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
|
|
|
|
hash_table = elf_hash_table (info);
|
|
|
|
num_local_syms = symtab_hdr->sh_info;
|
|
|
|
num_global_syms = symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
|
|
|
|
num_global_syms -= num_local_syms;
|
|
|
|
sym_hashes = elf_sym_hashes (input_bfd);
|
|
|
|
sym_hashes_end = sym_hashes + num_global_syms;
|
|
|
|
|
|
|
|
/* First scan the rename table, caching the hash entry and the new index. */
|
|
|
|
for (ptr = rename_list; ptr; ptr = ptr->next)
|
|
|
|
{
|
|
|
|
struct elf_link_hash_entry * new_hash;
|
|
|
|
struct elf_link_hash_entry ** h;
|
|
|
|
|
|
|
|
ptr->current_hash = elf_link_hash_lookup (hash_table, ptr->current_name, FALSE, FALSE, TRUE);
|
|
|
|
|
|
|
|
if (ptr->current_hash == NULL)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "IMPORT AS: current symbol '%s' does not exist\n", ptr->current_name);
|
|
|
|
continue;
|
|
|
|
}
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2013-03-23 10:25:02 +00:00
|
|
|
new_hash = elf_link_hash_lookup (hash_table, ptr->new_name,
|
|
|
|
FALSE, FALSE, TRUE);
|
2004-07-06 16:58:43 +00:00
|
|
|
/* If we could not find the symbol then it is a new, undefined symbol.
|
|
|
|
Symbian want this behaviour - ie they want to be able to rename the
|
|
|
|
reference in a reloc from one undefined symbol to another, new and
|
|
|
|
undefined symbol. So we create that symbol here. */
|
|
|
|
if (new_hash == NULL)
|
|
|
|
{
|
2013-03-23 10:25:02 +00:00
|
|
|
struct bfd_link_hash_entry *bh = NULL;
|
|
|
|
bfd_boolean collect = get_elf_backend_data (input_bfd)->collect;
|
|
|
|
if (_bfd_generic_link_add_one_symbol (info, input_bfd,
|
|
|
|
ptr->new_name, BSF_GLOBAL,
|
|
|
|
bfd_und_section_ptr, 0,
|
|
|
|
NULL, FALSE, collect,
|
|
|
|
&bh))
|
2004-07-06 16:58:43 +00:00
|
|
|
{
|
2013-03-23 10:25:02 +00:00
|
|
|
new_hash = (struct elf_link_hash_entry *) bh;
|
|
|
|
new_hash->type = STT_FUNC;
|
|
|
|
new_hash->non_elf = 0;
|
2004-07-06 16:58:43 +00:00
|
|
|
|
2013-03-23 10:25:02 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
|
|
|
fprintf (stderr, "Created new symbol %s\n", ptr->new_name);
|
|
|
|
}
|
|
|
|
}
|
2004-07-06 16:58:43 +00:00
|
|
|
|
2013-03-23 10:25:02 +00:00
|
|
|
if (new_hash == NULL)
|
|
|
|
{
|
|
|
|
_bfd_error_handler (_("%B: Failed to add renamed symbol %s"),
|
|
|
|
input_bfd, ptr->new_name);
|
|
|
|
continue;
|
2004-07-06 16:58:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert the new_hash value into a index into the table of symbol hashes. */
|
|
|
|
for (h = sym_hashes; h < sym_hashes_end; h ++)
|
|
|
|
{
|
|
|
|
if (* h == new_hash)
|
|
|
|
{
|
|
|
|
ptr->new_symndx = h - sym_hashes + num_local_syms;
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "Converted new hash to index of %ld\n", ptr->new_symndx);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If the new symbol is not in the hash table then it must be
|
|
|
|
because it is one of the newly created undefined symbols
|
|
|
|
manufactured above. So we extend the sym has table here to
|
|
|
|
include this extra symbol. */
|
|
|
|
if (h == sym_hashes_end)
|
|
|
|
{
|
|
|
|
struct elf_link_hash_entry ** new_sym_hashes;
|
|
|
|
|
|
|
|
/* This is not very efficient, but it works. */
|
|
|
|
++ num_global_syms;
|
|
|
|
new_sym_hashes = bfd_alloc (input_bfd, num_global_syms * sizeof * sym_hashes);
|
|
|
|
if (new_sym_hashes == NULL)
|
|
|
|
{
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "Out of memory extending hash table\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
memcpy (new_sym_hashes, sym_hashes, (num_global_syms - 1) * sizeof * sym_hashes);
|
|
|
|
new_sym_hashes[num_global_syms - 1] = new_hash;
|
|
|
|
elf_sym_hashes (input_bfd) = sym_hashes = new_sym_hashes;
|
|
|
|
sym_hashes_end = sym_hashes + num_global_syms;
|
|
|
|
symtab_hdr->sh_size = (num_global_syms + num_local_syms) * sizeof (Elf32_External_Sym);
|
|
|
|
|
|
|
|
ptr->new_symndx = num_global_syms - 1 + num_local_syms;
|
|
|
|
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "Extended symbol hash table to insert new symbol as index %ld\n",
|
|
|
|
ptr->new_symndx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Walk the reloc list looking for references to renamed symbols.
|
|
|
|
When we find one, we alter the index in the reloc to point to the new symbol. */
|
|
|
|
for (rel = relocs, relend = relocs + input_section->reloc_count;
|
|
|
|
rel < relend;
|
|
|
|
rel ++)
|
|
|
|
{
|
|
|
|
int r_type;
|
|
|
|
unsigned long r_symndx;
|
|
|
|
struct elf_link_hash_entry * h;
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
|
|
|
r_type = ELF32_R_TYPE (rel->r_info);
|
|
|
|
|
|
|
|
/* Ignore unused relocs. */
|
|
|
|
if ((r_type >= (int) R_SH_GNU_VTINHERIT
|
|
|
|
&& r_type <= (int) R_SH_LABEL)
|
|
|
|
|| r_type == (int) R_SH_NONE
|
|
|
|
|| r_type < 0
|
|
|
|
|| r_type >= R_SH_max)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Ignore relocs against local symbols. */
|
|
|
|
if (r_symndx < num_local_syms)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
BFD_ASSERT (r_symndx < (num_global_syms + num_local_syms));
|
|
|
|
h = sym_hashes[r_symndx - num_local_syms];
|
|
|
|
BFD_ASSERT (h != NULL);
|
|
|
|
|
|
|
|
while ( h->root.type == bfd_link_hash_indirect
|
|
|
|
|| h->root.type == bfd_link_hash_warning)
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
|
|
|
/* If the symbol is defined there is no need to rename it.
|
|
|
|
XXX - is this true ? */
|
|
|
|
if ( h->root.type == bfd_link_hash_defined
|
|
|
|
|| h->root.type == bfd_link_hash_defweak
|
|
|
|
|| h->root.type == bfd_link_hash_undefweak)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (ptr = rename_list; ptr; ptr = ptr->next)
|
|
|
|
if (h == ptr->current_hash)
|
|
|
|
{
|
|
|
|
BFD_ASSERT (ptr->new_symndx);
|
2006-05-02 09:56:00 +00:00
|
|
|
if (SYMBIAN_DEBUG)
|
2004-07-06 16:58:43 +00:00
|
|
|
fprintf (stderr, "convert reloc %lx from using index %ld to using index %ld\n",
|
2008-07-30 04:34:58 +00:00
|
|
|
(unsigned long) rel->r_info,
|
|
|
|
(long) ELF32_R_SYM (rel->r_info), ptr->new_symndx);
|
2004-07-06 16:58:43 +00:00
|
|
|
rel->r_info = ELF32_R_INFO (ptr->new_symndx, r_type);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-10 20:03:55 +00:00
|
|
|
|
2004-07-06 16:58:43 +00:00
|
|
|
return sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|
|
|
|
contents, relocs, local_syms, local_sections);
|
|
|
|
}
|
|
|
|
|
bfd target vector rationalisation
This renames the bfd targets to <cpu>_<format>_<other>_<endian>_vec.
So for example, bfd_elf32_ntradlittlemips_vec becomes
mips_elf32_ntrad_le_vec and hp300bsd_vec becomes m68k_aout_hp300bsd_vec.
bfd/
* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-ns32k.c,
* aout-sparcle.c, * aout0.c, * aoutx.h, * armnetbsd.c, * bout.c,
* cf-i386lynx.c, * cf-sparclynx.c, * cisco-core.c, * coff-alpha.c,
* coff-apollo.c, * coff-arm.c, * coff-aux.c, * coff-go32.c,
* coff-h8300.c, * coff-h8500.c, * coff-i386.c, * coff-i860.c,
* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mips.c,
* coff-rs6000.c, * coff-sh.c, * coff-sparc.c, * coff-stgo32.c,
* coff-svm68k.c, * coff-tic80.c, * coff-u68k.c, * coff-w65.c,
* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
* coff64-rs6000.c, * config.bfd, * configure.com, * configure.in,
* demo64.c, * elf-m10200.c, * elf-m10300.c, * elf32-am33lin.c,
* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c,
* elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c,
* elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c,
* elf32-fr30.c, * elf32-frv.c, * elf32-gen.c, * elf32-h8300.c,
* elf32-hppa.c, * elf32-i370.c, * elf32-i386.c, * elf32-i860.c,
* elf32-i960.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c,
* elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c,
* elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c, * elf32-mep.c,
* elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c,
* elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nios2.c,
* elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-rl78.c,
* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-sh-symbian.c,
* elf32-sh.c, * elf32-sh64.c, * elf32-sparc.c, * elf32-spu.c,
* elf32-tic6x.c, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-v850.c,
* elf32-vax.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c,
* elf32-xtensa.c, * elf64-alpha.c, * elf64-gen.c, * elf64-hppa.c,
* elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-ppc.c,
* elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c, * elf64-tilegx.c,
* elf64-x86-64.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
* epoc-pe-arm.c, * epoc-pei-arm.c, * hp300bsd.c, * hp300hpux.c,
* hppabsd-core.c, * hpux-core.c, * i386aout.c, * i386bsd.c,
* i386dynix.c, * i386freebsd.c, * i386linux.c, * i386lynx.c,
* i386mach3.c, * i386msdos.c, * i386netbsd.c, * i386os9k.c,
* irix-core.c, * m68k4knetbsd.c, * m68klinux.c, * m68knetbsd.c,
* m88kmach3.c, * m88kopenbsd.c, * mach-o-i386.c, * mach-o-x86-64.c,
* makefile.vms, * mipsbsd.c, * mmo.c, * netbsd-core.c, * newsos3.c,
* nlm32-alpha.c, * nlm32-i386.c, * nlm32-ppc.c, * nlm32-sparc.c,
* ns32knetbsd.c, * osf-core.c, * pc532-mach.c, * pe-arm-wince.c,
* pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-mips.c, * pe-ppc.c,
* pe-sh.c, * pe-x86_64.c, * pei-arm-wince.c, * pei-arm.c,
* pei-i386.c, * pei-ia64.c, * pei-mcore.c, * pei-mips.c, * pei-ppc.c,
* pei-sh.c, * pei-x86_64.c, * ppcboot.c, * ptrace-core.c, * riscix.c,
* sco5-core.c, * som.c, * sparclinux.c, * sparclynx.c,
* sparcnetbsd.c, * sunos.c, * targets.c, * trad-core.c,
* vax1knetbsd.c, * vaxbsd.c, * vaxnetbsd.c, * versados.c,
* vms-alpha.c, * vms-lib.c: Rename bfd targets to
<cpu>_<format>_<other>_<endian>_vec. Adjust associated MY macros
on aout targets.
* configure: Regenerate.
binutils/
* emul_aix.c: Update bfd target vector naming.
* testsuite/binutils-all/objcopy.exp: Likewise.
ld/
* emultempl/metagelf.em: Update bfd target vector naming.
* emultempl/nios2elf.em: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/tic6xdsbt.em: Likewise.
2014-05-02 10:39:40 +00:00
|
|
|
#define TARGET_LITTLE_SYM sh_elf32_symbian_le_vec
|
2004-07-06 16:58:43 +00:00
|
|
|
#define TARGET_LITTLE_NAME "elf32-shl-symbian"
|
|
|
|
|
|
|
|
#undef elf_backend_relocate_section
|
|
|
|
#define elf_backend_relocate_section sh_symbian_relocate_section
|
|
|
|
#undef elf_backend_check_directives
|
2008-10-20 11:05:47 +00:00
|
|
|
#define elf_backend_check_directives sh_symbian_process_directives
|
2004-07-06 16:58:43 +00:00
|
|
|
|
|
|
|
#include "elf32-target.h"
|