]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Mark internal nss symbols with attribute_hidden [BZ #18822]
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 21 Aug 2017 12:31:02 +0000 (05:31 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 21 Aug 2017 12:31:19 +0000 (05:31 -0700)
Mark internal nss symbols with attribute_hidden to allow direct access
within libc.so and libc.a without using GOT nor PLT.

Tested on x86-64 with and without --disable-nscd.

[BZ #18822]
* grp/initgroups.c (__nss_group_database): Removed.
(__nss_initgroups_database): Likewise.
* nscd/gai.c (__nss_hosts_database): Likewise.
* nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): Likewise.
* posix/tst-rfc3484-2.c (__nss_hosts_database): Likewise.
* posix/tst-rfc3484-3.c (__nss_hosts_database): Likewise.
* posix/tst-rfc3484.c (__nss_hosts_database): Likewise.
* sysdeps/posix/getaddrinfo.c (__nss_hosts_database): Likewise.
* nss/getXXent.c (INTERNAL (REENTRANT_GETNAME)): Add
attribute_hidden.
* nss/nsswitch.c (__nss_database_custom): Define only if
USE_NSCD is defined.
(__nss_configure_lookup): Use __nss_database_custom only if
USE_NSCD is defined.
* nss/nsswitch.h (__nss_database_custom): Declare only if
USE_NSCD is defined.  Add attribute_hidden.
(__nss_setent): Add attribute_hidden.
(__nss_endent): Likewise.
(__nss_getent_r): Likewise.
(__nss_getent): Likewise.
(DEFINE_DATABASE): Declare __nss_##arg##_database.

ChangeLog
grp/initgroups.c
nscd/gai.c
nss/XXX-lookup.c
nss/getXXent.c
nss/nsswitch.c
nss/nsswitch.h
posix/tst-rfc3484-2.c
posix/tst-rfc3484-3.c
posix/tst-rfc3484.c
sysdeps/posix/getaddrinfo.c

index 170d3ac928c71f2860708ae523e982392fe43851..680f37798657429df0d796676e21e343121008f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2017-08-21  H.J. Lu  <hongjiu.lu@intel.com>
+
+       [BZ #18822]
+       * grp/initgroups.c (__nss_group_database): Removed.
+       (__nss_initgroups_database): Likewise.
+       * nscd/gai.c (__nss_hosts_database): Likewise.
+       * nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): Likewise.
+       * posix/tst-rfc3484-2.c (__nss_hosts_database): Likewise.
+       * posix/tst-rfc3484-3.c (__nss_hosts_database): Likewise.
+       * posix/tst-rfc3484.c (__nss_hosts_database): Likewise.
+       * sysdeps/posix/getaddrinfo.c (__nss_hosts_database): Likewise.
+       * nss/getXXent.c (INTERNAL (REENTRANT_GETNAME)): Add
+       attribute_hidden.
+       * nss/nsswitch.c (__nss_database_custom): Define only if
+       USE_NSCD is defined.
+       (__nss_configure_lookup): Use __nss_database_custom only if
+       USE_NSCD is defined.
+       * nss/nsswitch.h (__nss_database_custom): Declare only if
+       USE_NSCD is defined.  Add attribute_hidden.
+       (__nss_setent): Add attribute_hidden.
+       (__nss_endent): Likewise.
+       (__nss_getent_r): Likewise.
+       (__nss_getent): Likewise.
+       (DEFINE_DATABASE): Declare __nss_##arg##_database.
+
 2017-08-20  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #18822]
index 0d5b841796f127cddaff36aac5efa2cb8e6b39d5..3e4a3de11f9144c883835a06f0459473a6d8c8dd 100644 (file)
@@ -36,8 +36,6 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
                                                    long int *, long int *,
                                                    gid_t **, long int, int *);
 
-extern service_user *__nss_group_database attribute_hidden;
-service_user *__nss_initgroups_database;
 static bool use_initgroups_entry;
 
 
index a1aeadadc3ea02cb68453a437249e77be53b5782..084a1fe68ae8613a9328f4f1f575718604da776e 100644 (file)
@@ -43,6 +43,3 @@
 #ifdef HAVE_LIBIDN
 # include <libidn/idn-stub.c>
 #endif
-
-/* Some variables normally defined in libc.  */
-service_user *__nss_hosts_database;
index 49417691b2f0a451358c90e58935141a428168ef..839c96e194372e50db74012299cd735382dc4bee 100644 (file)
@@ -52,8 +52,6 @@
 #define DEFAULT_CONFIG NULL
 #endif
 
-service_user *DATABASE_NAME_SYMBOL attribute_hidden;
-
 int
 DB_LOOKUP_FCT (service_user **ni, const char *fct_name, const char *fct2_name,
               void **fctp)
index aad374197f27a506dbbabda80e2271d0618218f8..31bd24b92471a5d2a9dfe223d397ee676cb876a1 100644 (file)
@@ -56,7 +56,7 @@
 /* Prototype of the reentrant version.  */
 extern int INTERNAL (REENTRANT_GETNAME) (LOOKUP_TYPE *resbuf, char *buffer,
                                         size_t buflen, LOOKUP_TYPE **result
-                                        H_ERRNO_PARM);
+                                        H_ERRNO_PARM) attribute_hidden;
 
 /* We need to protect the dynamic buffer handling.  */
 __libc_lock_define_initialized (static, lock);
index 8f31658523b9a71b6b1e0119b5edfd9a0fd6e919..834bef6f9c7844a78435d5e3f6f295cc9940f371 100644 (file)
@@ -73,8 +73,10 @@ static const struct
 };
 #define ndatabases (sizeof (databases) / sizeof (databases[0]))
 
