From d675782a06250d9f0b6d17cfa3be850634ffc27f Mon Sep 17 00:00:00 2001
From: Ken Raeburn <raeburn@cygnus>
Date: Tue, 20 Dec 1994 20:07:41 +0000
Subject: [PATCH] * config/obj-aout.h, config/obj-coff.c, config/obj-elf.h,
 config/obj-som.h, config/tc-h8500.c, config/tc-hppa.c, config/tc-hppa.h,
 config/tc-sh.c, config/tc-z8k.c: Don't rely on use of ".." when including
 header files. * config/tc-rce.c: Ditto.

* config/obj-coff.c (fixup_segment): Reformat condition in an `if' statement.
---
 gas/ChangeLog         | 11 +++++++++++
 gas/config/obj-coff.c | 34 +++++++++++++++++++++++-----------
 gas/config/tc-h8500.c |  2 +-
 gas/config/tc-hppa.c  |  4 ++--
 gas/config/tc-rce.c   |  2 +-
 5 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 75ecc1fb2c2..82d344bcd02 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,16 @@
 Tue Dec 20 14:56:31 1994  Ken Raeburn  <raeburn@cujo.cygnus.com>
 
+	* config/obj-aout.h, config/obj-coff.c, config/obj-elf.h,
+	config/obj-som.h, config/tc-h8500.c, config/tc-hppa.c,
+	config/tc-hppa.h, config/tc-sh.c, config/tc-z8k.c: Don't rely on
+	use of ".." when including header files.
+start-sanitize-rce
+	* config/tc-rce.c: Ditto.
+end-sanitize-rce
+
+	* config/obj-coff.c (fixup_segment): Reformat condition in an `if'
+	statement.
+
 	* Makefile.in (SUBDIR_INCLUDES): Deleted.
 
 Tue Dec 20 13:40:36 1994  Ian Lance Taylor  <ian@sanguine.cygnus.com>
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index 41e3b0af777..b263fe3394f 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -1014,18 +1014,23 @@ coff_frob_symbol (symp, punt)
 
   if (coffsymbol (symp->bsym)->lineno)
     {
-      int i, n;
+      int i;
       struct line_no *lptr;
       alent *l;
 
       lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
       for (i = 0; lptr; lptr = lptr->next)
 	i++;
-      n = i + 1;
       lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
-      l = (alent *) bfd_alloc_by_size_t (stdoutput, n * sizeof (alent));
+
+      /* We need i entries for line numbers, plus 1 for the first
+	 entry which BFD will override, plus 1 for the last zero
+	 entry (a marker for BFD).  */
+      l = (alent *) bfd_alloc_by_size_t (stdoutput, (i + 2) * sizeof (alent));
       coffsymbol (symp->bsym)->lineno = l;
-      for (i = n - 1; i > 0; i--)
+      l[i + 1].line_number = 0;
+      l[i + 1].u.sym = NULL;
+      for (; i > 0; i--)
 	{
 	  if (lptr->frag)
 	    lptr->l.u.offset += lptr->frag->fr_address;
@@ -1045,6 +1050,11 @@ coff_adjust_section_syms (abfd, sec, x)
   segment_info_type *seginfo = seg_info (sec);
   int nlnno, nrelocs = 0;
 
+  /* RS/6000 gas creates a .debug section manually in ppc_frob_file in
+     tc-ppc.c.  Do not get confused by it.  */
+  if (seginfo == NULL)
+    return;
+
   if (!strcmp (sec->name, ".text"))
     nlnno = n_line_nos;
   else
@@ -1291,8 +1301,8 @@ symbol_dump ()
 #include "frags.h"
 /* This is needed because we include internal bfd things. */
 #include <time.h>
-#include "../bfd/libbfd.h"
-#include "../bfd/libcoff.h"
+#include "bfd/libbfd.h"
+#include "bfd/libcoff.h"
 
 /* The NOP_OPCODE is for the alignment fill value.  Fill with nop so
    that we can stick sections together without causing trouble.  */
@@ -3687,16 +3697,18 @@ fixup_segment (segP, this_segment_type)
 #ifndef TC_M88K
 	  /* The m88k uses the offset field of the reloc to get around
 	     this problem.  */
-	  if ((size == 1 &&
-	  (add_number & ~0xFF) && ((add_number & ~0xFF) != (-1 & ~0xFF))) ||
-	      (size == 2 &&
-	       (add_number & ~0xFFFF) && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF))))
+	  if ((size == 1
+	       && (add_number & ~0xFF)
+	       && ((add_number & ~0xFF) != (-1 & ~0xFF)))
+	      || (size == 2
+		  && (add_number & ~0xFFFF)
+		  && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF))))
 	    {
 	      as_bad_where (fixP->fx_file, fixP->fx_line,
 			    "Value of %ld too large for field of %d bytes at 0x%lx",
 			    (long) add_number, size,
 			    (unsigned long) (fragP->fr_address + where));
-	    }			/* generic error checking */
+	    }
 #endif
 #ifdef WARN_SIGNED_OVERFLOW_WORD
 	  /* Warn if a .word value is too large when treated as
diff --git a/gas/config/tc-h8500.c b/gas/config/tc-h8500.c
index 3e3196c055a..bf8bae0a8dd 100644
--- a/gas/config/tc-h8500.c
+++ b/gas/config/tc-h8500.c
@@ -28,7 +28,7 @@
 #include "subsegs.h"
 #define DEFINE_TABLE
 #define ASSEMBLER_TABLE
-#include "../opcodes/h8500-opc.h"
+#include "opcodes/h8500-opc.h"
 #include <ctype.h>
 
 const char comment_chars[] = "!";
diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c
index 976b76a863f..d0806fb0be0 100644
--- a/gas/config/tc-hppa.c
+++ b/gas/config/tc-hppa.c
@@ -27,8 +27,8 @@
 #include "as.h"
 #include "subsegs.h"
 
-#include "../bfd/libhppa.h"
-#include "../bfd/libbfd.h"
+#include "bfd/libhppa.h"
+#include "bfd/libbfd.h"
 
 /* Be careful, this file includes data *declarations*.  */
 #include "opcode/hppa.h"
diff --git a/gas/config/tc-rce.c b/gas/config/tc-rce.c
index 700f9a1a94c..cd1048d9a97 100644
--- a/gas/config/tc-rce.c
+++ b/gas/config/tc-rce.c
@@ -28,7 +28,7 @@
 #include "bfd.h"
 #include "subsegs.h"
 #define DEFINE_TABLE
-#include "../opcodes/rce-opc.h"
+#include "opcodes/rce-opc.h"
 #include <ctype.h>
 #include <string.h>