public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822]
@ 2017-08-18 20:31 H.J. Lu
  2017-08-20  8:09 ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2017-08-18 20:31 UTC (permalink / raw)
  To: GNU C Library

Mark internal nss symbols with attribute_hidden to allow direct access
within libc.so and libc.a without using GOT.

OK for master?

H.J.
---
	[BZ #18822]
	* grp/initgroups.c (__nss_initgroups_database): Add
	attribute_hidden.
	* nss/getXXent.c (INTERNAL (REENTRANT_GETNAME)): Likewise.
	* nss/nsswitch.h (__nss_database_custom): Likewise.
---
 grp/initgroups.c | 2 +-
 nss/getXXent.c   | 2 +-
 nss/nsswitch.h   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/grp/initgroups.c b/grp/initgroups.c
index 0d5b841796..39fb29f43f 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -37,7 +37,7 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
 						    gid_t **, long int, int *);
 
 extern service_user *__nss_group_database attribute_hidden;
-service_user *__nss_initgroups_database;
+service_user *__nss_initgroups_database attribute_hidden;
 static bool use_initgroups_entry;
 
 
diff --git a/nss/getXXent.c b/nss/getXXent.c
index aad374197f..31bd24b924 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -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);
diff --git a/nss/nsswitch.h b/nss/nsswitch.h
index 2b86d63ddb..342f6f75d2 100644
--- a/nss/nsswitch.h
+++ b/nss/nsswitch.h
@@ -106,7 +106,7 @@ enum
   };
 
 /* 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;
 
 /* Warning for NSS functions, which don't require dlopen if glibc
    was built with --enable-static-nss.  */
-- 
2.13.5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822]
  2017-08-18 20:31 [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822] H.J. Lu
@ 2017-08-20  8:09 ` Florian Weimer
  2017-08-20 17:18   ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2017-08-20  8:09 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library, H.J. Lu

* H. J. Lu:

>  extern service_user *__nss_group_database attribute_hidden;
> -service_user *__nss_initgroups_database;
> +service_user *__nss_initgroups_database attribute_hidden;
>  static bool use_initgroups_entry;

Please use DEFINE_DATABASE in nsswitch.h instead to generate all
__nss_*_database declarations (and remove the declaration from
nss/XXX-lookup.c).

> diff --git a/nss/getXXent.c b/nss/getXXent.c
> index aad374197f..31bd24b924 100644
> --- a/nss/getXXent.c
> +++ b/nss/getXXent.c
> @@ -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;

Ideally, we should have a full complement of prototypes in include/,
so that we get some type safety here.  But until that, this part looks
fine.

>  /* 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;

The entire declaration should probably be guarded with #ifndef
USE_NSCD because if the symbol is used from nscd, it would give wrong
results.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822]
  2017-08-20  8:09 ` Florian Weimer
@ 2017-08-20 17:18   ` H.J. Lu
  2017-08-21  9:58     ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2017-08-20 17:18 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 1568 bytes --]

On Sun, Aug 20, 2017 at 1:08 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
> * H. J. Lu:
>
>>  extern service_user *__nss_group_database attribute_hidden;
>> -service_user *__nss_initgroups_database;
>> +service_user *__nss_initgroups_database attribute_hidden;
>>  static bool use_initgroups_entry;
>
> Please use DEFINE_DATABASE in nsswitch.h instead to generate all
> __nss_*_database declarations (and remove the declaration from
> nss/XXX-lookup.c).

Done.

>> diff --git a/nss/getXXent.c b/nss/getXXent.c
>> index aad374197f..31bd24b924 100644
>> --- a/nss/getXXent.c
>> +++ b/nss/getXXent.c
>> @@ -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;
>
> Ideally, we should have a full complement of prototypes in include/,
> so that we get some type safety here.  But until that, this part looks
> fine.
>
>>  /* 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;
>
> The entire declaration should probably be guarded with #ifndef
> USE_NSCD because if the symbol is used from nscd, it would give wrong
> results.

Done.

Here is the updated patch.   Tested on x86-64 with and without --disable-nscd.

OK for master?

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Mark-internal-nss-symbols-with-attribute_hidden-BZ-1.patch --]
[-- Type: text/x-patch, Size: 5622 bytes --]

From 6876672e67fb5e3a71139585ca4c16e43cfed70e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 18 Aug 2017 12:27:59 -0700
Subject: [PATCH] Mark internal nss symbols with attribute_hidden [BZ #18822]

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_initgroups_database): Removed.
	* nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): 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.
---
 grp/initgroups.c |  1 -
 nss/XXX-lookup.c |  2 --
 nss/getXXent.c   |  2 +-
 nss/nsswitch.c   |  4 ++++
 nss/nsswitch.h   | 23 +++++++++++++++--------
 5 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/grp/initgroups.c b/grp/initgroups.c
index 0d5b841796..0ffb5ceea1 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -37,7 +37,6 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
 						    gid_t **, long int, int *);
 
 extern service_user *__nss_group_database attribute_hidden;
-service_user *__nss_initgroups_database;
 static bool use_initgroups_entry;
 
 
diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
index 49417691b2..839c96e194 100644
--- a/nss/XXX-lookup.c
+++ b/nss/XXX-lookup.c
@@ -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)
diff --git a/nss/getXXent.c b/nss/getXXent.c
index aad374197f..31bd24b924 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -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);
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 8f31658523..834bef6f9c 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -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);
 
diff --git a/nss/nsswitch.h b/nss/nsswitch.h
index 2b86d63ddb..ab0a512d40 100644
--- a/nss/nsswitch.h
+++ b/nss/nsswitch.h
@@ -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)
-- 
2.13.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822]
  2017-08-20 17:18   ` H.J. Lu
