From c383f4857f1696c4beb782db36323f46f0c4f6de Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sun, 12 Mar 2023 03:45:37 +0200 Subject: [PATCH] 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