libc.so: Replace nscd_hash.os with libc-nscd_hash.os [BZ #22459]

Message ID 20171119194403.GA4405@gmail.com
State New, archived
Headers

Commit Message

H.J. Lu Nov. 19, 2017, 7:44 p.m. UTC
  nscd_hash.os is needed both libc.so as well as nscd.  Since nscd_hash.os
is compiled as the part of nscd, when -fstack-protector-all is used,
nscd_hash.os calls __stack_chk_fail via PLT, which leads to

FAIL: elf/check-localplt
Extra PLT reference: libc.so: __stack_chk_fail

This patch replaces nscd_hash.os with libc-nscd_hash.os in libc_pic.a
to avoid calling __stack_chk_fail via PLT inside of libc.so.

Any comments?

H.J.
---
	[BZ #22459]
	* nscd/Makefile (aux): Replace nscd_hash with libc-nscd_hash.
	* nscd/libc-nscd_hash.c: New file.
---
 nscd/Makefile         |  2 +-
 nscd/libc-nscd_hash.c | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 nscd/libc-nscd_hash.c
  

Patch

diff --git a/nscd/Makefile b/nscd/Makefile
index 095f3e53d4..7ae6518e2d 100644
--- a/nscd/Makefile
+++ b/nscd/Makefile
@@ -25,7 +25,7 @@  include ../Makeconfig
 ifneq ($(use-nscd),no)
 routines := nscd_getpw_r nscd_getgr_r nscd_gethst_r nscd_getai \
 	    nscd_initgroups nscd_getserv_r nscd_netgroup
-aux	:= nscd_helper nscd_hash
+aux	:= nscd_helper libc-nscd_hash
 endif
 
 # To find xmalloc.c
diff --git a/nscd/libc-nscd_hash.c b/nscd/libc-nscd_hash.c
new file mode 100644
index 0000000000..743f1adfb3
--- /dev/null
+++ b/nscd/libc-nscd_hash.c
@@ -0,0 +1,19 @@ 
+/* Used in libc.so to avoid calling __stack_chk_fail via PLT.
+   Copyright (C) 2017 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; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <nscd_hash.c>