@ 2017-08-21  9:58     ` Florian Weimer
  2017-08-21 11:47       ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2017-08-21  9:58 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

On 08/20/2017 07:18 PM, H.J. Lu wrote:
> diff --git a/grp/initgroups.c b/grp/initgroups.c
> index 0d5b841796..0ffb5ceea1 100644
> --- a/grp/initgroups.c
> +++ b/grp/initgroups.c
> @@ -37,7 +37,6 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
>  						    gid_t **, long int, int *);
>  
>  extern service_user *__nss_group_database attribute_hidden;
> -service_user *__nss_initgroups_database;

The declaration of __nss_group_database is no longer necessary, either.

I think these additional declarations can be removed as well"

nscd/gai.c:service_user *__nss_hosts_database;
posix/tst-rfc3484-2.c:service_user *__nss_hosts_database attribute_hidden;
posix/tst-rfc3484-3.c:service_user *__nss_hosts_database attribute_hidden;
posix/tst-rfc3484.c:service_user *__nss_hosts_database attribute_hidden;
sysdeps/posix/getaddrinfo.c:extern service_user *__nss_hosts_database
attribute_hidden;

Thanks,
Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822]
  2017-08-21  9:58     ` Florian Weimer
@ 2017-08-21 11:47       ` H.J. Lu
  2017-08-21 12:26         ` Florian Weimer
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2017-08-21 11:47 UTC (permalink / raw)
  To: Florian Weimer; +Cc: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]

On Mon, Aug 21, 2017 at 2:58 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/20/2017 07:18 PM, H.J. Lu wrote:
>> diff --git a/grp/initgroups.c b/grp/initgroups.c
>> index 0d5b841796..0ffb5ceea1 100644
>> --- a/grp/initgroups.c
>> +++ b/grp/initgroups.c
>> @@ -37,7 +37,6 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
>>                                                   gid_t **, long int, int *);
>>
>>  extern service_user *__nss_group_database attribute_hidden;
>> -service_user *__nss_initgroups_database;
>
> The declaration of __nss_group_database is no longer necessary, either.
>
> I think these additional declarations can be removed as well"
>
> nscd/gai.c:service_user *__nss_hosts_database;
> posix/tst-rfc3484-2.c:service_user *__nss_hosts_database attribute_hidden;
> posix/tst-rfc3484-3.c:service_user *__nss_hosts_database attribute_hidden;
> posix/tst-rfc3484.c:service_user *__nss_hosts_database attribute_hidden;
> sysdeps/posix/getaddrinfo.c:extern service_user *__nss_hosts_database
> attribute_hidden;
>

Here is the updated patch.  Tested on x86-64.

I will check it in shortly.

Thanks.

-- 
H.J.

[-- Attachment #2: 0001-Mark-internal-nss-symbols-with-attribute_hidden-BZ-1.patch --]
[-- Type: text/x-patch, Size: 8384 bytes --]

From 1b8ecdda717ebe4cf01f9af3d4996e5dec23855c Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 18 Aug 2017 12:27:59 -0700
Subject: [PATCH] Mark internal nss symbols with attribute_hidden [BZ #18822]

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.
---
 grp/initgroups.c            |  2 --
 nscd/gai.c                  |  3 ---
 nss/XXX-lookup.c            |  2 --
 nss/getXXent.c              |  2 +-
 nss/nsswitch.c              |  4 ++++
 nss/nsswitch.h              | 23 +++++++++++++++--------
 posix/tst-rfc3484-2.c       |  2 --
 posix/tst-rfc3484-3.c       |  2 --
 posix/tst-rfc3484.c         |  2 --
 sysdeps/posix/getaddrinfo.c |  1 -
 10 files changed, 20 insertions(+), 23 deletions(-)

diff --git a/grp/initgroups.c b/grp/initgroups.c
index 0d5b841796..3e4a3de11f 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -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;
 
 
diff --git a/nscd/gai.c b/nscd/gai.c
index a1aeadadc3..084a1fe68a 100644
--- a/nscd/gai.c
+++ b/nscd/gai.c
@@ -43,6 +43,3 @@
 #ifdef HAVE_LIBIDN
 # include <libidn/idn-stub.c>
 #endif
-
-/* Some variables normally defined in libc.  */
-service_user *__nss_hosts_database;
diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
index 49417691b2..839c96e194 100644
--- a/nss/XXX-lookup.c
+++ b/nss/XXX-lookup.c
@@ -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)
diff --git a/nss/getXXent.c b/nss/getXXent.c
index aad374197f..31bd24b924 100644
--- a/nss/getXXent.c
+++ b/nss/getXXent.c
@@ -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);
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 8f31658523..834bef6f9c 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -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);
 
diff --git a/nss/nsswitch.h b/nss/nsswitch.h
index 2b86d63ddb..ab0a512d40 100644
--- a/nss/nsswitch.h
+++ b/nss/nsswitch.h
@@ -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)
diff --git a/posix/tst-rfc3484-2.c b/posix/tst-rfc3484-2.c
index ee9281394b..f509534ca9 100644
--- a/posix/tst-rfc3484-2.c
+++ b/posix/tst-rfc3484-2.c
@@ -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.  */
diff --git a/posix/tst-rfc3484-3.c b/posix/tst-rfc3484-3.c
index c987366e4e..ae44087a10 100644
--- a/posix/tst-rfc3484-3.c
+++ b/posix/tst-rfc3484-3.c
@@ -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.  */
diff --git a/posix/tst-rfc3484.c b/posix/tst-rfc3484.c
index 73c4dffcf5..7f191abbbc 100644
--- a/posix/tst-rfc3484.c
+++ b/posix/tst-rfc3484.c
@@ -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.  */
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index f02bbbe533..fcc5d79362 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -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
-- 
2.13.5


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822]
  2017-08-21 11:47       ` H.J. Lu
@ 2017-08-21 12:26         ` Florian Weimer
  0 siblings, 0 replies; 6+ messages in thread
From: Florian Weimer @ 2017-08-21 12:26 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GNU C Library

On 08/21/2017 01:46 PM, H.J. Lu wrote:
> On Mon, Aug 21, 2017 at 2:58 AM, Florian Weimer <fweimer@redhat.com> wrote:
>> On 08/20/2017 07:18 PM, H.J. Lu wrote:
>>> diff --git a/grp/initgroups.c b/grp/initgroups.c
>>> index 0d5b841796..0ffb5ceea1 100644
>>> --- a/grp/initgroups.c
>>> +++ b/grp/initgroups.c
>>> @@ -37,7 +37,6 @@ typedef enum nss_status (*initgroups_dyn_function) (const char *, gid_t,
>>>                                                   gid_t **, long int, int *);
>>>
>>>  extern service_user *__nss_group_database attribute_hidden;
>>> -service_user *__nss_initgroups_database;
>>
>> The declaration of __nss_group_database is no longer necessary, either.
>>
>> I think these additional declarations can be removed as well"
>>
>> nscd/gai.c:service_user *__nss_hosts_database;
>> posix/tst-rfc3484-2.c:service_user *__nss_hosts_database attribute_hidden;
>> posix/tst-rfc3484-3.c:service_user *__nss_hosts_database attribute_hidden;
>> posix/tst-rfc3484.c:service_user *__nss_hosts_database attribute_hidden;
>> sysdeps/posix/getaddrinfo.c:extern service_user *__nss_hosts_database
>> attribute_hidden;
>>
> 
> Here is the updated patch.  Tested on x86-64.

Thanks, looks good.

Florian

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-08-21 12:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-18 20:31 [PATCH 2/3] Mark internal nss symbols with attribute_hidden [BZ #18822] H.J. Lu
2017-08-20  8:09 ` Florian Weimer
2017-08-20 17:18   ` H.J. Lu
2017-08-21  9:58     ` Florian Weimer
2017-08-21 11:47       ` H.J. Lu
2017-08-21 12:26         ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).