bfd/ * config.bfd (tic6x-*-*): Allow instead of tic6x-*-elf. * elf32-tic6x.c (struct elf32_tic6x_link_hash_table): New. (elf32_tic6x_hash_table): New macro. (elf32_tic6x_link_hash_table_create, elf32_tic6x_link_hash_table_free, elf32_tic6x_setup): New static functions. (elf32_tic6x_relocate_section): Handle R_C6000_DSBT_INDEX. (bfd_elf32_bfd_link_hash_table_create, bfd_elf32_bfd_link_hash_table_free): Define. * elf32-tic6x.h (struct elf32_tic6x_params): New. ld/ * emulparams/elf32_tic6x_le.sh (TEXT_START_ADDR): For *-uclinux targets, set to 0x0. (EXTRA_EM_FILE): Define. (OTHER_GOT_SYMBOLS): Renamed from SDATA_START_SYMBOLS. (OTHER_BSS_SECTIONS): Only define for *-elf targets. * emultempl/tic6xdsbt.em: New file. * gen-doc.texi: Set C6X. * ld.texinfo: Likewise. (Options specific to C6X uClinux targets): New section. ld/testsuite/ * ld-tic6x/dsbt-index.d: New test. * ld-tic6x/dsbt-index.s: New test. * lib/ld-lib.exp (is_elf_format): Allow c6x-*-uclinux. binutils/testsuite/ * lib/utils-lib.exp (is_elf_format): Allow c6x-*-uclinux. gas/testsuite/ * lib/gas-defs.exp (is_elf_format): Allow c6x-*-uclinux. Index: bfd/config.bfd =================================================================== RCS file: /cvs/src/src/bfd/config.bfd,v retrieving revision 1.269 diff -c -p -r1.269 config.bfd *** bfd/config.bfd 2 Sep 2010 22:54:43 -0000 1.269 --- bfd/config.bfd 29 Sep 2010 16:49:57 -0000 *************** case "${targ}" in *** 1458,1464 **** ;; #endif ! tic6x-*-elf) targ_defvec=bfd_elf32_tic6x_le_vec targ_selvecs=bfd_elf32_tic6x_be_vec ;; --- 1458,1464 ---- ;; #endif ! tic6x-*-*) targ_defvec=bfd_elf32_tic6x_le_vec targ_selvecs=bfd_elf32_tic6x_be_vec ;; Index: bfd/elf32-tic6x.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-tic6x.c,v retrieving revision 1.5 diff -c -p -r1.5 elf32-tic6x.c *** bfd/elf32-tic6x.c 23 Sep 2010 16:16:37 -0000 1.5 --- bfd/elf32-tic6x.c 29 Sep 2010 16:49:58 -0000 *************** *** 27,32 **** --- 27,46 ---- #include "elf/tic6x.h" #include "elf32-tic6x.h" + /* TI C6X ELF linker hash table. */ + + struct elf32_tic6x_link_hash_table + { + struct elf_link_hash_table elf; + + struct elf32_tic6x_params params; + }; + + /* Get the TI C6X ELF linker hash table from a link_info structure. */ + + #define elf32_tic6x_hash_table(p) \ + ((struct elf32_tic6x_link_hash_table *) ((p)->hash)) + struct elf32_tic6x_obj_tdata { struct elf_obj_tdata root; *************** elf32_tic6x_fake_sections (bfd *abfd, *** 1372,1377 **** --- 1386,1431 ---- return TRUE; } + /* Create an C6X ELF linker hash table. */ + + static struct bfd_link_hash_table * + elf32_tic6x_link_hash_table_create (bfd *abfd) + { + struct elf32_tic6x_link_hash_table *ret; + bfd_size_type amt = sizeof (struct elf32_tic6x_link_hash_table); + + ret = bfd_malloc (amt); + if (ret == NULL) + return NULL; + + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, + _bfd_elf_link_hash_newfunc, + sizeof (struct elf_link_hash_entry), + TIC6X_ELF_DATA)) + { + free (ret); + return NULL; + } + + return &ret->elf.root; + } + + /* Destroy an C6X ELF linker hash table. */ + + static void + elf32_tic6x_link_hash_table_free (struct bfd_link_hash_table *hash) + { + _bfd_generic_link_hash_table_free (hash); + } + + void + elf32_tic6x_setup (struct bfd_link_info *info, + struct elf32_tic6x_params *params) + { + struct elf32_tic6x_link_hash_table *htab = elf32_tic6x_hash_table (info); + htab->params = *params; + } + static bfd_boolean elf32_tic6x_mkobject (bfd *abfd) { *************** elf32_tic6x_relocate_section (bfd *outpu *** 1575,1584 **** } break; case R_C6000_SBR_GOT_U15_W: case R_C6000_SBR_GOT_L16_W: case R_C6000_SBR_GOT_H16_W: - case R_C6000_DSBT_INDEX: case R_C6000_PREL31: /* Shared libraries and exception handling support not implemented. */ --- 1629,1641 ---- } break; + case R_C6000_DSBT_INDEX: + relocation = elf32_tic6x_hash_table (info)->params.dsbt_index; + break; + case R_C6000_SBR_GOT_U15_W: case R_C6000_SBR_GOT_L16_W: case R_C6000_SBR_GOT_H16_W: case R_C6000_PREL31: /* Shared libraries and exception handling support not implemented. */ *************** elf32_tic6x_merge_private_bfd_data (bfd *** 1785,1790 **** --- 1842,1851 ---- #define bfd_elf32_bfd_reloc_name_lookup elf32_tic6x_reloc_name_lookup #define bfd_elf32_bfd_merge_private_bfd_data elf32_tic6x_merge_private_bfd_data #define bfd_elf32_mkobject elf32_tic6x_mkobject + #define bfd_elf32_bfd_link_hash_table_create \ + elf32_tic6x_link_hash_table_create + #define bfd_elf32_bfd_link_hash_table_free \ + elf32_tic6x_link_hash_table_free #define bfd_elf32_new_section_hook elf32_tic6x_new_section_hook #define elf_backend_can_gc_sections 1 #define elf_backend_default_use_rela_p 1 Index: bfd/elf32-tic6x.h =================================================================== RCS file: /cvs/src/src/bfd/elf32-tic6x.h,v retrieving revision 1.2 diff -c -p -r1.2 elf32-tic6x.h *** bfd/elf32-tic6x.h 16 Jun 2010 00:36:01 -0000 1.2 --- bfd/elf32-tic6x.h 29 Sep 2010 16:49:58 -0000 *************** extern int elf32_tic6x_merge_arch_attrib *** 24,26 **** --- 24,34 ---- /* This function is provided for use from the assembler. */ extern void elf32_tic6x_set_use_rela_p (bfd *, bfd_boolean); + + struct elf32_tic6x_params + { + int dsbt_index; + }; + + extern void elf32_tic6x_setup (struct bfd_link_info *, + struct elf32_tic6x_params *); Index: binutils/testsuite/lib/utils-lib.exp =================================================================== RCS file: /cvs/src/src/binutils/testsuite/lib/utils-lib.exp,v retrieving revision 1.20 diff -c -p -r1.20 utils-lib.exp *** binutils/testsuite/lib/utils-lib.exp 29 Sep 2010 06:04:40 -0000 1.20 --- binutils/testsuite/lib/utils-lib.exp 29 Sep 2010 16:50:00 -0000 *************** proc is_elf_format {} { *** 132,137 **** --- 132,138 ---- && ![istarget frv-*-uclinux*] && ![istarget bfin-*-uclinux] && ![istarget sh*-*-uclinux*] + && ![istarget tic6x-*-uclinux] && ![istarget *-*-irix5*] && ![istarget *-*-irix6*] && ![istarget *-*-netbsd*] Index: gas/testsuite/lib/gas-defs.exp =================================================================== RCS file: /cvs/src/src/gas/testsuite/lib/gas-defs.exp,v retrieving revision 1.41 diff -c -p -r1.41 gas-defs.exp *** gas/testsuite/lib/gas-defs.exp 29 Sep 2010 06:05:16 -0000 1.41 --- gas/testsuite/lib/gas-defs.exp 29 Sep 2010 16:50:01 -0000 *************** proc is_elf_format {} { *** 291,296 **** --- 291,297 ---- && ![istarget frv-*-uclinux*] && ![istarget bfin-*-uclinux] && ![istarget sh*-*-uclinux*] + && ![istarget tic6x-*-uclinux] && ![istarget *-*-irix5*] && ![istarget *-*-irix6*] && ![istarget *-*-netbsd*] Index: ld/gen-doc.texi =================================================================== RCS file: /cvs/src/src/ld/gen-doc.texi,v retrieving revision 1.12 diff -c -p -r1.12 gen-doc.texi *** ld/gen-doc.texi 12 Jul 2008 08:54:13 -0000 1.12 --- ld/gen-doc.texi 29 Sep 2010 16:50:02 -0000 *************** *** 4,9 **** --- 4,10 ---- @c 2. Specific target machines @set ARM + @set C6X @set H8300 @set HPPA @set I960 Index: ld/ld.texinfo =================================================================== RCS file: /cvs/src/src/ld/ld.texinfo,v retrieving revision 1.264 diff -c -p -r1.264 ld.texinfo *** ld/ld.texinfo 16 Sep 2010 00:06:12 -0000 1.264 --- ld/ld.texinfo 29 Sep 2010 16:50:03 -0000 *************** *** 22,27 **** --- 22,28 ---- @set UsesEnvVars @set GENERIC @set ARM + @set C6X @set H8300 @set HPPA @set I960 *************** The image is Terminal Server aware. *** 2612,2617 **** --- 2613,2638 ---- @c man end + @ifset C6X + @subsection Options specific to C6X uClinux targets + + @c man begin OPTIONS + + The C6X uClinux target uses a binary format called DSBT to support shared + libraries. Each shared library in the system needs to have a unique index. + + @table @gcctabopt + + @kindex --dsbt_index + @item --dsbt_index @var{index} + This option sets the DSBT index of the current executable or shared library + to @var{index}. + + @end table + + @c man end + @end ifset + @ifset M68HC11 @subsection Options specific to Motorola 68HC11 and 68HC12 targets Index: ld/emulparams/elf32_tic6x_le.sh =================================================================== RCS file: /cvs/src/src/ld/emulparams/elf32_tic6x_le.sh,v retrieving revision 1.3 diff -c -p -r1.3 elf32_tic6x_le.sh *** ld/emulparams/elf32_tic6x_le.sh 16 Jun 2010 00:36:03 -0000 1.3 --- ld/emulparams/elf32_tic6x_le.sh 29 Sep 2010 16:50:03 -0000 *************** *** 1,14 **** SCRIPT_NAME=elf TEMPLATE_NAME=elf32 OUTPUT_FORMAT="elf32-tic6x-le" # This address is an arbitrary value expected to be suitable for # semihosting simulator use, but not on hardware where it is expected # to be overridden. ! TEXT_START_ADDR=0x8000 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" ARCH=tic6x EXECUTABLE_SYMBOLS="EXTERN (__c6xabi_DSBT_BASE);" ! SDATA_START_SYMBOLS="PROVIDE_HIDDEN (__c6xabi_DSBT_BASE = .);" # ".bss" is near (small) BSS, ".far" is far (normal) BSS, ".const" is # far read-only data, ".rodata" is near read-only data. ".neardata" # is near (small) data, ".fardata" is (along with .data) far data. --- 1,22 ---- SCRIPT_NAME=elf TEMPLATE_NAME=elf32 + EXTRA_EM_FILE=tic6xdsbt OUTPUT_FORMAT="elf32-tic6x-le" # This address is an arbitrary value expected to be suitable for # semihosting simulator use, but not on hardware where it is expected # to be overridden. ! case ${target} in ! *-elf) ! TEXT_START_ADDR=0x8000 ! ;; ! *-uclinux) ! TEXT_START_ADDR=0x0 ! ;; ! esac MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" ARCH=tic6x EXECUTABLE_SYMBOLS="EXTERN (__c6xabi_DSBT_BASE);" ! OTHER_GOT_SYMBOLS="PROVIDE_HIDDEN (__c6xabi_DSBT_BASE = .);" # ".bss" is near (small) BSS, ".far" is far (normal) BSS, ".const" is # far read-only data, ".rodata" is near read-only data. ".neardata" # is near (small) data, ".fardata" is (along with .data) far data. *************** OTHER_READWRITE_SECTIONS=".fardata ${REL *** 24,30 **** OTHER_READWRITE_RELOC_SECTIONS=" .rel.fardata ${RELOCATING-0} : { *(.rel.fardata${RELOCATING+ .rel.fardata.*}) } .rela.fardata ${RELOCATING-0} : { *(.rela.fardata${RELOCATING+ .rela.fardata.*}) }" ! OTHER_BSS_SECTIONS=" .heap : { . = ALIGN(4); --- 32,40 ---- OTHER_READWRITE_RELOC_SECTIONS=" .rel.fardata ${RELOCATING-0} : { *(.rel.fardata${RELOCATING+ .rel.fardata.*}) } .rela.fardata ${RELOCATING-0} : { *(.rela.fardata${RELOCATING+ .rela.fardata.*}) }" ! case ${target} in ! *-elf) ! OTHER_BSS_SECTIONS=" .heap : { . = ALIGN(4); *************** OTHER_BSS_SECTIONS=" *** 37,40 **** --- 47,54 ---- . += 0x100000; _STACK_START = .; }" + ;; + esac + ATTRS_SECTIONS='__TI_build_attributes 0 : { KEEP (*(__TI_build_attributes)) KEEP (*(.gnu.attributes)) }' + Index: ld/emultempl/tic6xdsbt.em =================================================================== RCS file: ld/emultempl/tic6xdsbt.em diff -N ld/emultempl/tic6xdsbt.em *** /dev/null 1 Jan 1970 00:00:00 -0000 --- ld/emultempl/tic6xdsbt.em 29 Sep 2010 16:50:03 -0000 *************** *** 0 **** --- 1,86 ---- + # This shell script emits a C file. -*- C -*- + # Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + # + # This file is part of the GNU Binutils. + # + # 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 3 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program; if not, write to the Free Software + # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + # MA 02110-1301, USA. + # + + # This file is sourced from elf32.em, and defines extra C6X DSBT specific + # features. + # + fragment <xvec == &bfd_elf32_tic6x_le_vec + || link_info.output_bfd->xvec == &bfd_elf32_tic6x_be_vec); + } + + /* Create our note section. */ + + static void + tic6x_after_open (void) + { + if (is_tic6x_target ()) + { + /* Pass params to backend. */ + elf32_tic6x_setup (&link_info, ¶ms); + } + + gld${EMULATION_NAME}_after_open (); + } + EOF + + # This code gets inserted into the generic elf32.sc linker script + # and allows us to define our own command line switches. + PARSE_AND_LIST_PROLOGUE=' + #define OPTION_DSBT_INDEX 300 + ' + + PARSE_AND_LIST_LONGOPTS=' + {"dsbt-index", required_argument, NULL, OPTION_DSBT_INDEX}, + ' + + PARSE_AND_LIST_OPTIONS=' + fprintf (file, _(" --dsbt-index \n")); + fprintf (file, _("\t\t\tUse this as the DSBT index when generating a DLL\n")); + ' + + PARSE_AND_LIST_ARGS_CASES=' + case OPTION_DSBT_INDEX: + { + char *end; + params.dsbt_index = strtol (optarg, &end, 0); + if (*end == 0) + break; + einfo (_("%P%F: invalid --dsbt-index\n"), optarg); + } + break; + ' + + LDEMUL_AFTER_OPEN=tic6x_after_open Index: ld/testsuite/ld-tic6x/dsbt-index.d =================================================================== RCS file: ld/testsuite/ld-tic6x/dsbt-index.d diff -N ld/testsuite/ld-tic6x/dsbt-index.d *** /dev/null 1 Jan 1970 00:00:00 -0000 --- ld/testsuite/ld-tic6x/dsbt-index.d 29 Sep 2010 16:50:03 -0000 *************** *** 0 **** --- 1,14 ---- + #name: C6X DSBT_INDEX reloc + #as: -mlittle-endian + #ld: -melf32_tic6x_le -Tsbr.ld --dsbt-index 5 + #source: dsbt-index.s + #objdump: -dr + + .*: *file format elf32-tic6x-le + + + Disassembly of section \.text: + + 10000000 <[^>]*>: + 10000000:[ \t]+0700056e[ \t]+ldw \.D2T2 \*\+b14\(20\),b14 + [ \t]*\.\.\. Index: ld/testsuite/ld-tic6x/dsbt-index.s =================================================================== RCS file: ld/testsuite/ld-tic6x/dsbt-index.s diff -N ld/testsuite/ld-tic6x/dsbt-index.s *** /dev/null 1 Jan 1970 00:00:00 -0000 --- ld/testsuite/ld-tic6x/dsbt-index.s 29 Sep 2010 16:50:03 -0000 *************** *** 0 **** --- 1,3 ---- + .text + .nocmp + ldw .d2t2 *+B14($DSBT_index(__c6xabi_DSBT_BASE)), B14 Index: ld/testsuite/lib/ld-lib.exp =================================================================== RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v retrieving revision 1.74 diff -c -p -r1.74 ld-lib.exp *** ld/testsuite/lib/ld-lib.exp 29 Sep 2010 06:06:00 -0000 1.74 --- ld/testsuite/lib/ld-lib.exp 29 Sep 2010 16:50:04 -0000 *************** proc is_elf_format {} { *** 410,415 **** --- 410,416 ---- && ![istarget frv-*-uclinux*] && ![istarget bfin-*-uclinux] && ![istarget sh*-*-uclinux*] + && ![istarget tic6x-*-uclinux] && ![istarget *-*-irix5*] && ![istarget *-*-irix6*] && ![istarget *-*-netbsd*]