public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* LD port for ip2k
@ 2002-07-16 11:23 Denis Chertykov
  2002-07-17  7:23 ` Nick Clifton
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Chertykov @ 2002-07-16 11:23 UTC (permalink / raw)
  To: binutils; +Cc: denisc


This is a port of LD for ip2k micro controller.

Denis.


Tue Jul 16 21:22:54 2002  Denis Chertykov  <denisc@overta.ru>
			  Nick Clifton  <nickc@redhat.com>
			  Frank Ch. Eigler  <fche@redhat.com>
			  John Healy  <jhealy@redhat.com>

	* configure.tgt: Add support for ip2k-elf.
	* Makefile.am: Add support for ip2k-elf.
	* emulparams/elf32ip2k.sh: New file.
	* scripttempl/ip2k.sc: New file


Index: configure.tgt
===================================================================
RCS file: /cvs/src/src/ld/configure.tgt,v
retrieving revision 1.98
diff -c -3 -p -r1.98 configure.tgt
*** configure.tgt	9 Jul 2002 02:42:13 -0000	1.98
--- configure.tgt	16 Jul 2002 17:52:31 -0000
*************** mcore-*-elf)		targ_emul=elf32mcore ;;
*** 494,499 ****
--- 494,500 ----
  s390x-*-linux*)         targ_emul=elf64_s390 ;;
  s390-*-linux*)          targ_emul=elf_s390 ;;
  *-*-ieee*)		targ_emul=vanilla ;;
+ ip2k-*-elf)		targ_emul=elf32ip2k ;;
  
  *)
    echo 2>&1 "*** ld does not support target ${targ}"
Index: Makefile.am
===================================================================
RCS file: /cvs/src/src/ld/Makefile.am,v
retrieving revision 1.105
diff -c -3 -p -r1.105 Makefile.am
*** Makefile.am	9 Jul 2002 02:42:13 -0000	1.105
--- Makefile.am	16 Jul 2002 17:52:35 -0000
*************** ALL_EMULATIONS = \
*** 161,166 ****
--- 161,167 ----
  	eelf32fr30.o \
  	eelf32frv.o \
  	eelf32i370.o \
+ 	eelf32ip2k.o \
  	eelf32l4300.o \
  	eelf32lmip.o \
  	eelf32lppc.o \
*************** eelf64lppc.c: $(srcdir)/emulparams/elf64
*** 626,631 ****
--- 627,635 ----
  eelf32i370.c: $(srcdir)/emulparams/elf32i370.sh \
    $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elfi370.sc ${GEN_DEPENDS}
  	${GENSCRIPTS} elf32i370 "$(tdir_elf32i370)"
+ eelf32ip2k.c: $(srcdir)/emulparams/elf32ip2k.sh \
+   $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/ip2k.sc ${GEN_DEPENDS}
+ 	${GENSCRIPTS} elf32ip2k "$(tdir_ip2k)"
  eelf64alpha.c: $(srcdir)/emulparams/elf64alpha.sh \
    $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
  	${GENSCRIPTS} elf64alpha "$(tdir_elf64alpha)"



---------------------------------------------------------------
uuencoded tar.gz of emulparams/elf32ip2k.sh and scripttempl/ip2k.sc

begin 644 ld-new-files.tar.gz
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
:#3744$,--=100PTUU-#_BOX"]"7%NP`H````
`
end

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: LD port for ip2k
  2002-07-16 11:23 LD port for ip2k Denis Chertykov
@ 2002-07-17  7:23 ` Nick Clifton
  2002-07-17  8:40   ` Denis Chertykov
  2002-07-25  2:56   ` Alan Modra
  0 siblings, 2 replies; 6+ messages in thread
From: Nick Clifton @ 2002-07-17  7:23 UTC (permalink / raw)
  To: Denis Chertykov; +Cc: binutils

Hi Denis,

> Entry for include/elf/ChangeLog:
> 
> Mon Jul 15 21:47:21 2002  Denis Chertykov  <denisc@overta.ru>
> 			  Frank Ch. Eigler  <fche@redhat.com>
> 			  Ben Elliston  <bje@redhat.com>
> 			  Alan Lehotsky  <alehotsky@cygnus.com>
> 			  John Healy  <jhealy@redhat.com>
> 			  Graham Stott  <grahams@redhat.com>
> 			  Jeff Johnston  <jjohnstn@redhat.com>
> 
>         * common.h (EM_IP2K): New macro.
>         * ip2k.h: New file.
> 
> 
> Entry for bfd/ChangeLog:
> 
> Mon Jul 15 21:47:21 2002  Denis Chertykov  <denisc@overta.ru>
> 			  Frank Ch. Eigler  <fche@redhat.com>
> 			  Ben Elliston  <bje@redhat.com>
> 			  Alan Lehotsky  <alehotsky@cygnus.com>
> 			  John Healy  <jhealy@redhat.com>
> 			  Graham Stott  <grahams@redhat.com>
> 			  Jeff Johnston  <jjohnstn@redhat.com>
> 
> 	* Makefile.am: Add support for ip2k.
> 	* archures.c: Add support for ip2k.
> 	* config.bfd: Add support for ip2k.
> 	* configure.in: Add support for ip2k.
> 	* reloc.c: Add support for ip2k.
> 	* targets.c: Add support for ip2k.
> 	* cpu-ip2k.c: New file.
> 	* elf32-ip2k.c: New file.
> 
> Entry for ld/ChangeLog
> 
> Tue Jul 16 21:22:54 2002  Denis Chertykov  <denisc@overta.ru>
> 			  Nick Clifton  <nickc@redhat.com>
> 			  Frank Ch. Eigler  <fche@redhat.com>
> 			  John Healy  <jhealy@redhat.com>
> 
> 	* configure.tgt: Add support for ip2k-elf.
> 	* Makefile.am: Add support for ip2k-elf.
> 	* emulparams/elf32ip2k.sh: New file.
> 	* scripttempl/ip2k.sc: New file

