www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/08/09/14:26:07

Message-Id: <199908091312.NAA13038@out2.ibm.net>
From: "Mark E." <snowball3 AT bigfoot DOT com>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>, djgpp-workers AT delorie DOT com,
pavenis AT lanet DOT lv
Date: Mon, 9 Aug 1999 09:13:12 -0400
MIME-Version: 1.0
Subject: Re: Performance regression of 2.95 vs. 2.7, x86, loop-related (fwd)
References: <199908091202 DOT MAA18292 AT out1 DOT ibm DOT net>
In-reply-to: <Pine.SUN.3.91.990809151150.2359H-100000@is>
X-mailer: Pegasus Mail for Win32 (v3.11)
Reply-To: djgpp-workers AT delorie DOT com

> Great!
> 
> Is the 16-byte alignment patch for one file?  If so, could you tell 
> its name?  If not, perhaps you could post that patch here?
> 

I extracted the checked in version of the patch from cvs, which is slightly 
different from the version I posted to binutils. If you intend to back port the 
change to 2.9.1, leave out the references to .gnu.linkonce since they don't apply.

Index: binutils/bfd/coffcode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coffcode.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -c -r1.10 -r1.11
*** coffcode.h	1999/08/08 16:50:27	1.10
--- coffcode.h	1999/08/09 02:56:16	1.11
***************
*** 315,320 ****
--- 315,323 ----
  static long sec_to_styp_flags PARAMS ((const char *, flagword));
  static flagword styp_to_sec_flags PARAMS ((bfd *, PTR, const char *));
  static boolean coff_bad_format_hook PARAMS ((bfd *, PTR));
+ static void coff_set_custom_section_alignment
+   PARAMS ((bfd *, asection *, const struct coff_section_alignment_entry *,
+ 	   unsigned int));
  static boolean coff_new_section_hook PARAMS ((bfd *, asection *));
  static boolean coff_set_arch_mach_hook PARAMS ((bfd *, PTR));
  static boolean coff_write_relocs PARAMS ((bfd *, int));
***************
*** 1076,1090 ****
    return true;
  }
  
! /*
!    initialize a section structure with information peculiar to this
!    particular implementation of coff
! */
  
  static boolean
  coff_new_section_hook (abfd, section)
!      bfd * abfd;
!      asection * section;
  {
    combined_entry_type *native;
  
--- 1079,1151 ----
    return true;
  }
  
! /* Check whether this section uses an alignment other than the
!    default.  */
! 
! static void
! coff_set_custom_section_alignment (abfd, section, alignment_table, table_size)
!      bfd *abfd ATTRIBUTE_UNUSED;
!      asection *section;
!      const struct coff_section_alignment_entry *alignment_table;
!      const unsigned int table_size;
! {
!   const unsigned int default_alignment = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
!   unsigned int i;
! 
!   for (i = 0; i < table_size; ++i)
!     {
!       const char *secname = bfd_get_section_name (abfd, section);
!       if (alignment_table[i].comparison_length == (unsigned int) -1
! 	  ? strcmp (alignment_table[i].name, secname) == 0
! 	  : strncmp (alignment_table[i].name, secname,
! 		     alignment_table[i].comparison_length) == 0)
! 	break;
!     }
!   if (i >= table_size)
!     return;
! 
!   if (alignment_table[i].default_alignment_min != COFF_ALIGNMENT_FIELD_EMPTY
!       && default_alignment < alignment_table[i].default_alignment_min)
!     return;
! 
!   if (alignment_table[i].default_alignment_max != COFF_ALIGNMENT_FIELD_EMPTY
!       && default_alignment > alignment_table[i].default_alignment_max)
!     return;
! 
!   section->alignment_power = alignment_table[i].alignment_power;
! }
! 
! /* Custom section alignment records.  */
! 
! static const struct coff_section_alignment_entry
! coff_section_alignment_table[] =
! {
! #ifdef COFF_SECTION_ALIGNMENT_ENTRIES
!   COFF_SECTION_ALIGNMENT_ENTRIES,
! #endif
!   /* There must not be any gaps between .stabstr sections.  */
!   { COFF_SECTION_NAME_PARTIAL_MATCH (".stabstr"),
!     1, COFF_ALIGNMENT_FIELD_EMPTY, 0 },
!   /* The .stab section must be aligned to 2**2 at most, to avoid gaps.  */
!   { COFF_SECTION_NAME_PARTIAL_MATCH (".stab"),
!     3, COFF_ALIGNMENT_FIELD_EMPTY, 2 },
!   /* Similarly for the .ctors and .dtors sections.  */
!   { COFF_SECTION_NAME_EXACT_MATCH (".ctors"),
!     3, COFF_ALIGNMENT_FIELD_EMPTY, 2 },
!   { COFF_SECTION_NAME_EXACT_MATCH (".dtors"),
!     3, COFF_ALIGNMENT_FIELD_EMPTY, 2 }
! };
! 
! static const unsigned int coff_section_alignment_table_size =
!   sizeof coff_section_alignment_table / sizeof coff_section_alignment_table[0];
! 
! /* Initialize a section structure with information peculiar to this
!    particular implementation of COFF.  */
  
  static boolean
  coff_new_section_hook (abfd, section)
