git: c383f4857f16 - main - lib/csu: do not compile the body of handle_static_init() for PIC build at all

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 12 Mar 2023 21:49:35 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=c383f4857f1696c4beb782db36323f46f0c4f6de

commit c383f4857f1696c4beb782db36323f46f0c4f6de
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-03-12 01:45:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-03-12 21:47:41 +0000

    lib/csu: do not compile the body of handle_static_init() for PIC build at all
    
    The referenced symbols that provide init array boundaries are weak,
    hidden, and undefined.  The code that iterates over that arrays is not
    used for the case when libc is compiled as dso.
    
    This should fix linking with ld.bfd.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 weeks
---
 lib/libc/csu/libc_start1.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/libc/csu/libc_start1.c b/lib/libc/csu/libc_start1.c
index 346409e3f370..d6a973bf0fe0 100644
--- a/lib/libc/csu/libc_start1.c
+++ b/lib/libc/csu/libc_start1.c
@@ -94,6 +94,7 @@ finalizer(void)
 static void
 handle_static_init(int argc, char **argv, char **env)
 {
+#ifndef PIC
 	void (*fn)(int, char **, char **);
 	size_t array_size, n;
 
@@ -115,6 +116,7 @@ handle_static_init(int argc, char **argv, char **env)
 		if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1)
 			fn(argc, argv, env);
 	}
+#endif
 }
 
 static void