Approved and applied.

Cheers
        Nick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: LD port for ip2k
  2002-07-17  7:23 ` Nick Clifton
@ 2002-07-17  8:40   ` Denis Chertykov
  2002-07-25  2:56   ` Alan Modra
  1 sibling, 0 replies; 6+ messages in thread
From: Denis Chertykov @ 2002-07-17  8:40 UTC (permalink / raw)
  To: Nick Clifton; +Cc: Denis Chertykov, binutils

Nick Clifton <nickc@redhat.com> writes:

> Hi Denis,
> 
> > Entry for include/elf/ChangeLog:
> > 
> > Mon Jul 15 21:47:21 2002  Denis Chertykov  <denisc@overta.ru>
> > 			  Frank Ch. Eigler  <fche@redhat.com>
> > 			  Ben Elliston  <bje@redhat.com>
> > 			  Alan Lehotsky  <alehotsky@cygnus.com>
> > 			  John Healy  <jhealy@redhat.com>
> > 			  Graham Stott  <grahams@redhat.com>
> > 			  Jeff Johnston  <jjohnstn@redhat.com>
> > 
> >         * common.h (EM_IP2K): New macro.
> >         * ip2k.h: New file.
> > 
> > 
> > Entry for bfd/ChangeLog:
> > 
> > Mon Jul 15 21:47:21 2002  Denis Chertykov  <denisc@overta.ru>
> > 			  Frank Ch. Eigler  <fche@redhat.com>
> > 			  Ben Elliston  <bje@redhat.com>
> > 			  Alan Lehotsky  <alehotsky@cygnus.com>
> > 			  John Healy  <jhealy@redhat.com>
> > 			  Graham Stott  <grahams@redhat.com>
> > 			  Jeff Johnston  <jjohnstn@redhat.com>
> > 
> > 	* Makefile.am: Add support for ip2k.
> > 	* archures.c: Add support for ip2k.
> > 	* config.bfd: Add support for ip2k.
> > 	* configure.in: Add support for ip2k.
> > 	* reloc.c: Add support for ip2k.
> > 	* targets.c: Add support for ip2k.
> > 	* cpu-ip2k.c: New file.
> > 	* elf32-ip2k.c: New file.
> > 
> > Entry for ld/ChangeLog
> > 
> > Tue Jul 16 21:22:54 2002  Denis Chertykov  <denisc@overta.ru>
> > 			  Nick Clifton  <nickc@redhat.com>
> > 			  Frank Ch. Eigler  <fche@redhat.com>
> > 			  John Healy  <jhealy@redhat.com>
> > 
> > 	* configure.tgt: Add support for ip2k-elf.
> > 	* Makefile.am: Add support for ip2k-elf.
> > 	* emulparams/elf32ip2k.sh: New file.
> > 	* scripttempl/ip2k.sc: New file
> 
> Approved and applied.

Thank you.

I have a write access as AVR port maintainer. You can only
approve/reject my patches.

Denis.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: LD port for ip2k
  2002-07-17  7:23 ` Nick Clifton
  2002-07-17  8:40   ` Denis Chertykov
@ 2002-07-25  2:56   ` Alan Modra
  2002-08-01 11:27     ` Denis Chertykov
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Modra @ 2002-07-25  2:56 UTC (permalink / raw)
  To: binutils; +Cc: Denis Chertykov

On Wed, Jul 17, 2002 at 03:18:20PM +0100, Nick Clifton wrote:
> > Entry for bfd/ChangeLog:
> > 
> > Mon Jul 15 21:47:21 2002  Denis Chertykov  <denisc@overta.ru>
> > 			  Frank Ch. Eigler  <fche@redhat.com>
> > 			  Ben Elliston  <bje@redhat.com>
> > 			  Alan Lehotsky  <alehotsky@cygnus.com>
> > 			  John Healy  <jhealy@redhat.com>
> > 			  Graham Stott  <grahams@redhat.com>
> > 			  Jeff Johnston  <jjohnstn@redhat.com>
> > 
> > 	* elf32-ip2k.c: New file.
[snip]
> 
> Approved and applied.

Would the authors of the above file please read
http://sources.redhat.com/ml/binutils/2002-07/msg00133.html and
update the code accordingly?  I guess this file was developed before I
made this change, but I think it's worth being consistent.  Especially
note the internal reloc freeing bug.

What alerted me to this, was:
.../bfd/elf32-ip2k.c: In function `ip2k_elf_relax_section':
.../bfd/elf32-ip2k.c:1012: warning: assignment from incompatible pointer type
.../bfd/elf32-ip2k.c: In function `adjust_all_relocations':
.../bfd/elf32-ip2k.c:1473: warning: comparison between signed and unsigned
.../bfd/elf32-ip2k.c:1498: warning: comparison between signed and unsigned

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: LD port for ip2k
  2002-07-25  2:56   ` Alan Modra
@ 2002-08-01 11:27     ` Denis Chertykov
  2002-08-01 17:56       ` Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Chertykov @ 2002-08-01 11:27 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, Denis Chertykov

Alan Modra <amodra@bigpond.net.au> writes:

> On Wed, Jul 17, 2002 at 03:18:20PM +0100, Nick Clifton wrote:
> > > Entry for bfd/ChangeLog:
> > > 
> > > Mon Jul 15 21:47:21 2002  Denis Chertykov  <denisc@overta.ru>
> > > 			  Frank Ch. Eigler  <fche@redhat.com>
> > > 			  Ben Elliston  <bje@redhat.com>
> > > 			  Alan Lehotsky  <alehotsky@cygnus.com>
> > > 			  John Healy  <jhealy@redhat.com>
> > > 			  Graham Stott  <grahams@redhat.com>
> > > 			  Jeff Johnston  <jjohnstn@redhat.com>
> > > 
> > > 	* elf32-ip2k.c: New file.
> [snip]
> > 
> > Approved and applied.
> 
> Would the authors of the above file please read
> http://sources.redhat.com/ml/binutils/2002-07/msg00133.html and
> update the code accordingly?  I guess this file was developed before I
> made this change, but I think it's worth being consistent.  Especially
> note the internal reloc freeing bug.
> 
> What alerted me to this, was:
> .../bfd/elf32-ip2k.c: In function `ip2k_elf_relax_section':
> .../bfd/elf32-ip2k.c:1012: warning: assignment from incompatible pointer type
> .../bfd/elf32-ip2k.c: In function `adjust_all_relocations':
> .../bfd/elf32-ip2k.c:1473: warning: comparison between signed and unsigned
> .../bfd/elf32-ip2k.c:1498: warning: comparison between signed and unsigned

