atgreen / ggx

How To Retarget the GNU Toolchain in 21 Patches
82 stars 15 forks source link

Binutils seems to be missing a diff? #2

Open neozeed opened 3 years ago

neozeed commented 3 years ago

I'm just starting the voyage of building the toolchain.. Since it's dated 2007 I'm using the following packages:

This seems to put things where they ought to be...?

tar -zxvf binutils-2.18.tar.gz
cd binutils-2.18
tar -zxvf ../gdb-6.6a.tar.gz
mv gdb-6.6/sim .
mv gdb-6.6/gdb .
rm -rf gdb-6.6
tar -zxvf ../newlib-1.16.0.tar.gz
mv newlib-1.16.0/libgloss .
mv newlib-1.16.0/newlib .
rm -rf newlib-1.16.0

ggx-binutilspatches.tar.gz Anyways I gathered the patches, and use a simple script to apply them all, and I noticed the Changelog of all things fails:

$ cat sim/ggx/ChangeLog.rej
--- sim/ggx/ChangeLog   Mon Mar 24 17:27:34 2008 -0700
+++ sim/ggx/ChangeLog   Tue Mar 25 08:10:07 2008 -0700
@@ -1,3 +1,8 @@ 2008-03-23  Anthony Green  <green@spinda
+2008-03-24  Anthony Green  <green@spindazzle.org>
+
+       * interp.c (sim_resume): Add missing breaks.
+       (sim_resume): Fix neg implementation.
+
 2008-03-23  Anthony Green  <green@spindazzle.org>

        * interp.c (sim_load): Don't require a .bss section.

So it looks like the 03-23 change is missing?

Anyways here is a log of me applying the 19 patches:

