glibc/elf/tst-linkall-static.c
Carlos O'Donell 84aa75162c Bug 20918 - Building with --enable-nss-crypt fails tst-linkall-static
Some configurations may use NSS cryptographic routines but have no
static library for those routines. The following changes allow glibc to
be built and tested with --enable-nss-crypt, but without having a static
NSS library. At a high level the change does two things:

(1) Detect at configure time if static NSS crypto libraries are
    available.  Assumes libfreebl3.a (instead of the existing Fedora
    libfreebl.a which is incomplete) which matches libfreebl3.so.

(2) If static NSS crypto libraries are _not_ available then adjust the
    way in which we build tst-linkall-static. This includes excluding a
    reference to crypt and not linking against libcrypt.a, all of which
    will fail otherwise.

Testing assumptions:
* Static library is named libfreebl3.a (not libfreebl.a as is currently
  provided in Fedora), matching libfreebl3.so shared link name.

Tested on x86_64 on Fedora with:

(a) --enable-nss-crypt, with no static NSS library support: PASS
    (previous FAIL)

(b) --enable-nss-crypt, with faked static NSS library support: PASS
    (unsupported)
	* Requires changing elf/Makefile to include a stub
	  /lib64/libfreebl3.a for testing purposes.

(c) --disable-nss-crypt: PASS
    (default)

No regressions on x86_64.

For details see:
https://www.sourceware.org/ml/libc-alpha/2016-11/msg00647.html
2016-12-02 15:39:09 -05:00

48 lines
1.7 KiB
C

/* Test static linking against multiple libraries, to find symbol conflicts.
Copyright (C) 2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; see the file COPYING.LIB. If
not, see <http://www.gnu.org/licenses/>. */
#include <math.h>
#include <pthread.h>
#include <crypt.h>
#include <resolv.h>
#include <dlfcn.h>
#include <utmp.h>
#include <aio.h>
#include <netdb.h>
/* These references force linking the executable against central
functions in the static libraries, pulling significant parts of
each library into the link. */
void *references[] =
{
&pow, /* libm */
&pthread_create, /* libpthread */
#if USE_CRYPT
&crypt, /* libcrypt */
#endif
&res_send, /* libresolv */
&dlopen, /* libdl */
&login, /* libutil */
&aio_init, /* librt */
&getaddrinfo_a, /* libanl */
};
/* This is a link-time test. There is nothing to run here. */
#define TEST_FUNCTION 0
#include "../test-skeleton.c"