Fix linknamespace errors and local-plt-usages in nss_files.

Message ID 20210714135808.3555370-1-stli@linux.ibm.com
State New
Headers show
Series
  • Fix linknamespace errors and local-plt-usages in nss_files.
Related show

Commit Message

H.J. Lu via Libc-alpha July 14, 2021, 1:58 p.m.
After commit f9c8b11ed7726b858cd7b7cea0d3d7c5233d78cf
"nss: Access nss_files through direct references",
when building with -Os, multiple conform/.../linknamespace tests
and elf/check-localplt are failing:
Extra PLT reference: libc.so: fgetc_unlocked
Extra PLT reference: libc.so: getline

Or e.g.:
[initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endaliasent -> [libc.a(files-alias.o)] feof_unlocked
[initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endaliasent -> [libc.a(files-alias.o)] fgetc_unlocked
[initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endnetgrent -> [libc.a(files-netgrp.o)] getline

This patch is using the hidden symbols where possible.
Instead of fputc_unlocked, __putc_unlocked is used.
(Compare to commit eeaa19f75e52d2d48074ae0c423f2311d67c42c6
"mntent: Use __putc_unlocked instead of fputc_unlocked")
---
 nss/nss_files/files-alias.c      | 4 ++--
 nss/nss_files/files-initgroups.c | 4 ++--
 nss/nss_files/files-netgrp.c     | 6 +++---
 nss/nss_readline.c               | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

-- 
2.31.1

Comments

Andreas Schwab July 14, 2021, 2:13 p.m. | #1
On Jul 14 2021, Stefan Liebler via Libc-alpha wrote:

> After commit f9c8b11ed7726b858cd7b7cea0d3d7c5233d78cf

> "nss: Access nss_files through direct references",

> when building with -Os, multiple conform/.../linknamespace tests

> and elf/check-localplt are failing:

> Extra PLT reference: libc.so: fgetc_unlocked

> Extra PLT reference: libc.so: getline

>

> Or e.g.:

> [initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endaliasent -> [libc.a(files-alias.o)] feof_unlocked

> [initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endaliasent -> [libc.a(files-alias.o)] fgetc_unlocked

> [initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endnetgrent -> [libc.a(files-netgrp.o)] getline

>

> This patch is using the hidden symbols where possible.

> Instead of fputc_unlocked, __putc_unlocked is used.

> (Compare to commit eeaa19f75e52d2d48074ae0c423f2311d67c42c6

> "mntent: Use __putc_unlocked instead of fputc_unlocked")


Ok.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."
H.J. Lu via Libc-alpha July 14, 2021, 3 p.m. | #2
On 14/07/2021 16:13, Andreas Schwab wrote:
> On Jul 14 2021, Stefan Liebler via Libc-alpha wrote:

> 

>> After commit f9c8b11ed7726b858cd7b7cea0d3d7c5233d78cf

>> "nss: Access nss_files through direct references",

>> when building with -Os, multiple conform/.../linknamespace tests

>> and elf/check-localplt are failing:

>> Extra PLT reference: libc.so: fgetc_unlocked

>> Extra PLT reference: libc.so: getline

>>

>> Or e.g.:

>> [initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endaliasent -> [libc.a(files-alias.o)] feof_unlocked

>> [initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endaliasent -> [libc.a(files-alias.o)] fgetc_unlocked

>> [initial] glob -> [libc.a(glob.o)] __getpwnam_r -> [libc.a(getpwnam_r.o)] __nss_database_custom -> [libc.a(nsswitch.o)] __nss_module_get_function -> [libc.a(nss_module.o)] __nss_files_functions -> [libc.a(nss_files_functions.o)] _nss_files_endnetgrent -> [libc.a(files-netgrp.o)] getline

>>

>> This patch is using the hidden symbols where possible.

>> Instead of fputc_unlocked, __putc_unlocked is used.

>> (Compare to commit eeaa19f75e52d2d48074ae0c423f2311d67c42c6

>> "mntent: Use __putc_unlocked instead of fputc_unlocked")

> 

> Ok.

> 

> Andreas.

> 


Committed.

Thanks,
Stefan

Patch

diff --git a/nss/nss_files/files-alias.c b/nss/nss_files/files-alias.c
index 8c6e176ff6..2a4023b9a9 100644
--- a/nss/nss_files/files-alias.c
+++ b/nss/nss_files/files-alias.c
@@ -189,7 +189,7 @@  get_next_alias (FILE *stream, const char *match, struct aliasent *result,
 		      if (listfile != NULL
 			  && (old_line = __strdup (line)) != NULL)
 			{
-			  while (! feof_unlocked (listfile))
+			  while (! __feof_unlocked (listfile))
 			    {
 			      if (room_left < 2)
 				{
@@ -269,7 +269,7 @@  get_next_alias (FILE *stream, const char *match, struct aliasent *result,
 		     just read character.  */
 		  int ch;
 
-		  ch = fgetc_unlocked (stream);
+		  ch = __getc_unlocked (stream);
 		  if (ch == EOF || ch == '\n' || !isspace (ch))
 		    {
 		      size_t cnt;
diff --git a/nss/nss_files/files-initgroups.c b/nss/nss_files/files-initgroups.c
index b44211e50b..d221335902 100644
--- a/nss/nss_files/files-initgroups.c
+++ b/nss/nss_files/files-initgroups.c
@@ -55,10 +55,10 @@  _nss_files_initgroups_dyn (const char *user, gid_t group, long int *start,
     {
       fpos_t pos;
       fgetpos (stream, &pos);
-      ssize_t n = getline (&line, &linelen, stream);
+      ssize_t n = __getline (&line, &linelen, stream);
       if (n < 0)
 	{
-	  if (! feof_unlocked (stream))
+	  if (! __feof_unlocked (stream))
 	    status = ((*errnop = errno) == ENOMEM
 		      ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL);
 	  break;
diff --git a/nss/nss_files/files-netgrp.c b/nss/nss_files/files-netgrp.c
index 75bfbd9e44..82cc201b85 100644
--- a/nss/nss_files/files-netgrp.c
+++ b/nss/nss_files/files-netgrp.c
@@ -77,9 +77,9 @@  _nss_files_setnetgrent (const char *group, struct __netgrent *result)
       status = NSS_STATUS_NOTFOUND;
       result->cursor = result->data;
 
-      while (!feof_unlocked (fp))
+      while (!__feof_unlocked (fp))
 	{
-	  ssize_t curlen = getline (&line, &line_len, fp);
+	  ssize_t curlen = __getline (&line, &line_len, fp);
 	  int found;
 
 	  if (curlen < 0)
@@ -111,7 +111,7 @@  _nss_files_setnetgrent (const char *group, struct __netgrent *result)
 		result->cursor -= 2;
 
 	      /* Get next line.  */
-	      curlen = getline (&line, &line_len, fp);
+	      curlen = __getline (&line, &line_len, fp);
 	      if (curlen <= 0)
 		break;
 
diff --git a/nss/nss_readline.c b/nss/nss_readline.c
index a2f397a11f..ddf2b8962f 100644
--- a/nss/nss_readline.c
+++ b/nss/nss_readline.c
@@ -42,7 +42,7 @@  __nss_readline (FILE *fp, char *buf, size_t len, off64_t *poffset)
       buf[len - 1] = '\xff';        /* Marker to recognize truncation.  */
       if (__fgets_unlocked (buf, len, fp) == NULL)
         {
-          if (feof_unlocked (fp))
+          if (__feof_unlocked (fp))
             {
               __set_errno (ENOENT);
               return ENOENT;