summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2004-07-06 16:58:42 +0000
committerNick Clifton <nickc@redhat.com>2004-07-06 16:58:42 +0000
commitfd9e9504134d2abf9e843e69098460e782e0662e (patch)
treea1b9b6807e51ddf84bff45a11ef7b8ce6c12a648 /bfd
parent1ff74c5a32569e53bfc26960f84a9875fbb29bd8 (diff)
downloadgdb-fd9e9504134d2abf9e843e69098460e782e0662e.tar.gz
Add support for sh-symbian-elf target
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog24
-rw-r--r--bfd/Makefile.am7
-rw-r--r--bfd/Makefile.in11
-rw-r--r--bfd/config.bfd5
-rwxr-xr-xbfd/configure43
-rw-r--r--bfd/configure.in1
-rw-r--r--bfd/elf-bfd.h7
-rw-r--r--bfd/elf32-sh-symbian.c625
-rw-r--r--bfd/elf32-sh.c27
-rw-r--r--bfd/elf32-sh64.c1
-rw-r--r--bfd/elflink.c6
-rw-r--r--bfd/elfxx-target.h4
-rw-r--r--bfd/targets.c2
13 files changed, 738 insertions, 25 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ad7b8a4119e..15f9fb64224 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,27 @@
+2004-07-06 Nick Clifton <nickc@redhat.com>
+
+ * config.bfd: Add sh-symbian-elf target.
+ * configure.in: Add bfd_elf32_shl_symbian_vec.
+ * configure: Regenerate.
+ * elf-bfd.h (struct elf_backend_data): Add new field
+ 'check_directives'.
+ * elflink.c (elf_link_add_object_symbols): Invoke the
+ check_directives function, if defined.
+ * elfxx-target.h: Provide a default, NULL definition for
+ check_directives.
+ * targets.c: Add bfd_elf32_shl_symbian_vec.
+ * elf32-sh.c (sh_elf_swap_insns): Protect against unnecessary
+ definition.
+ (elf32_shlin_grok_prstatus, elf32_shlib_grok_psinfo,
+ * sh_elf_get_flags_from_mach, sh_elf_find_flags): Likewise.
+ (TARGET_BIG_SYM, TARGET_LITTLE_SYM): Only define if they have
+ not already been defined.
+ * elf32-sh64.c: Use SH_TARGET_ALREADY_DEFINED.
+ * sh-symbian.c: New file. Provide functions to support the
+ * sh-symbian-elf target.
+ * Makefile.am: Add elf32-sh-symbian.c
+ * Makefile.in: Regenerate.
+
2004-07-05 Andrew Stubbs <andrew.stubbs@superh.com>
* elf32-sh.c: Include ../opcodes/sh-opc.h .
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index c7ef7d7af94..07726242ee2 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -253,6 +253,7 @@ BFD32_BACKENDS = \
elf32-ppc.lo \
elf32-s390.lo \
elf32-sh.lo \
+ elf32-sh-symbian.lo \
elf32-sh64.lo \
elf32-sh64-com.lo \
elf32-sparc.lo \
@@ -421,6 +422,7 @@ BFD32_BACKENDS_CFILES = \
elf32-sh64-com.c \
elf32-s390.c \
elf32-sh.c \
+ elf32-sh-symbian.c \
elf32-sparc.c \
elf32-v850.c \
elf32-vax.c \
@@ -1310,6 +1312,11 @@ elf32-sh.lo: elf32-sh.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \
$(INCDIR)/libiberty.h $(srcdir)/../opcodes/sh-opc.h \
elf32-target.h
+elf32-sh-symbian.lo: elf32-sh-symbian.c elf32-sh.c $(INCDIR)/filenames.h \
+ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h \
+ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \
+ $(srcdir)/../opcodes/sh-opc.h elf32-target.h
elf32-sparc.lo: elf32-sparc.c $(INCDIR)/filenames.h \
$(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sparc.h \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 240e5fd7423..6638273a437 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -381,6 +381,7 @@ BFD32_BACKENDS = \
elf32-ppc.lo \
elf32-s390.lo \
elf32-sh.lo \
+ elf32-sh-symbian.lo \
elf32-sh64.lo \
elf32-sh64-com.lo \
elf32-sparc.lo \
@@ -550,6 +551,7 @@ BFD32_BACKENDS_CFILES = \
elf32-sh64-com.c \
elf32-s390.c \
elf32-sh.c \
+ elf32-sh-symbian.c \
elf32-sparc.c \
elf32-v850.c \
elf32-vax.c \
@@ -1843,6 +1845,11 @@ elf32-sh.lo: elf32-sh.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h $(INCDIR)/elf/reloc-macros.h \
$(INCDIR)/libiberty.h $(srcdir)/../opcodes/sh-opc.h \
elf32-target.h
+elf32-sh-symbian.lo: elf32-sh-symbian.c elf32-sh.c $(INCDIR)/filenames.h \
+ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sh.h \
+ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \
+ $(srcdir)/../opcodes/sh-opc.h elf32-target.h
elf32-sparc.lo: elf32-sparc.c $(INCDIR)/filenames.h \
$(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/sparc.h \
@@ -2189,3 +2196,7 @@ pepigen.lo: pepigen.c $(INCDIR)/filenames.h $(INCDIR)/coff/internal.h \
$(INCDIR)/coff/ia64.h $(INCDIR)/coff/external.h $(INCDIR)/coff/pe.h \
libcoff.h $(INCDIR)/bfdlink.h libpei.h
# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/bfd/config.bfd b/bfd/config.bfd
index d5469ca379b..a8e416168da 100644
--- a/bfd/config.bfd
+++ b/bfd/config.bfd
@@ -1101,6 +1101,11 @@ case "${targ}" in
targ_defvec=bfd_elf32_shnbsd_vec
targ_selvecs="bfd_elf32_shlnbsd_vec shcoff_vec shlcoff_vec"
;;
+ sh*-symbian-elf*)
+ targ_defvec=bfd_elf32_shl_symbian_vec
+ targ_selvecs="shlcoff_vec shlcoff_small_vec"
+ targ_underscore=yes
+ ;;
shl*-*-elf* | sh[1234]l*-*-elf* | sh3el*-*-elf* | shl*-*-kaos*)
targ_defvec=bfd_elf32_shl_vec
targ_selvecs="bfd_elf32_sh_vec shlcoff_vec shcoff_vec shlcoff_small_vec shcoff_small_vec"
diff --git a/bfd/configure b/bfd/configure
index cb63a9df8b3..34bf21f97d8 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -6340,6 +6340,7 @@ do
bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shl_symbian_vec) tb="$tb elf32-sh-symbian.lo elf32-sh64-com.lo elf32.lo $elf coff-sh.lo" ;;
bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
@@ -6568,10 +6569,10 @@ case ${host64}-${target64}-${want64} in
if test -n "$GCC" ; then
bad_64bit_gcc=no;
echo $ac_n "checking for gcc version with buggy 64-bit support""... $ac_c" 1>&6
-echo "configure:6572: checking for gcc version with buggy 64-bit support" >&5
+echo "configure:6573: checking for gcc version with buggy 64-bit support" >&5
# Add more tests for gcc versions with non-working 64-bit support here.
cat > conftest.$ac_ext <<EOF
-#line 6575 "configure"
+#line 6576 "configure"
#include "confdefs.h"
:__GNUC__:__GNUC_MINOR__:__i386__:
EOF
@@ -6613,12 +6614,12 @@ esac
for ac_func in ftello ftello64 fseeko fseeko64
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6617: checking for $ac_func" >&5
+echo "configure:6618: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6622 "configure"
+#line 6623 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6641,7 +6642,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6646: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -6667,13 +6668,13 @@ done
if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then
echo $ac_n "checking size of off_t""... $ac_c" 1>&6
-echo "configure:6671: checking size of off_t" >&5
+echo "configure:6672: checking size of off_t" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
for ac_size in 4 8 1 2 16 12 ; do # List sizes in rough order of prevalence.
cat > conftest.$ac_ext <<EOF
-#line 6677 "configure"
+#line 6678 "configure"
#include "confdefs.h"
#include "confdefs.h"
#include <sys/types.h>
@@ -6683,7 +6684,7 @@ int main() {
switch (0) case 0: case (sizeof (off_t) == $ac_size):;
; return 0; }
EOF
-if { (eval echo configure:6687: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6688: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_sizeof_off_t=$ac_size
else
@@ -6707,7 +6708,7 @@ EOF
fi
echo $ac_n "checking file_ptr type""... $ac_c" 1>&6
-echo "configure:6711: checking file_ptr type" >&5
+echo "configure:6712: checking file_ptr type" >&5
bfd_file_ptr="long"
bfd_ufile_ptr="unsigned long"
if test x"$ac_cv_func_ftello64" = xyes -a x"$ac_cv_func_fseeko64" = xyes \
@@ -6732,17 +6733,17 @@ for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6736: checking for $ac_hdr" >&5
+echo "configure:6737: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6741 "configure"
+#line 6742 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6746: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6747: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -6771,12 +6772,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6775: checking for $ac_func" >&5
+echo "configure:6776: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6780 "configure"
+#line 6781 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6799,7 +6800,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6804: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -6824,7 +6825,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6828: checking for working mmap" >&5
+echo "configure:6829: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6832,7 +6833,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 6836 "configure"
+#line 6837 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6972,7 +6973,7 @@ main()
}
EOF
-if { (eval echo configure:6976: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@@ -6997,12 +6998,12 @@ fi
for ac_func in madvise mprotect
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:7001: checking for $ac_func" >&5
+echo "configure:7002: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 7006 "configure"
+#line 7007 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -7025,7 +7026,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:7029: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
diff --git a/bfd/configure.in b/bfd/configure.in
index c4dba9aba8a..00890d79412 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -649,6 +649,7 @@ do
bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
bfd_elf32_shblin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shl_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
+ bfd_elf32_shl_symbian_vec) tb="$tb elf32-sh-symbian.lo elf32-sh64-com.lo elf32.lo $elf coff-sh.lo" ;;
bfd_elf32_shlin_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;;
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 1892cb17420..94a847d8d26 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -665,6 +665,13 @@ struct elf_backend_data
(bfd *abfd, struct bfd_link_info *info, asection *o,
const Elf_Internal_Rela *relocs);
+ /* The CHECK_DIRECTIVES function is called once per input file by
+ the add_symbols phase of the ELF backend linker. The function
+ must inspect the bfd and create any additional symbols according
+ to any custom directives in the bfd. */
+ bfd_boolean (*check_directives)
+ (bfd *abfd, struct bfd_link_info *info);
+
/* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
linker for every symbol which is defined by a dynamic object and
referenced by a regular object. This is called after all the
diff --git a/bfd/elf32-sh-symbian.c b/bfd/elf32-sh-symbian.c
new file mode 100644
index 00000000000..0dbf2277377
--- /dev/null
+++ b/bfd/elf32-sh-symbian.c
@@ -0,0 +1,625 @@
+/* Renesas / SuperH specific support for Symbian 32-bit ELF files
+ Copyright 2004
+ Free Software Foundation, Inc.
+ 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
+ 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. */
+
+/* Stop elf32-sh.c from defining any target vectors. */
+#define SH_TARGET_ALREADY_DEFINED
+#include "elf32-sh.c"
+
+
+//#define DEBUG 1
+#define DEBUG 0
+
+#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
+ reached and DEBUG is enabled then the error message 'm'
+ is displayed. */
+#define SKIP_UNTIL(s,e,c,m) \
+ do \
+ { \
+ while (s < e && *s != c) \
+ ++ s; \
+ if (s >= e) \
+ { \
+ if (DEBUG) \
+ 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) \
+ { \
+ if (DEBUG) \
+ 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'
+ is reached and DEBUG is enabled then the error message
+ 'm' is displayed. */
+#define SKIP_WHILE(s,e,c,m) \
+ do \
+ { \
+ while (s < e && *s == c) \
+ ++ s; \
+ if (s >= e) \
+ { \
+ if (DEBUG) \
+ fprintf (stderr, "Corrupt directive: %s\n", m); \
+ result = FALSE; \
+ } \
+ } \
+ while (0); \
+ if (!result) \
+ break;
+
+
+typedef struct symbol_rename
+{
+ struct symbol_rename * next;
+ bfd_byte * current_name;
+ bfd_byte * new_name;
+ 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,
+ bfd_byte * current_name, bfd_byte * new_name)
+{
+ struct elf_link_hash_entry * new_hash;
+ symbol_rename * node;
+
+ if (DEBUG)
+ 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_error_handler (_("%s: IMPORT AS directive for %s conceals previous IMPORT AS"),
+ bfd_archive_filename (abfd), current_name);
+ return FALSE;
+ }
+
+ if ((node = bfd_malloc (sizeof * node)) == NULL)
+ {
+ if (DEBUG)
+ fprintf (stderr, "IMPORT AS: No mem for new rename node\n");
+ return FALSE;
+ }
+
+ if ((node->current_name = bfd_malloc (strlen (current_name) + 1)) == NULL)
+ {
+ if (DEBUG)
+ 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);
+
+ if ((node->new_name = bfd_malloc (strlen (new_name) + 1)) == NULL)
+ {
+ if (DEBUG)
+ 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
+sh_symbian_import (bfd * abfd ATTRIBUTE_UNUSED, bfd_byte * name)
+{
+ if (DEBUG)
+ fprintf (stderr, "IMPORT '%s'\n", name);
+
+ /* XXX: Generate an import somehow ? */
+
+ return TRUE;
+}
+
+static bfd_boolean
+sh_symbian_export (bfd * abfd ATTRIBUTE_UNUSED, bfd_byte * name)
+{
+ if (DEBUG)
+ 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)
+{
+ bfd_byte *s;
+ bfd_byte *e;
+ bfd_boolean result = TRUE;
+ bfd_size_type sz = sec->rawsize ? sec->rawsize : sec->size;
+
+ for (s = contents, e = s + sz; s < e;)
+ {
+ bfd_byte * directive = s;
+
+ 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':
+ if (strncmp (s, DIRECTIVE_IMPORT, strlen (DIRECTIVE_IMPORT)))
+ result = FALSE;
+ else
+ {
+ bfd_byte * new_name;
+ bfd_byte * new_name_end;
+ bfd_byte name_end_char;
+
+ /* 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;
+
+ /* Check to see if 'AS '... is present. If se we have an IMPORT AS
+ directive, otherwise we have an IMPORT directive. */
+ if (strncmp (s, DIRECTIVE_AS, strlen (DIRECTIVE_AS)))
+ {
+ /* Skip the new-line at the end of the name. */
+ if (DEBUG && name_end_char != '\n')
+ 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)
+ {
+ if (DEBUG)
+ fprintf (stderr, "IMPORT: No NUL at end of directive\n");
+ }
+ }
+ else
+ {
+ bfd_byte * current_name;
+ bfd_byte * current_name_end;
+ bfd_byte current_name_end_char;
+
+ /* 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')
+ if (DEBUG)
+ 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)
+ {
+ if (DEBUG)
+ 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':
+ if (strncmp (s, DIRECTIVE_EXPORT, strlen (DIRECTIVE_EXPORT)))
+ result = FALSE;
+ else
+ {
+ bfd_byte * name;
+ bfd_byte * name_end;
+ bfd_byte name_end_char;
+
+ /* 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)
+ {
+ if (DEBUG)
+ 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)
+ {
+ if (DEBUG)
+ fprintf (stderr, "offset into .directive section: %d\n", directive - contents);
+
+ bfd_set_error (bfd_error_invalid_operation);
+ _bfd_error_handler (_("%s: Unrecognised .directive command: %s"),
+ bfd_archive_filename (abfd), directive);
+ break;
+ }
+ }
+
+ return result;
+}
+
+
+/* Scan a bfd for a .directive section, and if found process it.
+ Returns TRUE upon success, FALSE otherwise. */
+bfd_boolean bfd_elf32_sh_symbian_process_directives (struct bfd_link_info *info, bfd * abfd);
+
+bfd_boolean
+bfd_elf32_sh_symbian_process_directives (struct bfd_link_info *info, bfd * abfd)
+{
+ 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);
+ else
+ {
+ 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. */
+ if (!info->relocatable)
+ {
+ 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;
+
+ BFD_ASSERT (! elf_bad_symtab (input_bfd));
+
+ 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)
+ {
+ if (DEBUG)
+ fprintf (stderr, "IMPORT AS: current symbol '%s' does not exist\n", ptr->current_name);
+ continue;
+ }
+
+ new_hash = elf_link_hash_lookup (hash_table, ptr->new_name, FALSE, FALSE, TRUE);
+
+ /* 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)
+ {
+ asection * psec = bfd_und_section_ptr;
+ Elf_Internal_Sym new_sym;
+ bfd_vma new_value = 0;
+ bfd_boolean skip;
+ bfd_boolean override;
+ bfd_boolean type_change_ok;
+ bfd_boolean size_change_ok;
+
+ new_sym.st_value = 0;
+ new_sym.st_size = 0;
+ new_sym.st_name = -1;
+ new_sym.st_info = ELF_ST_INFO (STB_GLOBAL, STT_FUNC);
+ new_sym.st_other = ELF_ST_VISIBILITY (STV_DEFAULT);
+ new_sym.st_shndx = SHN_UNDEF;
+
+ if (! _bfd_elf_merge_symbol (input_bfd, info, ptr->new_name, & new_sym, & psec,
+ & new_value, & new_hash, & skip, & override, & type_change_ok,
+ & size_change_ok))
+ {
+ _bfd_error_handler (_("%s: Failed to add renamed symbol %s"),
+ bfd_archive_filename (input_bfd), ptr->new_name);
+ continue;
+ }
+ /* XXX - should we check psec, skip, override etc ? */
+
+ new_hash->root.type = bfd_link_hash_undefined;
+
+ /* Allow the symbol to become local if necessary. */
+ if (new_hash->dynindx == -1)
+ new_hash->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
+
+ if (DEBUG)
+ fprintf (stderr, "Created new symbol %s\n", ptr->new_name);
+ }
+
+ /* 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;
+ if (DEBUG)
+ 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)
+ {
+ if (DEBUG)
+ 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;
+
+ if (DEBUG)
+ 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;
+
+ 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);
+ if (DEBUG)
+ fprintf (stderr, "convert reloc %lx from using index %ld to using index %ld\n",
+ (long) rel->r_info, (long) ELF32_R_SYM (rel->r_info), ptr->new_symndx);
+ rel->r_info = ELF32_R_INFO (ptr->new_symndx, r_type);
+ break;
+ }
+ }
+ }
+
+ return sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+ contents, relocs, local_syms, local_sections);
+}
+
+static bfd_boolean
+sh_symbian_check_directives (bfd *abfd, struct bfd_link_info *info)
+{
+ return bfd_elf32_sh_symbian_process_directives (info, abfd);
+}
+
+#define TARGET_LITTLE_SYM bfd_elf32_shl_symbian_vec
+#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
+#define elf_backend_check_directives sh_symbian_check_directives
+
+#include "elf32-target.h"
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index e1d7e1a5050..b5a3caf39ed 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -50,8 +50,10 @@ static bfd_boolean sh_elf_relax_delete_bytes
(bfd *, asection *, bfd_vma, int);
static bfd_boolean sh_elf_align_loads
(bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, bfd_boolean *);
+#ifndef SH64_ELF
static bfd_boolean sh_elf_swap_insns
(bfd *, asection *, void *, bfd_byte *, bfd_vma);
+#endif
static bfd_boolean sh_elf_relocate_section
(bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
@@ -107,10 +109,12 @@ static enum elf_reloc_type_class sh_elf_reloc_type_class
#ifdef INCLUDE_SHMEDIA
inline static void movi_shori_putval (bfd *, unsigned long, char *);
#endif
+#if !defined SH_TARGET_ALREADY_DEFINED
static bfd_boolean elf32_shlin_grok_prstatus
(bfd *abfd, Elf_Internal_Note *note);
static bfd_boolean elf32_shlin_grok_psinfo
(bfd *abfd, Elf_Internal_Note *note);
+#endif
/* The name of the dynamic interpreter. This is put in the .interp
section. */
@@ -3090,6 +3094,7 @@ sh_elf_align_loads (bfd *abfd ATTRIBUTE_UNUSED, asection *sec,
return FALSE;
}
+#ifndef SH64_ELF
/* Swap two SH instructions. This is like sh_swap_insns in coff-sh.c. */
static bfd_boolean
@@ -3218,6 +3223,7 @@ sh_elf_swap_insns (bfd *abfd, asection *sec, void *relocs,
return TRUE;
}
+#endif /* defined SH64_ELF */
#ifdef INCLUDE_SHMEDIA
@@ -6827,6 +6833,7 @@ sh_elf_set_mach_from_flags (bfd *abfd)
return the equivalent ELF flags from the table.
Return -1 if no match is found. */
+#ifndef SH_TARGET_ALREADY_DEFINED
int
sh_elf_get_flags_from_mach (unsigned long mach)
{
@@ -6841,6 +6848,7 @@ sh_elf_get_flags_from_mach (unsigned long mach)
return -1;
}
+#endif
#endif /* not sh_elf_set_mach_from_flags */
#ifndef sh_elf_set_private_flags
@@ -6876,14 +6884,17 @@ sh_elf_copy_private_data (bfd * ibfd, bfd * obfd)
/* This function returns the ELF architecture number that
corresponds to the given arch_sh* flags. */
+
+#ifndef SH_TARGET_ALREADY_DEFINED
int
sh_find_elf_flags (unsigned int arch_set)
{
+ extern unsigned long sh_get_bfd_mach_from_arch_set (unsigned int);
unsigned long bfd_mach = sh_get_bfd_mach_from_arch_set (arch_set);
return sh_elf_get_flags_from_mach (bfd_mach);
}
-
+#endif
/* This routine initialises the elf flags when required and
calls sh_merge_bfd_arch() to check dsp/fpu compatibility. */
@@ -6891,6 +6902,8 @@ sh_find_elf_flags (unsigned int arch_set)
static bfd_boolean
sh_elf_merge_private_data (bfd *ibfd, bfd *obfd)
{
+ extern bfd_boolean sh_merge_bfd_arch (bfd *, bfd *);
+
if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return TRUE;
@@ -6903,7 +6916,7 @@ sh_elf_merge_private_data (bfd *ibfd, bfd *obfd)
sh_elf_set_mach_from_flags (obfd);
}
- if ( ! sh_merge_bfd_arch (ibfd, obfd) )
+ if (! sh_merge_bfd_arch (ibfd, obfd))
return FALSE;
elf_elfheader (obfd)->e_flags =
@@ -7383,7 +7396,9 @@ sh_elf_reloc_type_class (const Elf_Internal_Rela *rela)
}
}
+#if !defined SH_TARGET_ALREADY_DEFINED
/* Support for Linux core dump NOTE sections. */
+
static bfd_boolean
elf32_shlin_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
{
@@ -7443,6 +7458,7 @@ elf32_shlin_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
return TRUE;
}
+#endif /* not SH_TARGET_ALREADY_DEFINED */
/* Return address for Ith PLT stub in section PLT, for relocation REL
@@ -7455,10 +7471,13 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
return plt->vma + (i + 1) * PLT_ENTRY_SIZE;
}
+#if !defined SH_TARGET_ALREADY_DEFINED
#define TARGET_BIG_SYM bfd_elf32_sh_vec
#define TARGET_BIG_NAME "elf32-sh"
#define TARGET_LITTLE_SYM bfd_elf32_shl_vec
#define TARGET_LITTLE_NAME "elf32-shl"
+#endif
+
#define ELF_ARCH bfd_arch_sh
#define ELF_MACHINE_CODE EM_SH
#ifdef __QNXTARGET__
@@ -7511,7 +7530,7 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
#define elf_backend_want_plt_sym 0
#define elf_backend_got_header_size 12
-#ifndef INCLUDE_SHMEDIA
+#if !defined INCLUDE_SHMEDIA && !defined SH_TARGET_ALREADY_DEFINED
#include "elf32-target.h"
@@ -7553,4 +7572,4 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
#include "elf32-target.h"
-#endif /* INCLUDE_SHMEDIA */
+#endif /* neither INCLUDE_SHMEDIA nor SH_TARGET_ALREADY_DEFINED */
diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c
index f9d5e383571..58833715af9 100644
--- a/bfd/elf32-sh64.c
+++ b/bfd/elf32-sh64.c
@@ -106,6 +106,7 @@ static void sh64_find_section_for_address
#define GOT_BIAS (-((long)-32768))
#define INCLUDE_SHMEDIA
+#define SH_TARGET_ALREADY_DEFINED
#include "elf32-sh.c"
/* Tack some extra info on struct bfd_elf_section_data. */
diff --git a/bfd/elflink.c b/bfd/elflink.c
index c2830ff4be5..1c1de27fc87 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -2904,6 +2904,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
const char **, flagword *, asection **, bfd_vma *);
bfd_boolean (*check_relocs)
(bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
+ bfd_boolean (*check_directives)
+ (bfd *, struct bfd_link_info *);
bfd_boolean collect;
Elf_Internal_Shdr *hdr;
bfd_size_type symcount;
@@ -4053,6 +4055,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
free (sorted_sym_hash);
}
+ check_directives = get_elf_backend_data (abfd)->check_directives;
+ if (check_directives)
+ check_directives (abfd, info);
+
/* If this object is the same format as the output object, and it is
not a shared library, then let the backend look through the
relocs.
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index af04ecb6b65..a48b9f36d61 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -330,6 +330,9 @@
#ifndef elf_backend_check_relocs
#define elf_backend_check_relocs 0
#endif
+#ifndef elf_backend_check_directives
+#define elf_backend_check_directives 0
+#endif
#ifndef elf_backend_adjust_dynamic_symbol
#define elf_backend_adjust_dynamic_symbol 0
#endif
@@ -510,6 +513,7 @@ static const struct elf_backend_data elfNN_bed =
elf_backend_create_dynamic_sections,
elf_backend_omit_section_dynsym,
elf_backend_check_relocs,
+ elf_backend_check_directives,
elf_backend_adjust_dynamic_symbol,
elf_backend_always_size_sections,
elf_backend_size_dynamic_sections,
diff --git a/bfd/targets.c b/bfd/targets.c
index 19892543e32..320f7b9adde 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -589,6 +589,7 @@ extern const bfd_target bfd_elf32_sh64nbsd_vec;
extern const bfd_target bfd_elf32_sh_vec;
extern const bfd_target bfd_elf32_shblin_vec;
extern const bfd_target bfd_elf32_shl_vec;
+extern const bfd_target bfd_elf32_shl_symbian_vec;
extern const bfd_target bfd_elf32_shlin_vec;
extern const bfd_target bfd_elf32_shlnbsd_vec;
extern const bfd_target bfd_elf32_shnbsd_vec;
@@ -880,6 +881,7 @@ static const bfd_target * const _bfd_target_vector[] = {
&bfd_elf32_sh_vec,
&bfd_elf32_shblin_vec,
&bfd_elf32_shl_vec,
+ &bfd_elf32_shl_symbian_vec,
&bfd_elf32_shlin_vec,
&bfd_elf32_shlnbsd_vec,
&bfd_elf32_shnbsd_vec,