Browse Source

* don't generate instruction alignment fill bytes in non exectuable sections

git-svn-id: trunk@14251 -
florian 15 years ago
parent
commit
4123e0425c
3 changed files with 12 additions and 9 deletions
  1. 2 2
      compiler/aasmtai.pas
  2. 6 3
      compiler/assemble.pas
  3. 4 4
      compiler/x86/aasmcpu.pas

+ 2 - 2
compiler/aasmtai.pas

@@ -629,7 +629,7 @@ interface
            constructor Create_zeros(b:byte);
            constructor ppuload(t:taitype;ppufile:tcompilerppufile);override;
            procedure ppuwrite(ppufile:tcompilerppufile);override;
-           function calculatefillbuf(var buf : tfillbuffer):pchar;virtual;
+           function calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;virtual;
         end;
         tai_align_class = class of tai_align_abstract;
 
@@ -2350,7 +2350,7 @@ implementation
        end;
 
 
-     function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer):pchar;
+     function tai_align_abstract.calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;
        begin
          if fillsize>sizeof(buf) then
            internalerror(200404293);

+ 6 - 3
compiler/assemble.pas

@@ -1123,17 +1123,20 @@ Implementation
         lebbuf : array[0..63] of byte;
         objsym,
         objsymend : TObjSymbol;
+        zerobuf : array[0..63] of byte;
       begin
+        fillchar(zerobuf,sizeof(zerobuf),0);
         { main loop }
         while assigned(hp) do
          begin
            case hp.typ of
              ait_align :
                begin
-                 if (oso_data in ObjData.CurrObjSec.secoptions) then
-                   ObjData.writebytes(Tai_align_abstract(hp).calculatefillbuf(fillbuffer)^,Tai_align_abstract(hp).fillsize)
+                 if oso_data in ObjData.CurrObjSec.secoptions then
+                   ObjData.writebytes(Tai_align_abstract(hp).calculatefillbuf(fillbuffer,oso_executable in ObjData.CurrObjSec.secoptions)^,
+                     Tai_align_abstract(hp).fillsize)
                  else
-                   ObjData.alloc(Tai_align_abstract(hp).fillsize);
+                   ObjData.alloc(Tai_align_abstract(hp).fillsize);                   
                end;
              ait_section :
                begin

+ 4 - 4
compiler/x86/aasmcpu.pas

@@ -189,7 +189,7 @@ interface
          reg       : tregister;
          constructor create(b:byte);override;
          constructor create_op(b: byte; _op: byte);override;
-         function calculatefillbuf(var buf : tfillbuffer):pchar;override;
+         function calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;override;
       end;
 
       taicpu = class(tai_cpu_abstract_sym)
@@ -451,7 +451,7 @@ implementation
       end;
 
 
-    function tai_align.calculatefillbuf(var buf : tfillbuffer):pchar;
+    function tai_align.calculatefillbuf(var buf : tfillbuffer;executable : boolean):pchar;
       const
 {$ifdef x86_64}
         alignarray:array[0..3] of string[4]=(
@@ -474,8 +474,8 @@ implementation
         j : longint;
         localsize: byte;
       begin
-        inherited calculatefillbuf(buf);
-        if not use_op then
+        inherited calculatefillbuf(buf,executable);
+        if not(use_op) and executable then
          begin
            bufptr:=pchar(@buf);
            { fillsize may still be used afterwards, so don't modify }