+#ifdef USE_NSCD
 /* Flags whether custom rules for database is set.  */
 bool __nss_database_custom[NSS_DBSIDX_max];
+#endif
 
 
 __libc_lock_define_initialized (static, lock)
@@ -304,7 +306,9 @@ __nss_configure_lookup (const char *dbname, const char *service_line)
 
   /* Install new rules.  */
   *databases[cnt].dbp = new_db;
+#ifdef USE_NSCD
   __nss_database_custom[cnt] = true;
+#endif
 
   __libc_lock_unlock (lock);
 
index 2b86d63ddbaf7ba0f42eaf11df40acfd47e1ebf9..ab0a512d402f67be833565c7b1bd50b76d0f9879 100644 (file)
@@ -96,17 +96,19 @@ typedef struct name_database
 } name_database;
 
 
+#ifdef USE_NSCD
 /* Indices into DATABASES in nsswitch.c and __NSS_DATABASE_CUSTOM.  */
 enum
   {
-#define DEFINE_DATABASE(arg) NSS_DBSIDX_##arg,
-#include "databases.def"
-#undef DEFINE_DATABASE
+# define DEFINE_DATABASE(arg) NSS_DBSIDX_##arg,
+# include "databases.def"
+# undef DEFINE_DATABASE
     NSS_DBSIDX_max
   };
 
 /* Flags whether custom rules for database is set.  */
-extern bool __nss_database_custom[NSS_DBSIDX_max];
+extern bool __nss_database_custom[NSS_DBSIDX_max] attribute_hidden;
+#endif
 
 /* Warning for NSS functions, which don't require dlopen if glibc
    was built with --enable-static-nss.  */
@@ -180,11 +182,13 @@ extern void __nss_setent (const char *func_name,
                          db_lookup_function lookup_fct,
                          service_user **nip, service_user **startp,
                          service_user **last_nip, int stayon,
-                         int *stayon_tmp, int res);
+                         int *stayon_tmp, int res)
+     attribute_hidden;
 extern void __nss_endent (const char *func_name,
                          db_lookup_function lookup_fct,
                          service_user **nip, service_user **startp,
-                         service_user **last_nip, int res);
+                         service_user **last_nip, int res)
+     attribute_hidden;
 extern int __nss_getent_r (const char *getent_func_name,
                           const char *setent_func_name,
                           db_lookup_function lookup_fct,
@@ -192,10 +196,12 @@ extern int __nss_getent_r (const char *getent_func_name,
                           service_user **last_nip, int *stayon_tmp,
                           int res,
                           void *resbuf, char *buffer, size_t buflen,
-                          void **result, int *h_errnop);
+                          void **result, int *h_errnop)
+     attribute_hidden;
 extern void *__nss_getent (getent_r_function func,
                           void **resbuf, char **buffer, size_t buflen,
-                          size_t *buffer_size, int *h_errnop);
+                          size_t *buffer_size, int *h_errnop)
+     attribute_hidden;
 struct resolv_context;
 struct hostent;
 extern int __nss_hostname_digits_dots_context (struct resolv_context *,
@@ -221,6 +227,7 @@ libc_hidden_proto (__nss_hostname_digits_dots)
 
 /* Prototypes for __nss_*_lookup2 functions.  */
 #define DEFINE_DATABASE(arg)                               \
+  service_user *__nss_##arg##_database attribute_hidden;    \
   int __nss_##arg##_lookup2 (service_user **, const char *, \
                             const char *, void **);        \
   libc_hidden_proto (__nss_##arg##_lookup2)
index ee9281394b24810b59f52226f8314dd447e8336d..f509534ca9b99775880ba6fa90f11d6fbe4251b3 100644 (file)
@@ -58,8 +58,6 @@ _res_hconf_init (void)
 #undef USE_NSCD
 #include "../sysdeps/posix/getaddrinfo.c"
 
-service_user *__nss_hosts_database attribute_hidden;
-
 
 /* This is the beginning of the real test code.  The above defines
    (among other things) the function rfc3484_sort.  */
index c987366e4e45aa37d35bd4b780a22559b23dc0b7..ae44087a105eeeb04c51a071b7e7e10278a1d003 100644 (file)
@@ -58,8 +58,6 @@ _res_hconf_init (void)
 #undef USE_NSCD
 #include "../sysdeps/posix/getaddrinfo.c"
 
-service_user *__nss_hosts_database attribute_hidden;
-
 
 /* This is the beginning of the real test code.  The above defines
    (among other things) the function rfc3484_sort.  */
index 73c4dffcf50a84feb2986f3565cc3638417e13e0..7f191abbbc541dd4a36c840b4ea4d59995221a07 100644 (file)
@@ -58,8 +58,6 @@ _res_hconf_init (void)
 #undef USE_NSCD
 #include "../sysdeps/posix/getaddrinfo.c"
 
-service_user *__nss_hosts_database attribute_hidden;
-
 
 /* This is the beginning of the real test code.  The above defines
    (among other things) the function rfc3484_sort.  */
index f02bbbe533b289e77ca4010b4e3b6b903ec5117c..fcc5d79362b9faf55d6ce88bfcdfcd53c378c50d 100644 (file)
@@ -318,7 +318,6 @@ typedef enum nss_status (*nss_gethostbyname3_r)
 typedef enum nss_status (*nss_getcanonname_r)
   (const char *name, char *buffer, size_t buflen, char **result,
    int *errnop, int *h_errnop);
-extern service_user *__nss_hosts_database attribute_hidden;
 
 /* This function is called if a canonical name is requested, but if
    the service function did not provide it.  It tries to obtain the