delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/06/29/00:29:27

From: "Mark E." <snowball3 AT bigfoot DOT com>
To: djgpp-workers AT delorie DOT com
Date: Thu, 29 Jun 2000 00:28:41 -0400
MIME-Version: 1.0
Subject: experimental patch to stop garbage in executables
Message-ID: <395A9839.25190.302F28@localhost>
X-mailer: Pegasus Mail for Win32 (v3.12c)
Reply-To: djgpp-workers AT delorie DOT com

Hi folks,

I have come up with an experimental patch that get rid of the garbage that appears in 
the exectuables. Typically, I see snatches of source code in mine. If your adventurous, 
try out the patch and see if it works for you. I deliberately made the fill character 
'Z' so it would obvious where the fill takes place. It  also makes it obvious if 
something besides empty space is overwritten when using objdump and friends. The final 
patch will of course use the null character.

*** bfd/coffcode.h.orig	Mon Jun 19 12:23:26 2000
--- bfd/coffcode.h	Wed Jun 28 21:29:16 2000
*************** coff_write_object_contents (abfd)
*** 3880,3885 ****
--- 3880,3904 ----
      }
  #endif
  
+ #define COFF_PAD_EXEC_HEADER
+ #ifdef COFF_PAD_EXEC_HEADER
+   if (abfd->flags & EXEC_P)
+   {
+     /* Fill the bytes between the end of the headers
+        and the start of the first section.  */
+     long curpos = bfd_tell (abfd);
+     long first_sectpos = abfd->sections->filepos;
+     long fill_size = first_sectpos - curpos;
+     if (fill_size > 0)
+     {
+       bfd_byte *b = bfd_malloc (fill_size);
+       memset (b, 'Z', fill_size);
+       bfd_write ((PTR)b, 1, fill_size, abfd);
+       free (b);
+     }
+   }
+ #endif
+   
    /* now write them */
    if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
      return false;



- Raw text -


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