2002-08-01  Denis Chertykov  <denisc@overta.ru>

	* elf32-ip2k.c: Processor manufacturer changed to Ubicom.
	(struct misc): New field isymbuf. All free_* fields removed.
	(symbol_value): Pass in internal syms. No need to swap syms in.
	(ip2k_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free
	possibly cached info.
	(tidyup_after_error): Removed.
	(ip2k_elf_relax_section_pass1): Don't use removed fields of struct
	misc. Use new field.
	(adjust_all_relocations): Use internal syms. No need to swap syms
	in and out.
	(add_page_insn): Don't use removed fields of struct misc.


Index: elf32-ip2k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ip2k.c,v
retrieving revision 1.2
diff -c -3 -p -r1.2 elf32-ip2k.c
*** elf32-ip2k.c	23 Jul 2002 12:29:32 -0000	1.2
--- elf32-ip2k.c	1 Aug 2002 17:12:48 -0000
***************
*** 1,4 ****
! /* Scenix IP2xxx specific support for 32-bit ELF
     Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
  
     This file is part of BFD, the Binary File Descriptor library.
--- 1,4 ----
! /* Ubicom IP2xxx specific support for 32-bit ELF
     Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
  
     This file is part of BFD, the Binary File Descriptor library.
*************** struct misc
*** 30,39 ****
    Elf_Internal_Shdr *  symtab_hdr;
    Elf_Internal_Rela *  irelbase;
    bfd_byte *           contents;
!   bfd_byte *           free_contents;
!   Elf32_External_Sym * extsyms;
!   Elf32_External_Sym * free_extsyms;
!   Elf_Internal_Rela *  free_relocs;
  };
  
  /* Prototypes.  */
--- 30,36 ----
    Elf_Internal_Shdr *  symtab_hdr;
    Elf_Internal_Rela *  irelbase;
    bfd_byte *           contents;
!   Elf_Internal_Sym *   isymbuf;
  };
  
  /* Prototypes.  */
*************** static reloc_howto_type *    ip2k_reloc_
*** 41,47 ****
  static void                  ip2k_info_to_howto_rela              PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
  static asection *            ip2k_elf_gc_mark_hook                PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *));
  static boolean               ip2k_elf_gc_sweep_hook               PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
! static bfd_vma               symbol_value                         PARAMS ((bfd *, Elf_Internal_Shdr *, Elf32_External_Sym *, Elf_Internal_Rela *));
  static void                  adjust_all_relocations               PARAMS ((bfd *, asection *, bfd_vma, bfd_vma, int, int));
  static boolean               ip2k_elf_relax_delete_bytes          PARAMS ((bfd *, asection *, bfd_vma, int));
  static boolean               ip2k_elf_relax_add_bytes             PARAMS ((bfd *, asection *, bfd_vma, const bfd_byte *, int, int));
--- 38,44 ----
  static void                  ip2k_info_to_howto_rela              PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
  static asection *            ip2k_elf_gc_mark_hook                PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *));
  static boolean               ip2k_elf_gc_sweep_hook               PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *));
! static bfd_vma               symbol_value                         PARAMS ((bfd *, Elf_Internal_Shdr *, Elf32_Internal_Sym *, Elf_Internal_Rela *));
  static void                  adjust_all_relocations               PARAMS ((bfd *, asection *, bfd_vma, bfd_vma, int, int));
  static boolean               ip2k_elf_relax_delete_bytes          PARAMS ((bfd *, asection *, bfd_vma, int));
  static boolean               ip2k_elf_relax_add_bytes             PARAMS ((bfd *, asection *, bfd_vma, const bfd_byte *, int, int));
*************** static boolean               unrelax_dis
*** 52,58 ****
  static boolean               unrelax_switch_dispatch_tables_passN PARAMS ((bfd *, asection *, bfd_vma, boolean *, struct misc *));
  static boolean               is_switch_128_dispatch_table_p       PARAMS ((bfd *, bfd_vma, boolean, struct misc *));
  static boolean               is_switch_256_dispatch_table_p       PARAMS ((bfd *, bfd_vma, boolean, struct misc *));
- static void                  tidyup_after_error                   PARAMS ((struct misc *));
  static boolean               ip2k_elf_relax_section_pass1         PARAMS ((bfd *, asection *, boolean *, struct misc *));
  static boolean               ip2k_elf_relax_section_passN         PARAMS ((bfd *, asection *, boolean *, boolean *, struct misc *));
  static bfd_reloc_status_type ip2k_final_link_relocate             PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, bfd_vma));
--- 49,54 ----
*************** ip2k_reloc_type_lookup (abfd, code)
*** 257,290 ****
  /* Return the value of the symbol associated with the relocation IREL.  */
  
  static bfd_vma
! symbol_value (abfd, symtab_hdr, extsyms, irel)
       bfd *abfd;
       Elf_Internal_Shdr *symtab_hdr;
