This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Add v850 linker relaxation
Hi Alan,
> See http://sources.redhat.com/ml/binutils/2002-07/msg00670.html
> My gripe applies here too.
You mean the freeing of the relocs ? How about this patch ?
Cheers
Nick
2002-08-29 Nick Clifton <nickc@redhat.com>
* elf32-v850.c (v850_elf_relax_section): Properly free cached
info.
Index: bfd/elf32-v850.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-v850.c,v
retrieving revision 1.25
diff -c -3 -p -w -r1.25 elf32-v850.c
*** bfd/elf32-v850.c 29 Aug 2002 06:49:33 -0000 1.25
--- bfd/elf32-v850.c 29 Aug 2002 15:39:28 -0000
*************** v850_elf_relax_section (abfd, sec, link_
*** 2481,2499 ****
{
Elf_Internal_Shdr * symtab_hdr;
Elf_Internal_Rela * internal_relocs;
- Elf_Internal_Rela * free_relocs = NULL;
Elf_Internal_Rela * irel;
Elf_Internal_Rela * irelend;
Elf_Internal_Rela * irelalign = NULL;
bfd_byte * contents = NULL;
- bfd_byte * free_contents = NULL;
Elf32_External_Sym * extsyms = NULL;
- Elf32_External_Sym * free_extsyms = NULL;
bfd_vma addr = 0;
bfd_vma toaddr;
int align_pad_size = 0;
Elf_Internal_Shdr * shndx_hdr = NULL;
Elf_External_Sym_Shndx * shndx_buf = NULL;
* again = false;
--- 2481,2497 ----
{
Elf_Internal_Shdr * symtab_hdr;
Elf_Internal_Rela * internal_relocs;
Elf_Internal_Rela * irel;
Elf_Internal_Rela * irelend;
Elf_Internal_Rela * irelalign = NULL;
bfd_byte * contents = NULL;
Elf32_External_Sym * extsyms = NULL;
bfd_vma addr = 0;
bfd_vma toaddr;
int align_pad_size = 0;
Elf_Internal_Shdr * shndx_hdr = NULL;
Elf_External_Sym_Shndx * shndx_buf = NULL;
+ boolean result = true;
* again = false;
*************** v850_elf_relax_section (abfd, sec, link_
*** 2514,2521 ****
link_info->keep_memory));
if (internal_relocs == NULL)
goto error_return;
- if (! link_info->keep_memory)
- free_relocs = internal_relocs;
irelend = internal_relocs + sec->reloc_count;
--- 2512,2517 ----
*************** v850_elf_relax_section (abfd, sec, link_
*** 2599,2606 ****
if (contents == NULL)
goto error_return;
- free_contents = contents;
-
if (! bfd_get_section_contents (abfd, sec, contents,
(file_ptr) 0, sec->_raw_size))
goto error_return;
--- 2595,2600 ----
*************** v850_elf_relax_section (abfd, sec, link_
*** 2623,2629 ****
extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
- free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
|| bfd_bread ((PTR) extsyms, amt, abfd) != amt)
goto error_return;
--- 2617,2622 ----
*************** v850_elf_relax_section (abfd, sec, link_
*** 2861,2873 ****
that would be more work, but would require less memory when
the linker is run. */
elf_section_data (sec)->relocs = internal_relocs;
- free_relocs = NULL;
elf_section_data (sec)->this_hdr.contents = contents;
- free_contents = NULL;
symtab_hdr->contents = (bfd_byte *) extsyms;
- free_extsyms = NULL;
/* Replace the long call with a jarl. */
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (hi_irelfn->r_info), R_V850_22_PCREL);
--- 2854,2863 ----
*************** v850_elf_relax_section (abfd, sec, link_
*** 3058,3070 ****
that would be more work, but would require less memory when
the linker is run. */
elf_section_data (sec)->relocs = internal_relocs;
- free_relocs = NULL;
elf_section_data (sec)->this_hdr.contents = contents;
- free_contents = NULL;
symtab_hdr->contents = (bfd_byte *) extsyms;
- free_extsyms = NULL;
if (foff < -0x100 || foff >= 0x100)
{
--- 3048,3057 ----
*************** v850_elf_relax_section (abfd, sec, link_
*** 3162,3180 ****
sec->_cooked_size -= align_pad_size;
}
! return true;
!
! error_return:
! if (free_relocs != NULL)
! free (free_relocs);
!
! if (free_contents != NULL)
! free (free_contents);
! if (free_extsyms != NULL)
! free (free_extsyms);
! return false;
}
#define TARGET_LITTLE_SYM bfd_elf32_v850_vec
--- 3149,3172 ----
sec->_cooked_size -= align_pad_size;
}
! finish:
! if (internal_relocs != NULL
! && elf_section_data (sec)->relocs != internal_relocs)
! free (internal_relocs);
!
! if (contents != NULL
! && elf_section_data (sec)->this_hdr.contents != (unsigned char *) contents)
! free (contents);
!
! if (extsyms != NULL
! && symtab_hdr->contents != (bfd_byte *) extsyms)
! free (extsyms);
! return result;
! error_return:
! result = false;
! goto finish;
}
#define TARGET_LITTLE_SYM bfd_elf32_v850_vec