$ ../bindiff.sh
patching file ChangeLog.ggx
patching file config.sub
patching file configure
Hunk #2 succeeded at 2305 (offset -19 lines).
patching file configure.ac
Hunk #2 succeeded at 584 (offset -18 lines).
1
patching file ChangeLog.ggx
patching file bfd/ChangeLog.ggx
patching file bfd/Makefile.am
Hunk #3 succeeded at 255 (offset -2 lines).
Hunk #4 succeeded at 435 (offset -4 lines).
Hunk #5 succeeded at 1073 (offset -12 lines).
Hunk #6 succeeded at 1364 (offset -22 lines).
patching file bfd/Makefile.in
Hunk #1 succeeded at 322 (offset -1 lines).
Hunk #2 succeeded at 389 (offset -1 lines).
Hunk #3 succeeded at 505 (offset -3 lines).
Hunk #4 succeeded at 685 (offset -5 lines).
Hunk #5 succeeded at 1653 (offset -13 lines).
Hunk #6 succeeded at 1944 (offset -23 lines).
patching file bfd/archures.c
Hunk #1 succeeded at 321 (offset -6 lines).
Hunk #2 succeeded at 450 (offset -6 lines).
Hunk #3 succeeded at 522 (offset -6 lines).
patching file bfd/bfd-in2.h
Hunk #1 succeeded at 1992 (offset -12 lines).
patching file bfd/config.bfd
Hunk #1 succeeded at 407 (offset -1 lines).
patching file bfd/configure
Hunk #1 succeeded at 19065 (offset 15 lines).
patching file bfd/configure.in
Hunk #1 succeeded at 643 (offset -16 lines).
patching file bfd/cpu-ggx.c
patching file bfd/elf32-ggx.c
patching file bfd/targets.c
Hunk #1 succeeded at 583 (offset -6 lines).
Hunk #2 succeeded at 909 (offset -12 lines).
patching file configure
Hunk #1 succeeded at 2308 (offset -19 lines).
patching file configure.ac
Hunk #1 succeeded at 587 (offset -18 lines).
patching file include/elf/ChangeLog.ggx
patching file include/elf/common.h
patching file include/elf/ggx.h
2
patching file ChangeLog.ggx
patching file configure
Hunk #1 succeeded at 2308 (offset -19 lines).
patching file configure.ac
Hunk #1 succeeded at 587 (offset -18 lines).
patching file include/dis-asm.h
patching file include/opcode/ChangeLog.ggx
patching file include/opcode/ggx.h
patching file opcodes/ChangeLog.ggx
patching file opcodes/Makefile.am
Hunk #1 succeeded at 92 (offset -1 lines).
Hunk #2 succeeded at 245 (offset -1 lines).
Hunk #3 succeeded at 789 (offset -5 lines).
patching file opcodes/Makefile.in
Hunk #1 succeeded at 320 (offset -2 lines).
Hunk #2 succeeded at 473 (offset -2 lines).
Hunk #3 succeeded at 1340 (offset -6 lines).
patching file opcodes/configure
Hunk #1 succeeded at 11427 (offset -104 lines).
patching file opcodes/configure.in
Hunk #1 succeeded at 167 (offset -18 lines).
patching file opcodes/disassemble.c
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
3
patching file ChangeLog.ggx
patching file configure
Hunk #1 succeeded at 2308 (offset -19 lines).
patching file configure.ac
Hunk #1 succeeded at 587 (offset -18 lines).
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file gas/config/tc-ggx.h
patching file gas/configure
Hunk #1 succeeded at 10339 (offset -746 lines).
patching file gas/configure.tgt
4
patching file ChangeLog.ggx
patching file configure
Hunk #1 succeeded at 2308 (offset -19 lines).
patching file configure.ac
Hunk #1 succeeded at 587 (offset -18 lines).
5
patching file ChangeLog.ggx
patching file configure
Hunk #1 succeeded at 2308 (offset -19 lines).
patching file configure.ac
Hunk #1 succeeded at 587 (offset -18 lines).
patching file ld/ChangeLog.ggx
patching file ld/Makefile.am
patching file ld/Makefile.in
patching file ld/configure.tgt
patching file ld/emulparams/elf32ggx.sh
patching file ld/scripttempl/ggx.sc
6
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file include/opcode/ChangeLog.ggx
patching file include/opcode/ggx.h
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
7
patching file bfd/ChangeLog.ggx
patching file bfd/elf32-ggx.c
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file gas/config/tc-ggx.h
patching file include/elf/ChangeLog.ggx
patching file include/elf/ggx.h
patching file include/opcode/ChangeLog.ggx
patching file include/opcode/ggx.h
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
8
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
9
patching file ChangeLog.ggx
patching file configure
Hunk #1 succeeded at 2307 (offset -19 lines).
patching file configure.ac
Hunk #1 succeeded at 586 (offset -18 lines).
patching file sim/configure
Hunk #2 succeeded at 3443 with fuzz 1 (offset 2 lines).
patching file sim/configure.ac
Hunk #1 succeeded at 62 with fuzz 2 (offset 2 lines).
patching file sim/ggx/ChangeLog
patching file sim/ggx/Makefile.in
patching file sim/ggx/config.in
patching file sim/ggx/configure
patching file sim/ggx/configure.ac
patching file sim/ggx/interp.c
patching file sim/ggx/sysdep.h
10
patching file bfd/elf32-ggx.c
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file include/elf/ggx.h
patching file include/opcode/ChangeLog.ggx
patching file include/opcode/ggx.h
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
patching file sim/ggx/ChangeLog
patching file sim/ggx/interp.c
11
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
patching file sim/ggx/ChangeLog
patching file sim/ggx/interp.c
12
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file include/opcode/ChangeLog.ggx
patching file include/opcode/ggx.h
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
patching file sim/ggx/ChangeLog
patching file sim/ggx/interp.c
13
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file include/opcode/ChangeLog.ggx
patching file include/opcode/ggx.h
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
patching file sim/ggx/interp.c
14
patching file gas/ChangeLog.ggx
patching file gas/config/tc-ggx.c
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
patching file sim/ggx/ChangeLog
patching file sim/ggx/interp.c
15
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-opc.c
patching file sim/ggx/ChangeLog
patching file sim/ggx/interp.c
16
patching file libgloss/configure
patching file libgloss/configure.in
patching file libgloss/ggx/CVS/Entries
patching file libgloss/ggx/CVS/Repository
patching file libgloss/ggx/CVS/Root
patching file libgloss/ggx/Makefile.in
patching file libgloss/ggx/aclocal.m4
patching file libgloss/ggx/configure
patching file libgloss/ggx/configure.in
patching file libgloss/ggx/crt0.S
patching file libgloss/ggx/fstat.c
patching file libgloss/ggx/getpid.c
patching file libgloss/ggx/isatty.c
patching file libgloss/ggx/kill.c
patching file libgloss/ggx/print.c
patching file libgloss/ggx/putnum.c
patching file libgloss/ggx/sbrk.c
patching file libgloss/ggx/sim-close.S
patching file libgloss/ggx/sim-exit.S
patching file libgloss/ggx/sim-inbyte.c
patching file libgloss/ggx/sim-lseek.S
patching file libgloss/ggx/sim-lseek.c
patching file libgloss/ggx/sim-open.S
patching file libgloss/ggx/sim-read.S
patching file libgloss/ggx/sim-time.c
patching file libgloss/ggx/sim-unlink.S
patching file libgloss/ggx/sim-write.S
patching file libgloss/ggx/stat.c
patching file newlib/configure.host
Hunk #3 succeeded at 610 (offset -1 lines).
patching file newlib/libc/include/machine/ieeefp.h
patching file newlib/libc/machine/configure
patching file newlib/libc/machine/configure.in
patching file newlib/libc/machine/ggx/CVS/Entries
patching file newlib/libc/machine/ggx/CVS/Repository
patching file newlib/libc/machine/ggx/CVS/Root
patching file newlib/libc/machine/ggx/Makefile.am
patching file newlib/libc/machine/ggx/Makefile.in
patching file newlib/libc/machine/ggx/aclocal.m4
patching file newlib/libc/machine/ggx/configure
patching file newlib/libc/machine/ggx/configure.in
patching file newlib/libc/machine/ggx/setjmp.S
17
patching file bfd/ChangeLog.ggx
patching file bfd/elf32-ggx.c
patching file bfd/reloc.c
patching file gas/config/tc-ggx.c
patching file include/elf/ChangeLog.ggx
patching file include/elf/ggx.h
patching file ld/emulparams/elf32ggx.sh
patching file opcodes/ChangeLog.ggx
patching file opcodes/ggx-dis.c
patching file opcodes/ggx-opc.c
patching file sim/ggx/ChangeLog
patching file sim/ggx/interp.c
18
patching file newlib/libc/include/machine/setjmp.h
patching file newlib/libc/machine/ggx/setjmp.S
patching file sim/ggx/ChangeLog
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file sim/ggx/ChangeLog.rej
patching file sim/ggx/interp.c
Hunk #1 succeeded at 1064 (offset 1 line).
Hunk #2 succeeded at 1175 (offset 1 line).
Hunk #3 succeeded at 1186 (offset 1 line).
Hunk #4 succeeded at 1318 (offset 1 line).
Hunk #5 succeeded at 1327 (offset 1 line).
19
neozeed commented 3 years ago