!      bfd *abfd;
!      asection *section;
  {
    combined_entry_type *native;
  
***************
*** 1120,1141 ****
  
    coffsymbol (section->symbol)->native = native;
  
!   /* The .stab section must be aligned to 2**2 at most, because
!      otherwise there may be gaps in the section which gdb will not
!      know how to interpret.  Examining the section name is a hack, but
!      that is also how gdb locates the section.
!      We need to handle the .ctors and .dtors sections similarly, to
!      avoid introducing null words in the tables.  */
!   if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 2
!       && (strncmp (section->name, ".stab", 5) == 0
! 	  || strcmp (section->name, ".ctors") == 0
! 	  || strcmp (section->name, ".dtors") == 0))
!     section->alignment_power = 2;
! 
!   /* Similarly, the .stabstr section must be aligned to 2**0 at most.  */
!   if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 0
!       && strncmp (section->name, ".stabstr", 8) == 0)
!     section->alignment_power = 0;
  
    return true;
  }
--- 1181,1189 ----
  
    coffsymbol (section->symbol)->native = native;
  
!   coff_set_custom_section_alignment (abfd, section,
! 				     coff_section_alignment_table,
! 				     coff_section_alignment_table_size);
  
    return true;
  }
Index: binutils/bfd/coff-go32.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coff-go32.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** coff-go32.c	1999/07/22 01:39:23	1.2
--- coff-go32.c	1999/08/09 02:56:16	1.3
***************
*** 24,27 ****
--- 24,39 ----
  #define COFF_LONG_SECTION_NAMES
  #define COFF_SUPPORT_GNU_LINKONCE
  