!      Elf32_External_Sym *extsyms;
       Elf_Internal_Rela *irel;   
  {
    if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
      {
!       Elf_External_Sym_Shndx *sym_shndx;
!       Elf_Internal_Shdr *shndx_hdr;
!       Elf_Internal_Sym isym;
        asection *sym_sec;
  
!       shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
!       sym_shndx = (Elf_External_Sym_Shndx *) shndx_hdr->contents;
!       sym_shndx = sym_shndx ? sym_shndx + ELF32_R_SYM (irel->r_info) : NULL;
!       bfd_elf32_swap_symbol_in (abfd, extsyms + ELF32_R_SYM (irel->r_info),
! 				sym_shndx, &isym);
!       if (isym.st_shndx == SHN_UNDEF)
  	sym_sec = bfd_und_section_ptr;
!       else if (isym.st_shndx == SHN_ABS)
  	sym_sec = bfd_abs_section_ptr;
!       else if (isym.st_shndx == SHN_COMMON)
  	sym_sec = bfd_com_section_ptr;
        else
! 	sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
  
!       return isym.st_value + BASEADDR (sym_sec);
      }
    else
      {
--- 253,280 ----
  /* Return the value of the symbol associated with the relocation IREL.  */
  
  static bfd_vma
! symbol_value (abfd, symtab_hdr, isymbuf, irel)
       bfd *abfd;
       Elf_Internal_Shdr *symtab_hdr;
!      Elf32_Internal_Sym *isymbuf;
       Elf_Internal_Rela *irel;   
  {
    if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
      {
!       Elf_Internal_Sym *isym;
        asection *sym_sec;
  
!       isym = isymbuf + ELF32_R_SYM (irel->r_info);
!       if (isym->st_shndx == SHN_UNDEF)
  	sym_sec = bfd_und_section_ptr;
!       else if (isym->st_shndx == SHN_ABS)
  	sym_sec = bfd_abs_section_ptr;
!       else if (isym->st_shndx == SHN_COMMON)
  	sym_sec = bfd_com_section_ptr;
        else
! 	sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
  
!       return isym->st_value + BASEADDR (sym_sec);
      }
    else
      {
*************** ip2k_elf_relax_section (abfd, sec, link_
*** 772,779 ****
       struct bfd_link_info *link_info;
       boolean *again;
  {
!   Elf_External_Sym_Shndx *shndx_buf;
!   Elf_Internal_Shdr *shndx_hdr;
    static asection * first_section = NULL;
    static asection * last_section = NULL;
    static boolean changed = false;
--- 762,771 ----
       struct bfd_link_info *link_info;
       boolean *again;
  {
!   Elf_Internal_Shdr *symtab_hdr;
!   Elf_Internal_Rela *internal_relocs;
!   bfd_byte *contents = NULL;
!   Elf_Internal_Sym *isymbuf = NULL;
    static asection * first_section = NULL;
    static asection * last_section = NULL;
    static boolean changed = false;
*************** ip2k_elf_relax_section (abfd, sec, link_
*** 813,845 ****
    if (pass == 1)
      last_section = sec;
  
-   misc.symtab_hdr = NULL;
-   misc.irelbase = NULL;
-   misc.contents = NULL;
-   misc.free_contents = NULL;
-   misc.extsyms = NULL;
-   misc.free_extsyms = NULL;
-   misc.free_relocs = NULL;
- 
    /* If this is the first time we have been called
        for this section, initialise the cooked size.  */
    if (sec->_cooked_size == 0)
      sec->_cooked_size = sec->_raw_size;
  
!   misc.symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
!   shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
! 
!   misc.irelbase = _bfd_elf32_link_read_relocs (abfd, sec, NULL,
! 					     (Elf_Internal_Rela *)NULL,
! 					     link_info->keep_memory);
!   if (misc.irelbase == NULL)
!     {
!       tidyup_after_error (&misc);
!       return false;
!     }
  
!   if (! link_info->keep_memory)
!     misc.free_relocs = misc.irelbase;
  
    /* Make sure the stac.rela stuff gets read in.  */
    stab = bfd_get_section_by_name (abfd, ".stab");
--- 805,822 ----
    if (pass == 1)
      last_section = sec;
  
    /* If this is the first time we have been called
        for this section, initialise the cooked size.  */
    if (sec->_cooked_size == 0)
      sec->_cooked_size = sec->_raw_size;
  
!   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
  
!   internal_relocs = _bfd_elf32_link_read_relocs (abfd, sec, NULL,
! 						 (Elf_Internal_Rela *)NULL,
! 						 link_info->keep_memory);
!   if (internal_relocs == NULL)
!     goto error_return;
  
    /* Make sure the stac.rela stuff gets read in.  */
    stab = bfd_get_section_by_name (abfd, ".stab");
*************** ip2k_elf_relax_section (abfd, sec, link_
*** 855,925 ****
      }
  
    /* Get section contents cached copy if it exists.  */
!   if (elf_section_data (sec)->this_hdr.contents != NULL)
!     misc.contents = elf_section_data (sec)->this_hdr.contents;
!   else
      {
!       /* Go get them of disk.  */
!       misc.contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
!       if (misc.contents == NULL)
! 	{
! 	  tidyup_after_error (&misc);
! 	  return false;
! 	}
! 
!       misc.free_contents = misc.contents;
!       if (! bfd_get_section_contents (abfd, sec, misc.contents,
! 				      (file_ptr)0,
! 				      sec->_raw_size))
  	{
! 	  tidyup_after_error (&misc);
! 	  return false;
  	}
      }
!   
    /* Read this BFD's symbols cached copy if it exists.  */
!   if (misc.symtab_hdr->contents != NULL)
!     misc.extsyms = (Elf32_External_Sym *) misc.symtab_hdr->contents;
!   else
      {
!       /* Go get them off disk.  */
!       misc.extsyms = ((Elf32_External_Sym *)bfd_malloc (misc.symtab_hdr->sh_size));
!       if (misc.extsyms == NULL)
! 	{
! 	  tidyup_after_error (&misc);
! 	  return false;
! 	}
! 
!       misc.free_extsyms = misc.extsyms;
!       if (bfd_seek (abfd, misc.symtab_hdr->sh_offset, SEEK_SET) != 0
!           || (bfd_read (misc.extsyms, 1, misc.symtab_hdr->sh_size, abfd)
!           != misc.symtab_hdr->sh_size))
! 	{
! 	  tidyup_after_error (&misc);
! 	  return false;
! 	}
!     }
! 
!   if (shndx_hdr->sh_size != 0)
!     {
!       bfd_size_type amt;
! 
!       amt = misc.symtab_hdr->sh_info * sizeof (Elf_External_Sym_Shndx);
!       shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
!       if (shndx_buf == NULL)
! 	{
! 	  tidyup_after_error (&misc);
! 	  return false;
! 	}
!       if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0
! 	  || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt)
! 	{
! 	  tidyup_after_error (&misc);
! 	  return false;
! 	}
!       shndx_hdr->contents = (PTR) shndx_buf;
      }
  
    /* This is where all the relaxation actually get done.  */
  
    if (pass == 1)
--- 832,872 ----
      }
  
    /* Get section contents cached copy if it exists.  */
!   if (contents == NULL)
      {
!       /* Get cached copy if it exists.  */
!       if (elf_section_data (sec)->this_hdr.contents != NULL)
! 	contents = elf_section_data (sec)->this_hdr.contents;
!       else
  	{
! 	  /* Go get them off disk.  */
! 	  contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
! 	  if (contents == NULL)
! 	    goto error_return;
! 
! 	  if (! bfd_get_section_contents (abfd, sec, contents,
! 					  (file_ptr) 0, sec->_raw_size))
! 	    goto error_return;
  	}
      }
!       
    /* Read this BFD's symbols cached copy if it exists.  */
!   if (isymbuf == NULL && symtab_hdr->sh_info != 0)
      {
!       isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
!       if (isymbuf == NULL)
! 	isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
! 					symtab_hdr->sh_info, 0,
! 					NULL, NULL, NULL);
!       if (isymbuf == NULL)
! 	goto error_return;
      }
  
+   misc.symtab_hdr = symtab_hdr;
+   misc.isymbuf = isymbuf;
+   misc.irelbase = internal_relocs;
+   misc.contents = contents;
+   
    /* This is where all the relaxation actually get done.  */
  
    if (pass == 1)
*************** ip2k_elf_relax_section (abfd, sec, link_
*** 930,939 ****
  	 we add page instructions back in as needed.  */
  
        if (! ip2k_elf_relax_section_pass1 (abfd, sec, again, &misc))
!         {
! 	  tidyup_after_error (&misc);
! 	  return false;
!         }
  
        changed |= *again;
      }
--- 877,883 ----
  	 we add page instructions back in as needed.  */
  
        if (! ip2k_elf_relax_section_pass1 (abfd, sec, again, &misc))
! 	goto error_return;
  
        changed |= *again;
      }
*************** ip2k_elf_relax_section (abfd, sec, link_
*** 957,968 ****
  	 so the we will again interate until we find a new approximate
  	 solution which is closer to the final solution.  */
  
!       if (! ip2k_elf_relax_section_passN (abfd, sec, again,
! 					 &final_pass,  &misc))
! 	{
! 	  tidyup_after_error (&misc);
! 	  return false;
! 	}
  
        changed |= *again;
  
--- 901,909 ----
  	 so the we will again interate until we find a new approximate
  	 solution which is closer to the final solution.  */
  
!       if (! ip2k_elf_relax_section_passN (abfd, sec, again, &final_pass,
! 					  &misc))
! 	goto error_return;
  
        changed |= *again;
  
*************** ip2k_elf_relax_section (abfd, sec, link_
*** 983,1046 ****
  
    /* Perform some house keeping after relaxing the section.  */  
  
!   if (misc.free_relocs != NULL)
!     {
!       free (misc.free_relocs);
!       misc.free_relocs = NULL;
!     }
! 
!   if (misc.free_contents != NULL)
      {
        if (! link_info->keep_memory)
! 	free (misc.free_contents);
        else
! 	{
! 	  /* Cache the section contents for elf_link_input_bfd.  */
! 	  elf_section_data (sec)->this_hdr.contents = misc.contents;
! 	}
! 
!       misc.free_contents = NULL;
      }
  
!   if (misc.free_extsyms != NULL)
      {
        if (! link_info->keep_memory)
! 	free (misc.free_extsyms);
        else
  	{
! 	  /* Cache the symbols for elf_link_input_bfd.  */
! 	  misc.symtab_hdr->contents = misc.extsyms;
  	}
- 
-       misc.free_extsyms = NULL;
-     }
- 
-   return true;
- }
- 
- static void
- tidyup_after_error (misc)
-      struct misc *misc;
- {
-   if (misc->free_relocs != NULL)
-     {
-       free (misc->free_relocs);
-       misc->free_relocs = NULL;
      }
  
!   if (misc->free_contents != NULL)
!     {
!       free (misc->free_contents);
!       misc->free_contents = NULL;
!     }
  
!   if (misc->free_extsyms != NULL)
!     {
!       free (misc->free_extsyms);
!       misc->free_extsyms = NULL;
!     }
  
!   return;
  }
  
  /* This function handles relaxation during the first pass.  */
--- 924,967 ----
  
    /* Perform some house keeping after relaxing the section.  */  
  
!   if (isymbuf != NULL
!       && symtab_hdr->contents != (unsigned char *) isymbuf)
      {
        if (! link_info->keep_memory)
! 	free (isymbuf);
        else
! 	symtab_hdr->contents = (unsigned char *) isymbuf;
      }
  
!   if (contents != NULL
!       && elf_section_data (sec)->this_hdr.contents != contents)
      {
        if (! link_info->keep_memory)
! 	free (contents);
        else
  	{
! 	  /* Cache the section contents for elf_link_input_bfd.  */
! 	  elf_section_data (sec)->this_hdr.contents = contents;
  	}
      }
  
!   if (internal_relocs != NULL
!       && elf_section_data (sec)->relocs != internal_relocs)
!     free (internal_relocs);
  
!   return true;
  
!  error_return:
!   if (isymbuf != NULL
!       && symtab_hdr->contents != (unsigned char *) isymbuf)
!     free (isymbuf);
!   if (contents != NULL
!       && elf_section_data (sec)->this_hdr.contents != contents)
!     free (contents);
!   if (internal_relocs != NULL
!       && elf_section_data (sec)->relocs != internal_relocs)
!     free (internal_relocs);
!   return false;
  }
  
  /* This function handles relaxation during the first pass.  */
*************** ip2k_elf_relax_section_pass1 (abfd, sec,
*** 1070,1082 ****
  	  {
  	    /* Note that we've changed the relocs, section contents, etc.  */
  	    elf_section_data (sec)->relocs = misc->irelbase;
- 	    misc->free_relocs = NULL;
- 
  	    elf_section_data (sec)->this_hdr.contents = misc->contents;
! 	    misc->free_contents = NULL;
! 
! 	    misc->symtab_hdr->contents = (bfd_byte *) misc->extsyms;
! 	    misc->free_extsyms = NULL;
  
  	    /* Handle switch dispatch tables/prologues.  */
  	    if (!  relax_switch_dispatch_tables_pass1 (abfd, sec,
--- 991,998 ----
  	  {
  	    /* Note that we've changed the relocs, section contents, etc.  */
  	    elf_section_data (sec)->relocs = misc->irelbase;
  	    elf_section_data (sec)->this_hdr.contents = misc->contents;
! 	    misc->symtab_hdr->contents = (bfd_byte *) misc->isymbuf;
  
  	    /* Handle switch dispatch tables/prologues.  */
  	    if (!  relax_switch_dispatch_tables_pass1 (abfd, sec,
*************** ip2k_elf_relax_section_passN (abfd, sec,
*** 1153,1159 ****
        if (ELF32_R_TYPE (irel->r_info) == (int) R_IP2K_ADDR16CJP)
        {
          /* Get the value of the symbol referred to by the reloc.  */
!         bfd_vma symval = symbol_value (abfd, misc->symtab_hdr, misc->extsyms,
  				       irel);
  	bfd_byte code0, code1;
  
--- 1069,1075 ----
        if (ELF32_R_TYPE (irel->r_info) == (int) R_IP2K_ADDR16CJP)
        {
          /* Get the value of the symbol referred to by the reloc.  */
!         bfd_vma symval = symbol_value (abfd, misc->symtab_hdr, misc->isymbuf,
  				       irel);
  	bfd_byte code0, code1;
  
*************** adjust_all_relocations (abfd, sec, addr,
*** 1239,1256 ****
       int noadj;
  {
    Elf_Internal_Shdr *symtab_hdr;
!   Elf32_External_Sym *extsyms;
!   int shndx, index;
    bfd_byte *contents;
    Elf_Internal_Rela *irel, *irelend, *irelbase;
!   Elf32_External_Sym *esym, *esymend;
!   asection *stab;
!   bfd_byte *stabp, *stabend, *stabcontents;
!   Elf_Internal_Shdr *shndx_hdr;
!   Elf_External_Sym_Shndx *sym_shndx;
      
    symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
!   extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
  
    shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
  
--- 1155,1170 ----
       int noadj;
  {
    Elf_Internal_Shdr *symtab_hdr;
!   Elf_Internal_Sym *isymbuf, *isym, *isymend;
!   unsigned int shndx;
    bfd_byte *contents;
    Elf_Internal_Rela *irel, *irelend, *irelbase;
!   struct elf_link_hash_entry **sym_hashes;
!   struct elf_link_hash_entry **end_hashes;
!   unsigned int symcount;
      
    symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
!   isymbuf = (Elf32_Internal_Sym *) symtab_hdr->contents;
  
    shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
  
*************** adjust_all_relocations (abfd, sec, addr,
*** 1266,1299 ****
            /* Get the value of the symbol referred to by the reloc.  */
            if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
              {
-               Elf_Internal_Sym isym;
                asection *sym_sec;
- 	      Elf_External_Sym_Shndx *sym_shndx;
- 	      Elf_Internal_Shdr *shndx_hdr;
  
                /* A local symbol.  */
! 	      
! 	      shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
! 	      sym_shndx = (Elf_External_Sym_Shndx *) shndx_hdr->contents;
! 	      sym_shndx = (sym_shndx
! 			   ? sym_shndx + ELF32_R_SYM (irel->r_info) : NULL);
!               bfd_elf32_swap_symbol_in (abfd,
! 					extsyms + ELF32_R_SYM (irel->r_info),
! 					sym_shndx, &isym);
! 
! 	      if (isym.st_shndx == SHN_UNDEF)
! 		sym_sec = bfd_und_section_ptr;
! 	      else if (isym.st_shndx == SHN_ABS)
! 		sym_sec = bfd_abs_section_ptr;
! 	      else if (isym.st_shndx == SHN_COMMON)
! 		sym_sec = bfd_com_section_ptr;
! 	      else
! 		sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
  
!               if (sym_sec == sec)
                  {
                    bfd_vma baseaddr = BASEADDR (sec);
!                   bfd_vma symval = BASEADDR (sym_sec) + isym.st_value
                                     + irel->r_addend;
  
                    if ((baseaddr + addr + noadj) <= symval
--- 1180,1195 ----
            /* Get the value of the symbol referred to by the reloc.  */
            if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
              {
                asection *sym_sec;
  
                /* A local symbol.  */
! 	      isym = isymbuf + ELF32_R_SYM (irel->r_info);
!               sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
  
!               if (isym->st_shndx == shndx)
                  {
                    bfd_vma baseaddr = BASEADDR (sec);
!                   bfd_vma symval = BASEADDR (sym_sec) + isym->st_value
                                     + irel->r_addend;
  
                    if ((baseaddr + addr + noadj) <= symval
*************** adjust_all_relocations (abfd, sec, addr,
*** 1308,1455 ****
          irel->r_offset += count;
      }
  
-   /* Now fix the stab relocations.  */
-   stab = bfd_get_section_by_name (abfd, ".stab");
-   if (stab)
-     {
-       irelbase = elf_section_data (stab)->relocs;
-       irelend = irelbase + stab->reloc_count;
- 
-       /* Pull out the contents of the stab section.  */
-       if (elf_section_data (stab)->this_hdr.contents != NULL)
- 	stabcontents = elf_section_data (stab)->this_hdr.contents;
-       else
- 	{
- 	  stabcontents = (bfd_byte *) bfd_alloc (abfd, stab->_raw_size);
- 	  if (stabcontents == NULL)
- 	    return;
- 	  if (! bfd_get_section_contents (abfd, stab, stabcontents,
- 					  (file_ptr) 0, stab->_raw_size))
- 	    return;
- 
- 	  /* We need to remember this.  */
- 	  elf_section_data (stab)->this_hdr.contents = stabcontents;
- 	}
- 
-       stabend = stabcontents + stab->_raw_size;
- 
-       for (irel = irelbase; irel < irelend; irel++)
- 	{
- 	  if (ELF32_R_TYPE (irel->r_info) != R_IP2K_NONE)
- 	    {
- 	      /* Get the value of the symbol referred to by the reloc.  */
- 	      if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
- 		{
- 		  Elf_Internal_Sym isym;
- 		  asection *sym_sec;
- 		  Elf_External_Sym_Shndx *sym_shndx;
- 		  Elf_Internal_Shdr *shndx_hdr;
- 		  
- 		  /* A local symbol.  */
- 		  shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
- 		  sym_shndx = (Elf_External_Sym_Shndx *) shndx_hdr->contents;
- 		  sym_shndx = (sym_shndx
- 			       ? sym_shndx + ELF32_R_SYM (irel->r_info)
- 			       : NULL);
- 		  
- 		  bfd_elf32_swap_symbol_in (abfd,
- 					    (extsyms
- 					     + ELF32_R_SYM (irel->r_info)),
- 					    sym_shndx, &isym);
- 		  
- 		  if (isym.st_shndx == SHN_UNDEF)
- 		    sym_sec = bfd_und_section_ptr;
- 		  else if (isym.st_shndx == SHN_ABS)
- 		    sym_sec = bfd_abs_section_ptr;
- 		  else if (isym.st_shndx == SHN_COMMON)
- 		    sym_sec = bfd_com_section_ptr;
- 		  else
- 		    sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
- 		  
- 		  if (sym_sec == sec)
- 		    {
- 		      const char *name;
- 		      unsigned long strx;
- 		      unsigned char type, other;
- 		      unsigned short desc;
- 		      bfd_vma value;
- 		      bfd_vma baseaddr = BASEADDR (sec);
- 		      bfd_vma symval = BASEADDR (sym_sec) + isym.st_value
- 			+ irel->r_addend;
- 		      
- 		      if ((baseaddr + addr) <= symval
- 			  && symval <= (baseaddr + endaddr))
- 			irel->r_addend += count;
- 
- 		      /* Go hunt up a function and fix its line info if needed.  */
- 		      stabp = stabcontents + irel->r_offset - 8; 
- 
- 		      /* Go pullout the stab entry.  */
- 		      strx = bfd_h_get_32 (abfd, stabp + STRDXOFF);
- 		      type = bfd_h_get_8 (abfd, stabp + TYPEOFF);
- 		      other = bfd_h_get_8 (abfd, stabp + OTHEROFF);
- 		      desc = bfd_h_get_16 (abfd, stabp + DESCOFF);
- 		      value = bfd_h_get_32 (abfd, stabp + VALOFF);
- 		      
- 		      name = bfd_get_stab_name (type);
- 		      
- 		      if (strcmp (name, "FUN") == 0)
- 			{
- 			  int function_adjusted = 0;
- 
- 			  if (symval > (baseaddr + addr))
- 			    /* Not in this function.  */
- 			    continue;
- 
- 			  /* Hey we got a function hit.  */
- 			  stabp += STABSIZE;
- 			  for (;stabp < stabend; stabp += STABSIZE)
- 			    {
- 			      /* Go pullout the stab entry.  */
- 			      strx = bfd_h_get_32 (abfd, stabp + STRDXOFF);
- 			      type = bfd_h_get_8 (abfd, stabp + TYPEOFF);
- 			      other = bfd_h_get_8 (abfd, stabp + OTHEROFF);
- 			      desc = bfd_h_get_16 (abfd, stabp + DESCOFF);
- 			      value = bfd_h_get_32 (abfd, stabp + VALOFF);
- 			      name = bfd_get_stab_name (type);
- 
- 			      if (strcmp (name, "FUN") == 0)
- 				{
- 				  /* Hit another function entry.  */
- 				  if (function_adjusted)
- 				    {
- 				      /* Adjust the value.  */
- 				      value += count;
- 				  
- 				      /* We need to put it back.  */
- 				      bfd_h_put_32 (abfd, value,stabp + VALOFF);
- 				    }
- 
- 				  /* And then bale out.  */
- 				  break;
- 				}
- 
- 			      if (strcmp (name, "SLINE") == 0)
- 				{
- 				  /* Got a line entry.  */
- 				  if ((baseaddr + addr) <= (symval + value))
- 				    {
- 				      /* Adjust the line entry.  */
- 				      value += count;
- 
- 				      /* We need to put it back.  */
- 				      bfd_h_put_32 (abfd, value,stabp + VALOFF);
- 				      function_adjusted = 1;
- 				    }
- 				}
- 			    }
- 			}
- 		    }
- 		}
- 	    }
- 	}
-     }
- 
    /* When adding an instruction back it is sometimes necessary to move any
       global or local symbol that was referencing the first instruction of
       the moved block to refer to the first instruction of the inserted block.
--- 1204,1209 ----
*************** adjust_all_relocations (abfd, sec, addr,
*** 1459,1513 ****
    addr += noadj;
  
    /* Adjust the local symbols defined in this section.  */
!   shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
!   sym_shndx = (Elf_External_Sym_Shndx *) shndx_hdr->contents;
!   esym = extsyms;
!   esymend = esym + symtab_hdr->sh_info;
!   for (; esym < esymend; esym++, sym_shndx = (sym_shndx ? sym_shndx + 1: NULL))
      {
!       Elf_Internal_Sym isym;
!       Elf_External_Sym_Shndx dummy;
! 
!       bfd_elf32_swap_symbol_in (abfd, esym, sym_shndx, &isym);
! 
!       if (isym.st_shndx == shndx)
!         {
!           if (addr <= isym.st_value && isym.st_value < endaddr)
!             {
!               isym.st_value += count;
!               bfd_elf32_swap_symbol_out (abfd, &isym, esym, &dummy);
!             }
!         }
!     }
! 
!   /* Now adjust the global symbols defined in this section.  */
!   shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
!   sym_shndx = (Elf_External_Sym_Shndx *) shndx_hdr->contents;
!   esym = extsyms + symtab_hdr->sh_info;
!   esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
!   for (index = 0; esym < esymend;
!        esym++, index++, sym_shndx = (sym_shndx ? sym_shndx + 1: NULL))
!     {
!       Elf_Internal_Sym isym;
!       struct elf_link_hash_entry *sym_hash;
! 
!       bfd_elf32_swap_symbol_in (abfd, esym, sym_shndx, &isym);
!       sym_hash = elf_sym_hashes (abfd)[index];
! 
!       if (isym.st_shndx == shndx
!           && (sym_hash->root.type == bfd_link_hash_defined
!               || sym_hash->root.type == bfd_link_hash_defweak)
!           && sym_hash->root.u.def.section == sec)
!         {
            if (addr <= sym_hash->root.u.def.value
                && sym_hash->root.u.def.value < endaddr)
              {
- 	      Elf_External_Sym_Shndx dummy;
- 
  	      sym_hash->root.u.def.value += count;
-               bfd_elf32_swap_symbol_out (abfd, &isym, esym, &dummy);
              }
!         }
      }
  
    return;
--- 1213,1245 ----
    addr += noadj;
  
    /* Adjust the local symbols defined in this section.  */
!   isymend = isymbuf + symtab_hdr->sh_info;
!   for (isym = isymbuf; isym < isymend; isym++)
      {
!       if (isym->st_shndx == shndx
! 	  && addr <= isym->st_value
! 	  && isym->st_value < endaddr)
! 	isym->st_value += count;
!     }
! 
!     /* Now adjust the global symbols defined in this section.  */
!   symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
! 	      - symtab_hdr->sh_info);
!   sym_hashes = elf_sym_hashes (abfd);
!   end_hashes = sym_hashes + symcount;
!   for (; sym_hashes < end_hashes; sym_hashes++)
!     {
!       struct elf_link_hash_entry *sym_hash = *sym_hashes;
!       if ((sym_hash->root.type == bfd_link_hash_defined
! 	   || sym_hash->root.type == bfd_link_hash_defweak)
! 	  && sym_hash->root.u.def.section == sec)
! 	{
            if (addr <= sym_hash->root.u.def.value
                && sym_hash->root.u.def.value < endaddr)
              {
  	      sym_hash->root.u.def.value += count;
              }
! 	}
      }
  
    return;
*************** add_page_insn (abfd, sec, irel, misc)
*** 1522,1534 ****
  {
    /* Note that we've changed the relocs, section contents, etc.  */
    elf_section_data (sec)->relocs = misc->irelbase;
-   misc->free_relocs = NULL;
- 
    elf_section_data (sec)->this_hdr.contents = misc->contents;
!   misc->free_contents = NULL;
! 
!   misc->symtab_hdr->contents = (bfd_byte *) misc->extsyms;
!   misc->free_extsyms = NULL;
  
    /* Add the PAGE insn.  */
    if (! ip2k_elf_relax_add_bytes (abfd, sec, irel->r_offset,
--- 1254,1261 ----
  {
    /* Note that we've changed the relocs, section contents, etc.  */
    elf_section_data (sec)->relocs = misc->irelbase;
    elf_section_data (sec)->this_hdr.contents = misc->contents;
!   misc->symtab_hdr->contents = (bfd_byte *) misc->isymbuf;
  
    /* Add the PAGE insn.  */
    if (! ip2k_elf_relax_add_bytes (abfd, sec, irel->r_offset,

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: LD port for ip2k
  2002-08-01 11:27     ` Denis Chertykov
@ 2002-08-01 17:56       ` Alan Modra
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Modra @ 2002-08-01 17:56 UTC (permalink / raw)
  To: Denis Chertykov; +Cc: binutils

On Thu, Aug 01, 2002 at 10:32:48PM +0400, Denis Chertykov wrote:
> 	* elf32-ip2k.c: Processor manufacturer changed to Ubicom.
> 	(struct misc): New field isymbuf. All free_* fields removed.
> 	(symbol_value): Pass in internal syms. No need to swap syms in.
> 	(ip2k_elf_relax_section): Use bfd_elf_get_elf_syms. Properly free
> 	possibly cached info.
> 	(tidyup_after_error): Removed.
> 	(ip2k_elf_relax_section_pass1): Don't use removed fields of struct
> 	misc. Use new field.
> 	(adjust_all_relocations): Use internal syms. No need to swap syms
> 	in and out.
> 	(add_page_insn): Don't use removed fields of struct misc.

Thanks for doing this!

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2002-08-02  0:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-16 11:23 LD port for ip2k Denis Chertykov
2002-07-17  7:23 ` Nick Clifton
2002-07-17  8:40   ` Denis Chertykov
2002-07-25  2:56   ` Alan Modra
2002-08-01 11:27     ` Denis Chertykov
2002-08-01 17:56       ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).