Browse Source

* Fixed writing debug link for external symbols file. Bug #13041.

git-svn-id: trunk@12686 -
yury 16 years ago
parent
commit
89d466a3dc
1 changed files with 11 additions and 9 deletions
  1. 11 9
      compiler/ogcoff.pas

+ 11 - 9
compiler/ogcoff.pas

@@ -2128,7 +2128,8 @@ const pemagic : array[0..3] of byte = (
         dataExeSec,
         dataExeSec,
         bssExeSec,
         bssExeSec,
         idataExeSec : TExeSection;
         idataExeSec : TExeSection;
-        hassymbols  : boolean;
+        hassymbols,
+        writeDbgStrings : boolean;
 
 
         procedure UpdateDataDir(const secname:string;idx:longint);
         procedure UpdateDataDir(const secname:string;idx:longint);
         var
         var
@@ -2158,6 +2159,7 @@ const pemagic : array[0..3] of byte = (
                      (ExeWriteMode=ewm_exefull) and
                      (ExeWriteMode=ewm_exefull) and
                      not(cs_link_strip in current_settings.globalswitches)
                      not(cs_link_strip in current_settings.globalswitches)
                     );
                     );
+        writeDbgStrings:=hassymbols or ((ExeWriteMode=ewm_exeonly) and (cs_link_separate_dbg_file in current_settings.globalswitches));
         { Stub }
         { Stub }
         if win32 then
         if win32 then
           begin
           begin
@@ -2170,11 +2172,10 @@ const pemagic : array[0..3] of byte = (
         fillchar(header,sizeof(header),0);
         fillchar(header,sizeof(header),0);
         header.mach:=COFF_MAGIC;
         header.mach:=COFF_MAGIC;
         header.nsects:=nsects;
         header.nsects:=nsects;
+        if writeDbgStrings then
+          header.sympos:=sympos;
         if hassymbols then
         if hassymbols then
-          begin
-            header.sympos:=sympos;
-            header.syms:=nsyms;
-          end;
+          header.syms:=nsyms;
         if win32 then
         if win32 then
           header.opthdr:=sizeof(tcoffpeoptheader)
           header.opthdr:=sizeof(tcoffpeoptheader)
         else
         else
@@ -2288,12 +2289,13 @@ const pemagic : array[0..3] of byte = (
         ExeSectionList.ForEachCall(@ExeSectionList_write_header,nil);
         ExeSectionList.ForEachCall(@ExeSectionList_write_header,nil);
         { Section data }
         { Section data }
         ExeSectionList.ForEachCall(@ExeSectionList_write_data,nil);
         ExeSectionList.ForEachCall(@ExeSectionList_write_data,nil);
+        { Optional Symbols }
+        if SymPos<>FWriter.Size then
+          internalerror(200602252);
         if hassymbols then
         if hassymbols then
+          ExeSymbolList.ForEachCall(@globalsyms_write_symbol,nil);
+        if writeDbgStrings then
           begin
           begin
-            { Optional Symbols }
-            if SymPos<>FWriter.Size then
-              internalerror(200602252);
-            ExeSymbolList.ForEachCall(@globalsyms_write_symbol,nil);
             { Strings }
             { Strings }
             i:=FCoffStrs.size+4;
             i:=FCoffStrs.size+4;
             FWriter.write(i,4);
             FWriter.write(i,4);