Looks like I found the 'so far' patch which includes the full interp.c here: all-so-far.patch.txt

Not sure why it's changing the pc, but it clearly removes the .bss check

 diff -ruN interp.c ../../../interp.c |more
--- interp.c    2021-08-26 08:59:58.112051400 +0800
+++ ../../../interp.c   2021-08-29 15:20:51.159402200 +0800
@@ -31,7 +31,6 @@
 typedef int word;
 typedef unsigned int uword;

-static unsigned long  heap_ptr = 0;
 host_callback *       callback;

 #define EXTRACT_WORD(addr) (((addr)[0] << 24) \
@@ -94,13 +93,13 @@
    Simulation speed is deemed more important.  */

 #define NUM_GGX_REGS 8
+#define PC_REGNO     8

 /* The ordering of the ggx_regset structure is matched in the
    gdb/config/ggx/tm-ggx.h file in the REGISTER_NAMES macro.  */
 struct ggx_regset
 {
-  word           regs[NUM_GGX_REGS];   /* primary registers */
-  word           pc;                   /* the program counter */
+  word           regs[NUM_GGX_REGS + 1]; /* primary registers */
   word            cc;                   /* the condition code reg */
   int            exception;
   unsigned long   msize;
@@ -175,7 +174,7 @@
   init_pointers ();

   /* Set up machine just out of reset.  */
-  cpu.asregs.pc = 0;
+  cpu.asregs.regs[PC_REGNO] = 0;

   memsize = cpu.asregs.msize / (1024 * 1024);

@@ -375,7 +374,7 @@

   sigsave = signal (SIGINT, interrupt);
   cpu.asregs.exception = step ? SIGTRAP: 0;
-  pc = cpu.asregs.pc;
+  pc = cpu.asregs.regs[PC_REGNO];
   insts = cpu.asregs.insts;
   unsigned char *memory = cpu.asregs.memory;

@@ -1216,7 +1215,7 @@
     } while (!cpu.asregs.exception);

   /* Hide away the things we've cached while executing.  */
-  cpu.asregs.pc = pc;
+  cpu.asregs.regs[PC_REGNO] = pc;
   cpu.asregs.insts += insts;           /* instructions done ... */

   signal (SIGINT, sigsave);
@@ -1407,7 +1406,6 @@

   {
     bfd * handle;
-    asection * s_bss;
     handle = bfd_openr (prog, 0);      /* could be "ggx" */

     if (!handle)
@@ -1426,26 +1424,8 @@
        return SIM_RC_FAIL;
       }

-    /* Look for that bss section.  */
-    s_bss = bfd_get_section_by_name (handle, ".bss");
-
-    if (!s_bss)
-      {
-       printf("``%s'' has no bss section.\n", prog);
-       return SIM_RC_FAIL;
-      }
-
-    /* Appropriately paranoid would check that we have
-       a traditional text/data/bss ordering within memory.  */
-
-    /* figure the end of the bss section */
-    heap_ptr = ((unsigned long) bfd_get_section_vma (handle, s_bss)
-               + (unsigned long) bfd_section_size (handle, s_bss));
-
     /* Clean up after ourselves.  */
     bfd_close (handle);
-
-    /* XXX: do we need to free the s_bss and handle structures? */
   }

   /* from sh -- dac */
@@ -1477,7 +1457,7 @@
   set_initial_gprs ();
   issue_messages = l;

-  cpu.asregs.pc = bfd_get_start_address (prog_bfd);
+  cpu.asregs.regs[PC_REGNO] = bfd_get_start_address (prog_bfd);

   return SIM_RC_OK;
 }