Browse Source

Merge branch 'fixes_3_2' of gitlab.com:freepascal.org/fpc/source into fixes_3_2

marcoonthegit 2 years ago
parent
commit
05480071e2

+ 2 - 2
compiler/nflw.pas

@@ -1960,7 +1960,7 @@ implementation
               { nested exits don't need the non local goto switch }
               (labelsym.realname='$nestedexit') then
               begin
-                if current_procinfo.procdef.parast.symtablelevel>labelsym.owner.symtablelevel then
+                if current_procinfo.procdef.parast.symtablelevel>=labelsym.owner.symtablelevel then
                   begin
                     { don't mess with the exception blocks, global gotos in/out side exception blocks are not allowed }
                     if exceptionblock>0 then
@@ -1995,7 +1995,7 @@ implementation
                       CGMessage1(cg_e_goto_label_not_found,labelsym.realname);
                   end
                 else
-                  CGMessage(cg_e_interprocedural_goto_only_to_outer_scope_allowed);
+                  CGMessagePos(self.fileinfo,cg_e_interprocedural_goto_only_to_outer_scope_allowed);
               end
             else
               CGMessage1(cg_e_goto_label_not_found,labelsym.realname);

+ 1 - 1
compiler/pdecl.pas

@@ -363,7 +363,7 @@ implementation
                   begin
                     { strip leading 0's in iso mode }
                     if (([m_iso,m_extpas]*current_settings.modeswitches)<>[]) then
-                      while pattern[1]='0' do
+                      while (length(pattern)>1) and (pattern[1]='0') do
                         delete(pattern,1,1);
                     labelsym:=clabelsym.create(pattern);
                   end;

+ 1 - 1
compiler/pstatmnt.pas

@@ -1143,7 +1143,7 @@ implementation
 
                         { strip leading 0's in iso mode }
                         if (([m_iso,m_extpas]*current_settings.modeswitches)<>[]) then
-                          while pattern[1]='0' do
+                          while (length(pattern)>1) and (pattern[1]='0') do
                             delete(pattern,1,1);
 
                         searchsym(pattern,srsym,srsymtable);

+ 6 - 5
rtl/linux/i386/si_c21.inc

@@ -35,12 +35,13 @@
 
 {$asmmode att}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
+procedure ini_dummy;
+  begin
+  end;
+
 procedure libc_start_main; external name '__libc_start_main';
 procedure libc_exit(code: longint); cdecl; external name 'exit';
 
-
 {******************************************************************************
                        glibc 2.1 lib + profiling start/halt
  ******************************************************************************}
@@ -93,8 +94,8 @@ asm
         pushl %esp   			{ stack_end }
         pushl %edx   			{ function to be registered with
                       			  atexit(), passed by loader }
-        pushl $__libc_csu_fini
-        pushl $__libc_csu_init
+        pushl $ini_dummy
+        pushl $ini_dummy
         pushl %esi                      { Push second argument: argv.  }
         pushl %ecx                      { Push first argument: argc.  }
 

+ 72 - 34
rtl/linux/mips/cprt0.as

@@ -64,32 +64,70 @@
 		      void (*rtld_fini) (void), void *stack_end)
 */
  .text
- .globl main
- .globl __start
- .type __start,@function
+ 	.align	2
+	.globl	__libc_csu_init
+	.type	__libc_csu_init, @function
+__libc_csu_init:
+	.set	nomips16
+        .weak __libc_csu_init
+	.ent	__libc_csu_init
+	.frame	$sp,0,$ra
+	.mask	0x00000000,0
+	.fmask	0x00000000,0
+	.set	noreorder
+	.set	nomacro
+	jr	$31
+	nop
+	.set	macro
+	.set	reorder
+	.end	__libc_csu_init
+	.size	__libc_csu_init, .-__libc_csu_init
+
+	.align	2
+	.globl	__libc_csu_fini
+	.type	__libc_csu_fini, @function
+__libc_csu_fini:
+	.set	nomips16
+        .weak __libc_csu_fini
+	.ent	__libc_csu_fini
+	.frame	$sp,0,$ra
+	.mask	0x00000000,0
+	.fmask	0x00000000,0
+	.set	noreorder
+	.set	nomacro
+	jr	$31
+	nop
+	.set	macro
+	.set	reorder
+	.end	__libc_csu_fini
+	.size	__libc_csu_fini, .-__libc_csu_fini
+
+ 	.align	2
+        .globl main
+        .globl __start
+        .type __start,@function
 __start:
-.globl _start
- .type _start,@function
+        .globl _start
+        .type _start,@function
 _start:
-  .ent _start
-
+        .ent _start
 
- .set noreorder
- move $0, $31
- bal 10f
- nop
- 10: 
- .cpload $31
- move $31, $0
- .set reorder
-	/* Setup GP correctly if we're non-PIC.  */
- la $28,_gp
-
- lui $4, %hi(main_stub)		/* main */
- addiu $4,$4,%lo(main_stub)
-
- lw $5, 0($29)		/* argc */
- addiu $6, $29, 4	/* argv */
+        .set noreorder
+        move $0, $31
+        bal 10f
+        nop
+        10: 
+        .cpload $31
+        move $31, $0
+        .set reorder
+                /* Setup GP correctly if we're non-PIC.  */
+        la $28,_gp
+
+        lui $4, %hi(main_stub)		/* main */
+        addiu $4,$4,%lo(main_stub)
+
+        lw $5, 0($29)		/* argc */
+        addiu $6, $29, 4	/* argv */
         /* store argc */
         lw      $t0,0($29)
         lui     $t1,%hi(operatingsystem_parameter_argc)
@@ -110,20 +148,20 @@ _start:
 	/* Allocate space on the stack for seven arguments (o32 only)
 	   and make sure the stack is aligned to double words (8 bytes) 
 	   on o32 and quad words (16 bytes) on n32 and n64.  */
- and $29, -2 * 4
- subu $29, 32
+        and $29, -2 * 4
+        subu $29, 32
 
- lw $7,%got(__libc_csu_init)($gp) /* init */
- lw $8,%got(__libc_csu_fini)($gp) /* fini */
+        lw $7,%got(__libc_csu_init)($gp) /* init */
+        lw $8,%got(__libc_csu_fini)($gp) /* fini */
 
- sw $8, 16($29)				/* fini */
- sw $2, 20($29)				/* rtld_fini */
- sw $29, 24($29)			/* stack_end */
+        sw $8, 16($29)				/* fini */
+        sw $2, 20($29)				/* rtld_fini */
+        sw $29, 24($29)			/* stack_end */
 
- lw $t9,%got(__libc_start_main)($gp)
- jalr $t9
- .end _start
- .size _start, . - _start
+        lw $t9,%got(__libc_start_main)($gp)
+        jalr $t9
+        .end _start
+        .size _start, . - _start
 
         .globl  main_stub
         .type   main_stub,@function

+ 20 - 0
rtl/linux/powerpc/cprt0.as

@@ -57,6 +57,26 @@ _start:
  /* and continue in libc-start, in glibc.  */
     b      __libc_start_main
 
+	.balign 4
+.globl	__libc_csu_init
+	.type	__libc_csu_init,@function
+/* strangly enough using weak breaks things */
+/*    .weak __libc_csu_init                 */
+__libc_csu_init:
+	blr
+.Le0:
+	.size	__libc_csu_init, .Le0 - __libc_csu_init
+
+	.balign 4
+.globl	__libc_csu_fini
+	.type	__libc_csu_fini,@function
+/* strangly enough using weak breaks things */
+/*    .weak __libc_csu_fini */
+__libc_csu_fini:
+	blr
+.Le1:
+	.size	__libc_csu_fini, .Le1 - __libc_csu_fini
+
     .globl  main_stub
     .type   main_stub, @function
 main_stub:

+ 8 - 5
rtl/linux/powerpc64/si_c.inc

@@ -657,9 +657,6 @@ _restvr_31: addi r12,r0,-16
                           Process start/halt
  ******************************************************************************}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
-
 procedure __libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl; external;
 
 var
@@ -715,6 +712,10 @@ data_start:
 .text
   end;
 
+procedure ini_dummy;
+  begin
+  end;
+
 const
   start_addresses: record
     sda_base: pointer;
@@ -724,8 +725,10 @@ const
   end
   = (sda_base: nil; {* was _SDA_BASE_  but not in 64-bit ABI }
      main: @main_stub;
-     libc_csu_init: @__libc_csu_init;
-     libc_csu_fini: @__libc_csu_fini
+     { use dummy, it should not be used anymore by glibc }
+     libc_csu_init: @ini_dummy;
+     { use dummy, it should not be used anymore by glibc }
+     libc_csu_fini: @ini_dummy
     );
 
 

+ 9 - 5
rtl/linux/powerpc64/si_g.inc

@@ -657,9 +657,6 @@ _restvr_31: addi r12,r0,-16
                           Process start/halt
  ******************************************************************************}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
-
 procedure __libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl; external;
 
 type
@@ -736,6 +733,11 @@ data_start:
 .text
   end;
 
+
+procedure ini_dummy;
+  begin
+  end;
+
 const
   start_addresses: record
     sda_base: pointer;
@@ -745,8 +747,10 @@ const
   end
   = (sda_base: nil; {* was _SDA_BASE_  but not in 64-bit ABI }
      main: @main_stub;
-     libc_csu_init: @__libc_csu_init;
-     libc_csu_fini: @__libc_csu_fini
+     { use dummy, it should not be used anymore by glibc }
+     libc_csu_init: @ini_dummy;
+     { use dummy, it should not be used anymore by glibc }
+     libc_csu_fini: @ini_dummy
     );
 
 procedure call_libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl;

+ 8 - 0
tests/webtbs/tw37428.pp

@@ -0,0 +1,8 @@
+{$mode iso}
+label
+  0;
+
+begin
+  0:
+    writeln('ok');
+end.