bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Aug 2007 16:02:01 +0000 (16:02 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Aug 2007 16:02:01 +0000 (16:02 +0000)
2007-08-02  H.J. Lu  <hongjiu.lu@intel.com>

* coffcode.h (ALIGN_SET): Removed.
(ELIFALIGN_SET): Likewise.
(coff_set_alignment_hook): Handle IMAGE_SCN_ALIGN_128BYTES,
IMAGE_SCN_ALIGN_256BYTES, IMAGE_SCN_ALIGN_512BYTES,
IMAGE_SCN_ALIGN_1024BYTES, IMAGE_SCN_ALIGN_2048BYTES,
IMAGE_SCN_ALIGN_4096BYTES and IMAGE_SCN_ALIGN_8192BYTES.

include/coff/

2007-08-02  H.J. Lu  <hongjiu.lu@intel.com>

* pe.h (IMAGE_SCN_ALIGN_POWER_BIT_POS): New.
(IMAGE_SCN_ALIGN_POWER_BIT_MASK): Likewise.
(IMAGE_SCN_ALIGN_POWER_NUM): Likewise.
(IMAGE_SCN_ALIGN_POWER_CONST): Likewise.
(IMAGE_SCN_ALIGN_128BYTES): Likewise.
(IMAGE_SCN_ALIGN_256BYTES): Likewise.
(IMAGE_SCN_ALIGN_512BYTES): Likewise.
(IMAGE_SCN_ALIGN_1024BYTES): Likewise.
(IMAGE_SCN_ALIGN_2048BYTES): Likewise.
(IMAGE_SCN_ALIGN_4096BYTES): Likewise.
(IMAGE_SCN_ALIGN_8192BYTES): Likewise.
(IMAGE_SCN_ALIGN_1BYTES): Redefined with
IMAGE_SCN_ALIGN_POWER_CONST.
(IMAGE_SCN_ALIGN_2BYTES): Likewise.
(IMAGE_SCN_ALIGN_4BYTES): Likewise.
(IMAGE_SCN_ALIGN_8BYTES): Likewise.
(IMAGE_SCN_ALIGN_16BYTES): Likewise.
(IMAGE_SCN_ALIGN_32BYTES): Likewise.
(IMAGE_SCN_ALIGN_64BYTES): Likewise.

bfd/ChangeLog
bfd/coffcode.h
include/coff/ChangeLog
include/coff/pe.h

index 68a9ef32bd195fa953115a90b6cad21c4c080402..16690a5a4a1d36b97abb35a45241629e7059a6a5 100644 (file)
@@ -1,3 +1,12 @@
+2007-08-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * coffcode.h (ALIGN_SET): Removed.
+       (ELIFALIGN_SET): Likewise.
+       (coff_set_alignment_hook): Handle IMAGE_SCN_ALIGN_128BYTES,
+       IMAGE_SCN_ALIGN_256BYTES, IMAGE_SCN_ALIGN_512BYTES,
+       IMAGE_SCN_ALIGN_1024BYTES, IMAGE_SCN_ALIGN_2048BYTES,
+       IMAGE_SCN_ALIGN_4096BYTES and IMAGE_SCN_ALIGN_8192BYTES.
+
 2007-08-01  Michael Snyder  <msnyder@access-company.com>
 
        * vms-tir.c (new_section): Fix cut and paste error.
index 043e929bd79e82ed9e914a3b9cc4eff644a52a0b..3d92ee570a49d281ec626b376e87a510e61d8e2f 100644 (file)
@@ -1628,19 +1628,6 @@ coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
 #else /* ! COFF_ALIGN_IN_SECTION_HEADER */
 #ifdef COFF_WITH_PE
 
-/* A couple of macros to help setting the alignment power field.  */
-#define ALIGN_SET(field, x, y) \
-  if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x)\
-    {\
-      section->alignment_power = y;\
-    }
-
-#define ELIFALIGN_SET(field, x, y) \
-  else if (((field) & IMAGE_SCN_ALIGN_64BYTES) == x) \
-    {\
-      section->alignment_power = y;\
-    }
-
 static void
 coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
                         asection * section,
