Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <richard@atheist.tamu.edu>
Subject: another bfd section layout bug
Date: Mon, 20 May 1996 02:20:26 -0500 (CDT)	[thread overview]
Message-ID: <m0uLPGV-0001v7C@atheist.tamu.edu> (raw)

Here is another bug related to those plauging strip.
This one was brought to light by the linker now doing
the right thing in the previous case.

r~

Index: ecoff.c
===================================================================
RCS file: /home/richard/Repository/cygnus/gas/bfd/ecoff.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 ecoff.c
--- ecoff.c	1996/03/23 22:46:11	1.1.1.3
+++ ecoff.c	1996/05/20 07:09:12
@@ -140,6 +140,7 @@
      bfd *abfd;
      asection *section;
 {
+#if rth_notdef
   /* For the .pdata section, which has a special meaning on the Alpha,
      we set the alignment power to 3.  We correct this later in
      ecoff_compute_section_file_positions.  We do this hackery because
@@ -151,6 +152,7 @@
   if (strcmp (section->name, _PDATA) == 0)
     section->alignment_power = 3;
   else
+#endif
     section->alignment_power = 4;
 
   if (strcmp (section->name, _TEXT) == 0)
@@ -161,7 +163,8 @@
   else if (strcmp (section->name, _RDATA) == 0
 	   || strcmp (section->name, _LIT8) == 0
 	   || strcmp (section->name, _LIT4) == 0
-	   || strcmp (section->name, _RCONST) == 0)
+	   || strcmp (section->name, _RCONST) == 0
+	   || strcmp (section->name, _PDATA) == 0)
     section->flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC | SEC_READONLY;
   else if (strcmp (section->name, _BSS) == 0
 	   || strcmp (section->name, _SBSS) == 0)
@@ -2077,12 +2080,9 @@
 	 really in the section.  Each entry is 8 bytes.  We store this
 	 away in line_filepos before increasing the section size.  */
       if (strcmp (current->name, _PDATA) != 0)
-	alignment_power = current->alignment_power;
-      else
-	{
-	  current->line_filepos = current->_raw_size / 8;
-	  alignment_power = 4;
-	}
+	current->line_filepos = current->_raw_size / 8;
+
+      alignment_power = current->alignment_power;
 
       /* On Ultrix, the data sections in an executable file must be
 	 aligned to a page boundary within the file.  This does not
@@ -2126,6 +2126,13 @@
       old_sofar = sofar;
       sofar = BFD_ALIGN (sofar, 1 << alignment_power);
 
+      /* Expand the previous section to our alignment boundary
+	 so that, e.g, text size calculations work.
+	 FIXME: This seems stupid.  Wouldn't it be better to
+	 calculate text sizes from differences of filepos? -- r~ */
+      if (i > 0)
+	  sorted_hdrs[i-1]->_raw_size += sofar - old_sofar;
+
       if ((abfd->flags & D_PAGED) != 0
 	  && (current->flags & SEC_ALLOC) != 0)
 	sofar += (current->vma - sofar) % round;
@@ -2134,11 +2141,6 @@
 	current->filepos = sofar;
 
       sofar += current->_raw_size;
-
-      /* make sure that this section is of the right size too */
-      old_sofar = sofar;
-      sofar = BFD_ALIGN (sofar, 1 << alignment_power);
-      current->_raw_size += sofar - old_sofar;
     }
 
   free (sorted_hdrs);

                 reply	other threads:[~1996-05-20  7:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox