Adjust startup code for glibc 2.34
authorGraham Inggs <ginggs@debian.org>
Fri, 17 Mar 2023 12:45:28 +0000 (12:45 +0000)
committerAbou Al Montacir <abou.almontacir@sfr.fr>
Fri, 17 Mar 2023 12:45:28 +0000 (12:45 +0000)
Bug: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
Last-Update: 2022-08-12

Based on the corresponding changes made in glibc:
https://sourceware.org/git/?p=glibc.git;a=commit;h=035c012e32c11e84d64905efaf55e74f704d3668

Gbp-Pq: Name glibc2.34.patch

fpcsrc/rtl/linux/aarch64/cprt0.as
fpcsrc/rtl/linux/arm/cprt0.as
fpcsrc/rtl/linux/i386/si_c21.inc
fpcsrc/rtl/linux/m68k/cprt0.as
fpcsrc/rtl/linux/mips/cprt0.as
fpcsrc/rtl/linux/powerpc/cprt0.as
fpcsrc/rtl/linux/powerpc64/cprt0.as
fpcsrc/rtl/linux/powerpc64/gprt0.as
fpcsrc/rtl/linux/powerpc64/si_c.inc
fpcsrc/rtl/linux/powerpc64/si_g.inc
fpcsrc/rtl/linux/x86_64/cprt0.as

index fd83610fbc72fd04e152a31bebe95261d100f235..17c3492688190aa7e2753daeba545c974ed4d57f 100644 (file)
@@ -41,10 +41,8 @@ _start:
                             init, fini, rtld_fini, stack_end) */
        adrp    x0,:got:PASCALMAIN
        ldr     x0,[x0,#:got_lo12:PASCALMAIN]
-       adrp    x3,:got:__libc_csu_init
-       ldr     x3,[x3,#:got_lo12:__libc_csu_init]
-       adrp    x4,:got:__libc_csu_fini
-       ldr     x4,[x4,#:got_lo12:__libc_csu_fini]
+       mov     x3, #0
+       mov     x4, #0
        bl      __libc_start_main
 
        /* This should never happen */
index 40755fe40f69ba4dd3397d156fb09ef73b88a26c..f2c2ddf15c15d2b18b83816ff7a5e59c9329275e 100644 (file)
@@ -82,10 +82,10 @@ _start:
 
         /* Set up the other arguments in registers */
         ldr a1, =PASCALMAIN
-        ldr a4, =_init
+        ldr a4, = #0
 
         /* Push fini */
-        str ip, [sp, #-4]!
+        str a4, [sp, #-4]!
 
         /* __libc_start_main (main, argc, argv, init, fini, rtld_fini, stack_end) */
 
index 71df29b6efd8a35ef2002f2903a42edf826ef996..a6918ba5dbf10a2e4efdfa646eb078d468310655 100644 (file)
@@ -35,8 +35,6 @@
 
 {$asmmode att}
 
-procedure __libc_csu_init; cdecl; external;
-procedure __libc_csu_fini; cdecl; external;
 procedure libc_start_main; external name '__libc_start_main';
 procedure libc_exit(code: longint); cdecl; external name 'exit';
 
@@ -93,8 +91,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 $0
+        pushl $0
         pushl %esi                      { Push second argument: argv.  }
         pushl %ecx                      { Push first argument: argc.  }
 
index 46f8ddc40326685aa164160b6ae9a4580bd96ecf..a66937267848898cb60c7027b57401a2d889d846 100644 (file)
@@ -41,8 +41,10 @@ __entry:
 
         pea      (%sp)         /* highest available stack address */
         pea      (%a1)         /* termination function provided by kernel */
-        pea      __libc_csu_fini
-        pea      __libc_csu_init
+
+        clr.l    -(%sp)
+        clr.l    -(%sp)
+
         pea      (%a0)         /* argv */
         move.l   %d0,-(%sp)    /* argc */
         pea      PASCALMAIN
index 327adf1dcf882faf0a123cfdd725428d079dd913..3d18c4ba73e4322a109e90d2623d468256ec815f 100644 (file)
@@ -113,10 +113,9 @@ _start:
  and $29, -2 * 4
  subu $29, 32
 
- lw $7,%got(__libc_csu_init)($gp) /* init */
- lw $8,%got(__libc_csu_fini)($gp) /* fini */
+ move $7, $0
 
- sw $8, 16($29)                                /* fini */
+ sw $0, 16($29)
  sw $2, 20($29)                                /* rtld_fini */
  sw $29, 24($29)                       /* stack_end */
 
index d4637923c8ccb1d26e7685dfe13bd0c6e9604ce5..a0660f2d142473209804bfb332afb02fd28b6e86 100644 (file)
@@ -35,8 +35,8 @@
 start_addresses:
     .long     _SDA_BASE_
     .long     main_stub
-    .long     __libc_csu_init
-    .long     __libc_csu_fini
+    .long     0
+    .long     0
     .size   start_adresses, .-start_addresses
 
     .section ".text"
index 2b8309d4bfd0ba5e9fc6b85f1e0bb6e1a22fe8d2..1175274d7dde36994bab2c121f5ea8ce94defddd 100644 (file)
@@ -351,8 +351,8 @@ _restvr_31: addi r12,r0,-16
 start_addresses:
     .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
     .quad   main_stub
-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
+    .quad   0
+    .quad   0
     .size   start_adresses, .-start_addresses
 
 /*
index de31b6b08d5bf89fc3d678595ed5fb2439a42396..0a4a57b2c593204ef4e018a5a22f51326a050f72 100644 (file)
@@ -351,8 +351,8 @@ _restvr_31: addi r12,r0,-16
 start_addresses:
     .quad   0 /* was _SDA_BASE_  but not in 64-bit ABI*/
     .quad   main_stub
-    .quad   __libc_csu_init
-    .quad   __libc_csu_fini
+    .quad   0
+    .quad   0
     .size   start_adresses, .-start_addresses
 
 /*
index c7e5e353a09e4c3bd804a469d397b2281f797b3e..929ffdccc90e326a4ab5be57ba5bba1765e41e40 100644 (file)
@@ -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
@@ -724,8 +721,8 @@ 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
+     libc_csu_init: pointer(0);
+     libc_csu_fini: pointer(0)
     );
 
 
index 8c99a39bc6e96dc6cc64fba3e277c53f3bf5b751..b5e882baec5f5867baf48b3c30ffbdcf4e75c4a8 100644 (file)
@@ -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
@@ -745,8 +742,8 @@ 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
+     libc_csu_init: pointer(0);
+     libc_csu_fini: pointer(0)
     );
 
 procedure call_libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl;
index 1a228227ab25ee59e3768bf7bde11598b04fc178..135a67e31275f52d0843bb9645491e0f0fc4dc24 100644 (file)
@@ -61,9 +61,8 @@ _start:
           which grow downwards).  */
        pushq %rsp
 
-       /* Pass address of our own entry points to .fini and .init.  */
-       movq __libc_csu_init@GOTPCREL(%rip), %rcx
-       movq __libc_csu_fini@GOTPCREL(%rip), %r8
+       xorl %r8d, %r8d
+       xorl %ecx, %ecx
 
        movq main_stub@GOTPCREL(%rip), %rdi