1 From a6c82b6642871e1c68f3839e090b055bee4254b0 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
3 Date: Tue, 21 Sep 2021 12:47:28 +0200
4 Subject: [PATCH] update startup data structs for glibc >= 2.34
6 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2005910
7 Fixes: https://gitlab.com/freepascal.org/fpc/source/-/issues/39295
9 rtl/linux/aarch64/cprt0.as | 6 ++----
10 rtl/linux/i386/si_c21.inc | 7 +++----
11 rtl/linux/powerpc64/cprt0.as | 4 ++--
12 rtl/linux/powerpc64/gprt0.as | 4 ++--
13 rtl/linux/powerpc64/si_c.inc | 7 ++-----
14 rtl/linux/powerpc64/si_g.inc | 7 ++-----
15 6 files changed, 13 insertions(+), 22 deletions(-)
17 diff --git a/rtl/linux/aarch64/cprt0.as b/rtl/linux/aarch64/cprt0.as
18 index fd83610fbc..c8f2ca4baa 100644
19 --- a/rtl/linux/aarch64/cprt0.as
20 +++ b/rtl/linux/aarch64/cprt0.as
21 @@ -41,10 +41,8 @@ _start:
22 init, fini, rtld_fini, stack_end) */
23 adrp x0,:got:PASCALMAIN
24 ldr x0,[x0,#:got_lo12:PASCALMAIN]
25 - adrp x3,:got:__libc_csu_init
26 - ldr x3,[x3,#:got_lo12:__libc_csu_init]
27 - adrp x4,:got:__libc_csu_fini
28 - ldr x4,[x4,#:got_lo12:__libc_csu_fini]
29 + mov x3, #0 /* Used to be init. */
30 + mov x4, #0 /* Used to be fini. */
33 /* This should never happen */
34 diff --git a/rtl/linux/i386/si_c21.inc b/rtl/linux/i386/si_c21.inc
35 index 71df29b6ef..084cdcf3ce 100644
36 --- a/rtl/linux/i386/si_c21.inc
37 +++ b/rtl/linux/i386/si_c21.inc
42 -procedure __libc_csu_init; cdecl; external;
43 -procedure __libc_csu_fini; cdecl; external;
44 procedure libc_start_main; external name '__libc_start_main';
45 procedure libc_exit(code: longint); cdecl; external name 'exit';
47 @@ -93,8 +91,9 @@ procedure _FPC_libc21_start; assembler; nostackframe; public name '_start';
48 pushl %esp { stack_end }
49 pushl %edx { function to be registered with
50 atexit(), passed by loader }
51 - pushl $__libc_csu_fini
52 - pushl $__libc_csu_init
53 + { This used to be the addresses of .fini and .init. }
56 pushl %esi { Push second argument: argv. }
57 pushl %ecx { Push first argument: argc. }
59 diff --git a/rtl/linux/powerpc64/cprt0.as b/rtl/linux/powerpc64/cprt0.as
60 index 2b8309d4bf..3eace2813d 100644
61 --- a/rtl/linux/powerpc64/cprt0.as
62 +++ b/rtl/linux/powerpc64/cprt0.as
63 @@ -351,8 +351,8 @@ _restvr_31: addi r12,r0,-16
65 .quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
67 - .quad __libc_csu_init
68 - .quad __libc_csu_fini
69 + .quad 0 /* Used to be init. */
70 + .quad 0 /* Used to be fini. */
71 .size start_adresses, .-start_addresses
74 diff --git a/rtl/linux/powerpc64/gprt0.as b/rtl/linux/powerpc64/gprt0.as
75 index de31b6b08d..6b6fc9011b 100644
76 --- a/rtl/linux/powerpc64/gprt0.as
77 +++ b/rtl/linux/powerpc64/gprt0.as
78 @@ -351,8 +351,8 @@ _restvr_31: addi r12,r0,-16
80 .quad 0 /* was _SDA_BASE_ but not in 64-bit ABI*/
82 - .quad __libc_csu_init
83 - .quad __libc_csu_fini
84 + .quad 0 /* Used to be init. */
85 + .quad 0 /* Used to be fini. */
86 .size start_adresses, .-start_addresses
89 diff --git a/rtl/linux/powerpc64/si_c.inc b/rtl/linux/powerpc64/si_c.inc
90 index c7e5e353a0..2833258c93 100644
91 --- a/rtl/linux/powerpc64/si_c.inc
92 +++ b/rtl/linux/powerpc64/si_c.inc
93 @@ -657,9 +657,6 @@ procedure _restfpr_30; cdecl; public; assembler; nostackframe;
95 ******************************************************************************}
97 -procedure __libc_csu_init; cdecl; external;
98 -procedure __libc_csu_fini; cdecl; external;
100 procedure __libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl; external;
103 @@ -724,8 +721,8 @@ procedure main_stub(argc: longint; argv, envp: ppchar); cdecl; assembler; nostac
105 = (sda_base: nil; {* was _SDA_BASE_ but not in 64-bit ABI }
107 - libc_csu_init: @__libc_csu_init;
108 - libc_csu_fini: @__libc_csu_fini
109 + libc_csu_init: nil;
114 diff --git a/rtl/linux/powerpc64/si_g.inc b/rtl/linux/powerpc64/si_g.inc
115 index 8c99a39bc6..58cdf19f9c 100644
116 --- a/rtl/linux/powerpc64/si_g.inc
117 +++ b/rtl/linux/powerpc64/si_g.inc
118 @@ -657,9 +657,6 @@ procedure _restfpr_30; cdecl; public; assembler; nostackframe;
120 ******************************************************************************}
122 -procedure __libc_csu_init; cdecl; external;
123 -procedure __libc_csu_fini; cdecl; external;
125 procedure __libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl; external;
128 @@ -745,8 +742,8 @@ procedure main_stub(argc: longint; argv, envp: ppchar); cdecl; assembler; nostac
130 = (sda_base: nil; {* was _SDA_BASE_ but not in 64-bit ABI }
132 - libc_csu_init: @__libc_csu_init;
133 - libc_csu_fini: @__libc_csu_fini
134 + libc_csu_init: nil;
138 procedure call_libc_start_main(r3,r4,r5,r6,r7,r8,r9: pointer); cdecl;