* resres.c (write_res_header): Align header size.
authorDJ Delorie <dj@redhat.com>
Tue, 17 Jul 2001 03:14:49 +0000 (03:14 +0000)
committerDJ Delorie <dj@redhat.com>
Tue, 17 Jul 2001 03:14:49 +0000 (03:14 +0000)
(res_align_file): Calculate alignment correctly.

binutils/ChangeLog
binutils/resres.c

index 40ca327593e755f7f7a95d42bdc0db52692c6b75..c5a62a2cec4a1a5a9885cc59494bfa66ec9045d3 100644 (file)
@@ -1,5 +1,8 @@
 2001-07-16  DJ Delorie  <dj@redhat.com>
 
+       * resres.c (write_res_header): Align header size.
+       (res_align_file): Calculate alignment correctly.
+
        * rcparse.y (styles): use SUBLANG_SHIFT instead of 8 (or the more
        correct 10).
        * resrc.c (write_rc_resource): Likewise.
index 6a860eb2aebbec859e2069fd04031d3e718f7f61..616772e55c8890b631cd861a691c103e274ea5ab 100644 (file)
@@ -387,6 +387,8 @@ write_res_header (datasize, type, name, resinfo)
   reshdr.data_size = datasize;
   reshdr.header_size = 24 + get_id_size (type) + get_id_size (name);
 
+  reshdr.header_size = (reshdr.header_size + 3) & ~3;
+
   res_align_file ();
   write_res_data (&reshdr, sizeof (reshdr), 1);
   write_res_id (type);
@@ -513,7 +515,9 @@ read_unistring (len)
 static void
 res_align_file (void)
 {
-  if (fseek (fres, ftell (fres) % 4, SEEK_CUR) != 0)
+  int pos = ftell (fres);
+  int skip = ((pos + 3) & ~3) - pos;
+  if (fseek (fres, skip, SEEK_CUR) != 0)
     fatal ("%s: %s: unable to align file", program_name, filename);
 }
 
This page took 0.02749 seconds and 4 git commands to generate.