Browse Source

* Some fixes to NASM writer:
* Correctly output names of sec_user sections and sec_threadvar on Windows targets
* Use ALIGNB directive to align without warnings in bss and alike sections.
* Do not output 'begin/end asmlist x' for empty asmlists.

git-svn-id: trunk@26898 -

sergei 11 years ago
parent
commit
f69e6ec389
1 changed files with 21 additions and 8 deletions
  1. 21 8
      compiler/x86/agx86nsm.pas

+ 21 - 8
compiler/x86/agx86nsm.pas

@@ -577,6 +577,11 @@ interface
         if (atype in [sec_rodata,sec_rodata_norel]) and
         if (atype in [sec_rodata,sec_rodata_norel]) and
           (target_info.system=system_i386_go32v2) then
           (target_info.system=system_i386_go32v2) then
           AsmWrite('.data')
           AsmWrite('.data')
+        else if (atype=sec_user) then
+          AsmWrite(aname)
+        else if (atype=sec_threadvar) and
+          (target_info.system in (systems_windows+systems_wince)) then
+          AsmWrite('.tls'#9'bss')
         else if secnames[atype]='.text' then
         else if secnames[atype]='.text' then
           AsmWrite(CodeSectionName)
           AsmWrite(CodeSectionName)
         else
         else
@@ -665,11 +670,16 @@ interface
 
 
            ait_align :
            ait_align :
              begin
              begin
-               { nasm gives warnings when it finds align in bss as it
-                 wants to store data }
-               if (lastsectype<>sec_bss) and
-                  (tai_align(hp).aligntype>1) then
-                 AsmWriteLn(#9'ALIGN '+tostr(tai_align(hp).aligntype));
+               if (tai_align(hp).aligntype>1) then
+                 begin
+                   if (lastsectype=sec_bss) or (
+                      (lastsectype=sec_threadvar) and
+                      (target_info.system in (systems_windows+systems_wince))
+                     ) then
+                      AsmWriteLn(#9'ALIGNB '+tostr(tai_align(hp).aligntype))
+                    else
+                      AsmWriteLn(#9'ALIGN '+tostr(tai_align(hp).aligntype));
+                 end;
              end;
              end;
 
 
            ait_datablock :
            ait_datablock :
@@ -1242,9 +1252,12 @@ interface
 
 
       for hal:=low(TasmlistType) to high(TasmlistType) do
       for hal:=low(TasmlistType) to high(TasmlistType) do
         begin
         begin
-          AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmListTypeStr[hal]);
-          writetree(current_asmdata.asmlists[hal]);
-          AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]);
+          if not (current_asmdata.asmlists[hal].empty) then
+            begin
+              AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmListTypeStr[hal]);
+              writetree(current_asmdata.asmlists[hal]);
+              AsmWriteLn(target_asm.comment+'End asmlist '+AsmListTypeStr[hal]);
+            end;
         end;
         end;
 
 
       AsmLn;
       AsmLn;