This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Clean up platform-specific code in gas/write.c
- To: law at cygnus dot com
- Subject: Re: Clean up platform-specific code in gas/write.c
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 19 Aug 2000 20:25:44 -0300
- Cc: binutils at sources dot redhat dot com
- Organization: GCC Team, Red Hat
- References: <26772.966555964@upchuck><orlmxti3it.fsf@guarana.lsd.ic.unicamp.br>
On Aug 19, 2000, Alexandre Oliva <aoliva@redhat.com> wrote:
> I've been playing with deferring PCREL relocations of non_adjustable
> symbols to the linker on SH, and found not only a couple of
> limitations in the SH linker (patch to follow)
Here it is. Ok to install?
Index: bfd/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* elf32-sh.c (sh_elf_relocate_section) [R_SH_IND12W,
R_SH_DIR8WPN, R_SH_DIR8WPZ, R_SH_DIR8WPL]: Handle them
explicitly. Improve validation of r_type.
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.14
diff -u -p -r1.14 elf32-sh.c
--- bfd/elf32-sh.c 2000/08/11 14:35:41 1.14
+++ bfd/elf32-sh.c 2000/08/19 23:24:58
@@ -1884,6 +1884,7 @@ sh_elf_relocate_section (output_bfd, inf
continue;
if (r_type < 0
+ || r_type >= R_SH_max
|| (r_type >= (int) R_SH_FIRST_INVALID_RELOC
&& r_type <= (int) R_SH_LAST_INVALID_RELOC))
{
@@ -1891,14 +1892,6 @@ sh_elf_relocate_section (output_bfd, inf
return false;
}
- /* FIXME: This is certainly incorrect. However, it is how the
- COFF linker works. */
- if (r_type != (int) R_SH_DIR32
- && r_type != (int) R_SH_IND12W
- && r_type != (int) R_SH_LOOP_START
- && r_type != (int) R_SH_LOOP_END)
- continue;
-
howto = sh_elf_howto_table + r_type;
/* This is a final link. */
@@ -1907,11 +1900,6 @@ sh_elf_relocate_section (output_bfd, inf
sec = NULL;
if (r_symndx < symtab_hdr->sh_info)
{
- /* There is nothing to be done for an internal IND12W
- relocation. FIXME: This is probably wrong, but it's how
- the COFF relocations work. */
- if (r_type == (int) R_SH_IND12W)
- continue;
sym = local_syms + r_symndx;
sec = local_sections[r_symndx];
relocation = (sec->output_section->vma
@@ -1944,22 +1932,34 @@ sh_elf_relocate_section (output_bfd, inf
}
}
- /* FIXME: This is how the COFF relocations work. */
- if (r_type == (int) R_SH_IND12W)
- relocation -= 4;
-
switch ((int)r_type)
{
- case (int)R_SH_DIR32:
- addend = rel->r_addend;
- /* Fall through. */
- default:
+ final_link_relocate:
/* COFF relocs don't use the addend. The addend is used for
R_SH_DIR32 to be compatible with other compilers. */
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
contents, rel->r_offset,
relocation, addend);
break;
+
+ case R_SH_IND12W:
+ case R_SH_DIR8WPN:
+ case R_SH_DIR8WPZ:
+ case R_SH_DIR8WPL:
+ /* These should normally be handled by the assembler, but at
+ least IND12W is generated by ourselves, so we must deal
+ with it. */
+ relocation -= 4;
+ goto final_link_relocate;
+
+ default:
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+
+ case R_SH_DIR32:
+ addend = rel->r_addend;
+ goto final_link_relocate;
+
case R_SH_LOOP_START:
{
static bfd_vma start, end;
@@ -1969,6 +1969,7 @@ sh_elf_relocate_section (output_bfd, inf
r = sh_elf_reloc_loop (r_type, input_bfd, input_section, contents,
rel->r_offset, sec, start, end);
break;
+
case R_SH_LOOP_END:
end = (relocation + rel->r_addend
- (sec->output_section->vma + sec->output_offset));
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me