build: Enable .init_array support when building with LTO

Because these symbols are not otherwise referenced, GCC would like
to remove them.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
This commit is contained in:
Victor Westerhuis 2021-11-26 20:01:18 +01:00 committed by Guillem Jover
parent 428be9e030
commit 54f8745657
2 changed files with 2 additions and 2 deletions

View File

@ -175,7 +175,7 @@ AC_CACHE_CHECK(
[[
static int rc = 1;
static void init(int argc) { if (argc == 1) rc = 0; }
void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
void (*init_func)(int argc) __attribute__((__section__(".init_array"), __used__)) = init;
int main() { return rc; }
]]
)],

View File

@ -49,4 +49,4 @@
* move them from .ctors to .init_array.
*/
void (*libbsd_init_func)(int argc, char *argv[], char *envp[])
__attribute__((__section__(".init_array"))) = setproctitle_init;
__attribute__((__section__(".init_array"), __used__)) = setproctitle_init;