include/coff/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 10 Aug 2009 22:02:41 +0000 (22:02 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Mon, 10 Aug 2009 22:02:41 +0000 (22:02 +0000)
Fix references past allocated memory for i386-*-go32.
* ti.h (COFF_ADJUST_FILEHDR_IN_POST, COFF_ADJUST_FILEHDR_OUT_POST):
Reference F_TARGET_ID only when !COFF0_P.

include/coff/ChangeLog
include/coff/ti.h

index a38228b33db8e3115fb2c02a6a3f77b47901ee4b..4aa9dc10774041803d8ef782011c95f1c09aee63 100644 (file)
@@ -1,3 +1,9 @@
+2009-08-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Fix references past allocated memory for i386-*-go32.
+       * ti.h (COFF_ADJUST_FILEHDR_IN_POST, COFF_ADJUST_FILEHDR_OUT_POST):
+       Reference F_TARGET_ID only when !COFF0_P.
+
 2009-08-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Stop using bfd_usrdata in libbfd.
index e0e17293d9309da2da3b3b98245c6bcbe0b70eef..7f3ad7e530c23f0f596a5a2e93dc3c5bab496459 100644 (file)
@@ -102,19 +102,21 @@ struct external_filehdr
 #define COFF_ADJUST_FILEHDR_IN_POST(abfd, src, dst) \
   do                                                                   \
     {                                                                  \
-      ((struct internal_filehdr *)(dst))->f_target_id =                        \
-       H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id);                \
+      if (!COFF0_P (abfd))                                             \
+       ((struct internal_filehdr *)(dst))->f_target_id =               \
+         H_GET_16 (abfd, ((FILHDR *)(src))->f_target_id);              \
     }                                                                  \
   while (0)
 #endif
 
 #ifndef COFF_ADJUST_FILEHDR_OUT_POST
 #define COFF_ADJUST_FILEHDR_OUT_POST(abfd, src, dst) \
-  do                                                                   \
-    {                                                                  \
-      H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \
-              ((FILHDR *)(dst))->f_target_id);                         \
-    }                                                                  \
+  do                                                                    \
+    {                                                                   \
+      if (!COFF0_P (abfd))                                              \
+       H_PUT_16 (abfd, ((struct internal_filehdr *)(src))->f_target_id, \
+                ((FILHDR *)(dst))->f_target_id);                        \
+    }                                                                   \
   while (0)
 #endif