]> git.wh0rd.org Git - elf2flt.git/commitdiff
The patch below teaches elf2flt to handle R_68K_PC16 relocs.
authorDavid McCullough <davidm@snapgear.com>
Tue, 23 May 2006 22:28:31 +0000 (22:28 +0000)
committerDavid McCullough <davidm@snapgear.com>
Tue, 23 May 2006 22:28:31 +0000 (22:28 +0000)
Our immediate need for this was to deal with relocs for uClibc's
libc/sysdeps/linux/m68k/clone.S, which has "bcc.w __syscall_error"
instructions.  It might be argued that clone.S should be using jbcc
instead, in case __syscall_error ends up too far away.  But even if
that's true, elf2flt should still support such branches in cases
whether the user _knows_ that the target is within range.
So I think elf2flt should be patched either way.

We've been using this patch for a while now without problems.
Please install if OK.

Richard

Signed-off-by: Richard Sandiford <richard@codesourcery.com>
elf2flt.c

index cff6cb3fc9168f477198957b0a00151e45d59c0c..0afe1242bbbef8fbfbdd4d3006dca7c87db1bb3f 100644 (file)
--- a/elf2flt.c
+++ b/elf2flt.c
@@ -845,7 +845,7 @@ dump_symbols(symbols, number_of_symbols);
                                /* Calculate the sym address ourselves.  */
                                sym_reloc_size = bfd_get_reloc_size(q->howto);
 
-#if !defined(TARGET_h8300) && !defined(TARGET_e1) && !defined(TARGET_bfin)
+#if !defined(TARGET_h8300) && !defined(TARGET_e1) && !defined(TARGET_bfin) && !defined(TARGET_m68k)
                                if (sym_reloc_size != 4) {
                                        printf("ERROR: bad reloc type %d size=%d for symbol=%s\n",
                                                        (*p)->howto->type, sym_reloc_size, sym_name);
@@ -863,6 +863,7 @@ dump_symbols(symbols, number_of_symbols);
                                        sym_vma = bfd_section_vma(abs_bfd, sym_section);
                                        sym_addr += sym_vma + q->addend;
                                        break;
+                               case R_68K_PC16:
                                case R_68K_PC32:
                                        sym_vma = 0;
                                        sym_addr += sym_vma + q->addend;
@@ -1739,6 +1740,18 @@ DIS29_RELOCATION:
                                        break;
 #endif /* TARGET_nios2 */
 
+#if defined(TARGET_m68k)
+                               case R_68K_PC16:
+                                       if (sym_addr < -0x8000 || sym_addr > 0x7fff) {
+                                               fprintf (stderr, "Relocation overflow for R_68K_PC16 relocation against %s\n", sym_name);
+                                               bad_relocs++;
+                                       } else {
+                                               r_mem[0] = (sym_addr >>  8) & 0xff;
+                                               r_mem[1] =  sym_addr        & 0xff;
+                                       }
+                                       break;
+#endif
+
                                default:
                                        /* The alignment of the build host
                                           might be stricter than that of the