@@ -1648,14 +1635,31 @@ coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED,
 {
   struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
   bfd_size_type amt;
+  unsigned int alignment_power_const
+    = hdr->s_flags & IMAGE_SCN_ALIGN_POWER_BIT_MASK;
 
-  ALIGN_SET     (hdr->s_flags, IMAGE_SCN_ALIGN_64BYTES, 6)
-  ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_32BYTES, 5)
-  ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_16BYTES, 4)
-  ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_8BYTES,  3)
-  ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_4BYTES,  2)
-  ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_2BYTES,  1)
-  ELIFALIGN_SET (hdr->s_flags, IMAGE_SCN_ALIGN_1BYTES,  0)
+  switch (alignment_power_const)
+    {
+    case IMAGE_SCN_ALIGN_8192BYTES:
+    case IMAGE_SCN_ALIGN_4096BYTES:
+    case IMAGE_SCN_ALIGN_2048BYTES:
+    case IMAGE_SCN_ALIGN_1024BYTES:
+    case IMAGE_SCN_ALIGN_512BYTES:
+    case IMAGE_SCN_ALIGN_256BYTES:
+    case IMAGE_SCN_ALIGN_128BYTES:
+    case IMAGE_SCN_ALIGN_64BYTES:
+    case IMAGE_SCN_ALIGN_32BYTES:
+    case IMAGE_SCN_ALIGN_16BYTES:
+    case IMAGE_SCN_ALIGN_8BYTES:
+    case IMAGE_SCN_ALIGN_4BYTES:
+    case IMAGE_SCN_ALIGN_2BYTES:
+    case IMAGE_SCN_ALIGN_1BYTES:
+      section->alignment_power
+       = IMAGE_SCN_ALIGN_POWER_NUM (alignment_power_const);
+      break;
+    default:
+      break;
+    }
 
   /* In a PE image file, the s_paddr field holds the virtual size of a
      section, while the s_size field holds the raw size.  We also keep
index bc1c92210963bb2340ba3494474ec9a8dd833fda..936cefa881cb34d5c83f22d0451db27e4412c128 100644 (file)
@@ -1,3 +1,25 @@
+2007-08-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * pe.h (IMAGE_SCN_ALIGN_POWER_BIT_POS): New.
+       (IMAGE_SCN_ALIGN_POWER_BIT_MASK): Likewise.
+       (IMAGE_SCN_ALIGN_POWER_NUM): Likewise.
+       (IMAGE_SCN_ALIGN_POWER_CONST): Likewise.
+       (IMAGE_SCN_ALIGN_128BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_256BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_512BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_1024BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_2048BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_4096BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_8192BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_1BYTES): Redefined with
+       IMAGE_SCN_ALIGN_POWER_CONST.
+       (IMAGE_SCN_ALIGN_2BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_4BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_8BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_16BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_32BYTES): Likewise.
+       (IMAGE_SCN_ALIGN_64BYTES): Likewise.
+
 2007-07-12  Kai Tietz   <kai.tietz@onevision.com>
 
        * internal.h (struct internal_syment): Use bfd_hostptr_t for
index 277621cd41b02e2127ddb641266c98ab9e93967c..5a4d96027d483472716472c5ac6c7189c95441f0 100644 (file)
 #define IMAGE_SCN_MEM_LOCKED                 0x00040000
 #define IMAGE_SCN_MEM_PRELOAD                0x00080000
 
-#define IMAGE_SCN_ALIGN_1BYTES               0x00100000
-#define IMAGE_SCN_ALIGN_2BYTES               0x00200000
-#define IMAGE_SCN_ALIGN_4BYTES               0x00300000
-#define IMAGE_SCN_ALIGN_8BYTES               0x00400000
-#define IMAGE_SCN_ALIGN_16BYTES              0x00500000  /* Default alignment if no others are specified. */
-#define IMAGE_SCN_ALIGN_32BYTES              0x00600000
-#define IMAGE_SCN_ALIGN_64BYTES              0x00700000
+/* Bit position in the s_flags field where the alignment values start. */
+#define IMAGE_SCN_ALIGN_POWER_BIT_POS       20
+#define IMAGE_SCN_ALIGN_POWER_BIT_MASK      0x00f00000
+#define IMAGE_SCN_ALIGN_POWER_NUM(val)      \
+  (((val) >> IMAGE_SCN_ALIGN_POWER_BIT_POS) - 1)
+#define IMAGE_SCN_ALIGN_POWER_CONST(val)     \
+  (((val) + 1) << IMAGE_SCN_ALIGN_POWER_BIT_POS)
+
+#define IMAGE_SCN_ALIGN_1BYTES              IMAGE_SCN_ALIGN_POWER_CONST (0)
+#define IMAGE_SCN_ALIGN_2BYTES              IMAGE_SCN_ALIGN_POWER_CONST (1)
+#define IMAGE_SCN_ALIGN_4BYTES              IMAGE_SCN_ALIGN_POWER_CONST (2)
+#define IMAGE_SCN_ALIGN_8BYTES              IMAGE_SCN_ALIGN_POWER_CONST (3)
+/* Default alignment if no others are specified. */
+#define IMAGE_SCN_ALIGN_16BYTES                     IMAGE_SCN_ALIGN_POWER_CONST (4)
+#define IMAGE_SCN_ALIGN_32BYTES                     IMAGE_SCN_ALIGN_POWER_CONST (5)
+#define IMAGE_SCN_ALIGN_64BYTES                     IMAGE_SCN_ALIGN_POWER_CONST (6)
+#define IMAGE_SCN_ALIGN_128BYTES            IMAGE_SCN_ALIGN_POWER_CONST (7)
+#define IMAGE_SCN_ALIGN_256BYTES            IMAGE_SCN_ALIGN_POWER_CONST (8)
+#define IMAGE_SCN_ALIGN_512BYTES            IMAGE_SCN_ALIGN_POWER_CONST (9)
+#define IMAGE_SCN_ALIGN_1024BYTES           IMAGE_SCN_ALIGN_POWER_CONST (10)
+#define IMAGE_SCN_ALIGN_2048BYTES           IMAGE_SCN_ALIGN_POWER_CONST (11)
+#define IMAGE_SCN_ALIGN_4096BYTES           IMAGE_SCN_ALIGN_POWER_CONST (12)
+#define IMAGE_SCN_ALIGN_8192BYTES           IMAGE_SCN_ALIGN_POWER_CONST (13)
 
 #define IMAGE_SCN_LNK_NRELOC_OVFL            0x01000000  /* Section contains extended relocations. */
 #define IMAGE_SCN_MEM_NOT_CACHED             0x04000000  /* Section is not cachable.               */