+ #define COFF_SECTION_ALIGNMENT_ENTRIES \
+ { COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+ { COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.d"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.t"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+ { COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.r"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }
+ 
  #include "coff-i386.c"
Index: binutils/bfd/coff-stgo32.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coff-stgo32.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -r1.4 -r1.5
*** coff-stgo32.c	1999/08/03 16:31:37	1.4
--- coff-stgo32.c	1999/08/09 02:56:16	1.5
***************
*** 42,47 ****
--- 42,53 ----
  #define COFF_LONG_SECTION_NAMES
  #define COFF_SUPPORT_GNU_LINKONCE
  
+ #define COFF_SECTION_ALIGNMENT_ENTRIES \
+ { COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }, \
+ { COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+   COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 4 }
+ 
  #include "bfd.h"
  
  /* At first the prototypes */
Index: binutils/bfd/libcoff-in.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/libcoff-in.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** libcoff-in.h	1999/07/24 03:16:49	1.2
--- libcoff-in.h	1999/08/09 02:56:16	1.3
***************
*** 1,5 ****
  /* BFD COFF object file private structure.
!    Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
     Free Software Foundation, Inc.
     Written by Cygnus Support.
  
--- 1,5 ----
  /* BFD COFF object file private structure.
!    Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
     Free Software Foundation, Inc.
     Written by Cygnus Support.
  
***************
*** 465,470 ****
--- 465,505 ----
    bfd_byte *external_relocs;
    /* Buffer large enough to hold swapped relocs of any input section.  */
    struct internal_reloc *internal_relocs;
+ };
+ 
+ /* Most COFF variants have no way to record the alignment of a
+    section.  This struct is used to set a specific alignment based on
+    the name of the section.  */
+ 
+ struct coff_section_alignment_entry
+ {
+   /* The section name.  */
+   const char *name;
+ 
+   /* This is either (unsigned int) -1, indicating that the section
+      name must match exactly, or it is the number of letters which
+      must match at the start of the name.  */
+   unsigned int comparison_length;
+ 
+   /* These macros may be used to fill in the first two fields in a
+      structure initialization.  */
+ #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
+ #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
+ 
+   /* Only use this entry if the default section alignment for this
+      target is at least that much (as a power of two).  If this field
+      is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored.  */
+   unsigned int default_alignment_min;
+ 
+   /* Only use this entry if the default section alignment for this
+      target is no greater than this (as a power of two).  If this
+      field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored.  */
+   unsigned int default_alignment_max;
+ 
+ #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
+ 
+   /* The desired alignment for this section (as a power of two).  */
+   unsigned int alignment_power;
  };
  
  extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
Index: binutils/bfd/libcoff.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/libcoff.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -c -r1.3 -r1.4
*** libcoff.h	1999/08/05 21:01:37	1.3
--- libcoff.h	1999/08/09 02:56:16	1.4
***************
*** 1,5 ****
  /* BFD COFF object file private structure.
!    Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
     Free Software Foundation, Inc.
     Written by Cygnus Support.
  
--- 1,5 ----
  /* BFD COFF object file private structure.
!    Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 98, 1999
     Free Software Foundation, Inc.
     Written by Cygnus Support.
  
***************
*** 465,470 ****
--- 465,505 ----
    bfd_byte *external_relocs;
    /* Buffer large enough to hold swapped relocs of any input section.  */
    struct internal_reloc *internal_relocs;
+ };
+ 
+ /* Most COFF variants have no way to record the alignment of a
+    section.  This struct is used to set a specific alignment based on
+    the name of the section.  */
+ 
+ struct coff_section_alignment_entry
+ {
+   /* The section name.  */
+   const char *name;
+ 
+   /* This is either (unsigned int) -1, indicating that the section
+      name must match exactly, or it is the number of letters which
+      must match at the start of the name.  */
+   unsigned int comparison_length;
+ 
+   /* These macros may be used to fill in the first two fields in a
+      structure initialization.  */
+ #define COFF_SECTION_NAME_EXACT_MATCH(name) (name), ((unsigned int) -1)
+ #define COFF_SECTION_NAME_PARTIAL_MATCH(name) (name), (sizeof (name) - 1)
+ 
+   /* Only use this entry if the default section alignment for this
+      target is at least that much (as a power of two).  If this field
+      is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored.  */
+   unsigned int default_alignment_min;
+ 
+   /* Only use this entry if the default section alignment for this
+      target is no greater than this (as a power of two).  If this
+      field is COFF_ALIGNMENT_FIELD_EMPTY, it should be ignored.  */
+   unsigned int default_alignment_max;
+ 
+ #define COFF_ALIGNMENT_FIELD_EMPTY ((unsigned int) -1)
+ 
+   /* The desired alignment for this section (as a power of two).  */
+   unsigned int alignment_power;
  };
  
  extern struct bfd_hash_entry *_bfd_coff_link_hash_newfunc
Index: binutils/gas/config/tc-i386.h
===================================================================
RCS file: /cvs/binutils/binutils/gas/config/tc-i386.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -3 -r1.4 -r1.5
*** tc-i386.h	1999/08/04 10:07:40	1.4
--- tc-i386.h	1999/08/09 04:42:15	1.5
***************
*** 118,124 ****
--- 118,138 ----
  extern short tc_coff_fix2rtype PARAMS ((struct fix *));
  #define TC_COFF_SIZEMACHDEP(frag) tc_coff_sizemachdep(frag)
  extern int tc_coff_sizemachdep PARAMS ((fragS *frag));
+ 
+ #ifdef TE_GO32
+ /* DJGPP now expects some sections to be 2**4 aligned.  */
+ #define SUB_SEGMENT_ALIGN(SEG)						\
+   ((strcmp (obj_segment_name (SEG), ".text") == 0			\
+     || strcmp (obj_segment_name (SEG), ".data") == 0			\
+     || strncmp (obj_segment_name (SEG), ".gnu.linkonce.t", 15) == 0	\
+     || strncmp (obj_segment_name (SEG), ".gnu.linkonce.d", 15) == 0	\
+     || strncmp (obj_segment_name (SEG), ".gnu.linkonce.r", 15) == 0)	\
+    ? 4									\
+    : 2)
+ #else
  #define SUB_SEGMENT_ALIGN(SEG) 2
+ #endif
+ 
  #define TC_RVA_RELOC 7
  /* Need this for PIC relocations */
  #define NEED_FX_R_TYPE


--- 
Mark Elbrecht, snowball3 AT bigfoot DOT com
http://snowball.frogspace.net/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019