2
0
Эх сурвалжийг харах

Merged revisions 11168-11169 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r11168 | giulio | 2008-06-02 09:29:14 +0200 (lun, 02 giu 2008) | 4 lines

Updated go32v2 linker script:
* dwarf debug sections must be placed at address 0
* added names of sections that are commonly found in gcc-compiled libraries (fixes linking to certain libraries)
........
r11169 | giulio | 2008-06-02 09:30:32 +0200 (lun, 02 giu 2008) | 3 lines

Fixed stack corruption in c_setjmp when register calling convention is used.
This caused the DOS ide to crash when trying to debug.
........

git-svn-id: branches/rc_2_2_2@11251 -

giulio 17 жил өмнө
parent
commit
396a97f306

+ 18 - 1
compiler/systems/t_go32v2.pas

@@ -194,16 +194,20 @@ begin
   ScriptRes.Add('  }');
   ScriptRes.Add('    .data  ALIGN(0x200) : {');
   ScriptRes.Add('      djgpp_first_ctor = . ;');
+  ScriptRes.Add('      *(SORT(.ctors.*))');
   ScriptRes.Add('      *(.ctor)');
+  ScriptRes.Add('      *(.ctors)');
   ScriptRes.Add('      djgpp_last_ctor = . ;');
   ScriptRes.Add('      djgpp_first_dtor = . ;');
+  ScriptRes.Add('      *(SORT(.dtors.*))');
   ScriptRes.Add('      *(.dtor)');
+  ScriptRes.Add('      *(.dtors)');
   ScriptRes.Add('      djgpp_last_dtor = . ;');
   ScriptRes.Add('      *(.data)');
   ScriptRes.Add('      *(.fpc*)');
   ScriptRes.Add('      *(.gcc_exc)');
   ScriptRes.Add('      ___EH_FRAME_BEGIN__ = . ;');
-  ScriptRes.Add('      *(.eh_fram)');
+  ScriptRes.Add('      *(.eh_fram*)');
   ScriptRes.Add('      ___EH_FRAME_END__ = . ;');
   ScriptRes.Add('      LONG(0)');
   ScriptRes.Add('       edata  =  . ; _edata = .;');
@@ -218,6 +222,19 @@ begin
   ScriptRes.Add('       end = . ; _end = .;');
   ScriptRes.Add('       . = ALIGN(0x200);');
   ScriptRes.Add('    }');
+  ScriptRes.Add('    /* Stabs debugging sections.  */');
+  ScriptRes.Add('    .stab 0 : { *(.stab) }');
+  ScriptRes.Add('    .stabstr 0 : { *(.stabstr) }');
+  ScriptRes.Add('    /* DWARF 2 */');
+  ScriptRes.Add('    .debug_aranges  0 : { *(.debug_aranges) }');
+  ScriptRes.Add('    .debug_pubnames 0 : { *(.debug_pubnames) }');
+  ScriptRes.Add('    .debug_info     0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }');
+  ScriptRes.Add('    .debug_abbrev   0 : { *(.debug_abbrev) }');
+  ScriptRes.Add('    .debug_line     0 : { *(.debug_line) }');
+  ScriptRes.Add('    .debug_frame    0 : { *(.debug_frame) }');
+  ScriptRes.Add('    .debug_str      0 : { *(.debug_str) }');
+  ScriptRes.Add('    .debug_loc      0 : { *(.debug_loc) }');
+  ScriptRes.Add('    .debug_macinfo  0 : { *(.debug_macinfo) }');
   ScriptRes.Add('  }');
 
   { Write path to search libraries }

+ 18 - 22
rtl/go32v2/dpmiexcp.pp

@@ -500,7 +500,11 @@ end;
 
 {$ifdef CREATE_C_FUNCTIONS}
 function c_setjmp(var rec : dpmi_jmp_buf) : longint;cdecl;[public, alias : '_setjmp'];
-  begin
+begin
+  asm
+        { unset the frame pointer just set }
+        movl    %ebp,%esp
+        popl    %ebp
 {$ifndef REGCALL}
   { here we need to be subtle :
     - we need to return with the arg still on the stack
@@ -509,40 +513,32 @@ function c_setjmp(var rec : dpmi_jmp_buf) : longint;cdecl;[public, alias : '_set
 
     For this we shift the return address down and
     duplicate the rec on stack }
-     asm
-        movl    %ebp,%esp
-        popl    %ebp
         subl    $8,%esp
         movl    %eax,(%esp)
         movl    8(%esp),%eax
         movl    %eax,4(%esp)
         movl    12(%esp),%eax
         movl    %eax,8(%esp)
+    { stack is now:
+          (%esp)   eax           <= we're popping it in the next instruction
+         4(%esp)   return addr
+         8(%esp)   rec           <= automatically removed by dpmi_setjmp
+        12(%esp)   rec           <= the caller will remove this
+    }
         popl    %eax
         jmp     dpmi_setjmp
-     end;
 {$ELSE REGCALL}
     { this is easier with regcall convention
-      because dpmi_setjmp expects rec arg in $eax }
-     asm
-        movl     rec,%eax
-        movl    %ebp,%esp
-        popl    %ebp
-        pushl   %eax
-        { stack is now:
-           (%esp): saved eax
-          4(%esp): return addr
-          8(%esp): rec addr
-          we need just
-          (%esp): return addr }
-        movl    4(%esp),%eax
-        movl    %eax,8(%esp)
-        popl    %eax
-        addl    $4,%esp
+      because dpmi_setjmp expects rec arg in $eax
+
+      We don't need to touch the stack. We must leave the parameter
+      there since this is a cdecl function (the caller will remove it)
+    }
+        movl    4(%esp), %eax
         jmp     dpmi_setjmp
-     end;
 {$ENDIF REGCALL}
   end;
+end;
 {$endif CREATE_C_FUNCTIONS}
 
 {$ifdef CREATE_C_FUNCTIONS}