This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Better ld -pie bug workaround for nscd


Hi!

Using -fpic is too heavy hammer for the workaround, all accesses will
then be function calls, which isn't needed.  Using initial-exec tls model
works around the bug too, and the code is far more efficient (and eventually
when ld is fixed, ld -pie can transition that to local-exec to make it even
more efficient).

The unrelated change to make dbs hidden (note, can't use attribute_hidden,
as connections.o isn't -DSHARED) seems to turn of a bunch relocations
against dbs into relative relocations.

2008-04-22  Jakub Jelinek  <jakub@redhat.com>

	* nscd/Makefile (nscd-cflags): Set back to -fpie.
	* nscd/nscd.h (mem_in_flight): Add attribute_tls_model_ie.
	* nscd/connections.c (mem_in_flight): Likewise.

	* nscd/nscd.h (dbs): Make hidden.
	
--- libc/nscd/Makefile.jj	2008-04-22 09:08:33.000000000 +0200
+++ libc/nscd/Makefile	2008-04-22 10:41:10.000000000 +0200
@@ -90,8 +90,7 @@ CFLAGS-nscd_initgroups.c = -fexceptions
 
 nscd-cflags = -DIS_IN_nscd=1 -D_FORTIFY_SOURCE=2
 ifeq (yesyes,$(have-fpie)$(build-shared))
-#nscd-cflags += -fpie
-nscd-cflags += -fpic
+nscd-cflags += -fpie
 endif
 ifeq (yes,$(have-ssp))
 nscd-cflags += -fstack-protector
--- libc/nscd/nscd.h.jj	2008-04-22 09:08:33.000000000 +0200
+++ libc/nscd/nscd.h	2008-04-22 10:50:54.000000000 +0200
@@ -130,7 +130,7 @@ struct database_dyn
 
 
 /* Global variables.  */
-extern struct database_dyn dbs[lastdb];
+extern struct database_dyn dbs[lastdb] __attribute__ ((visibility ("hidden")));
 extern const char *const dbnames[lastdb];
 extern const char *const serv2str[LASTREQ];
 
@@ -201,7 +201,7 @@ extern __thread struct mem_in_flight
   } block[IDX_last];
 
   struct mem_in_flight *next;
-} mem_in_flight;
+} mem_in_flight attribute_tls_model_ie;
 /* Global list of the mem_in_flight variables of all the threads.  */
 extern struct mem_in_flight *mem_in_flight_list;
 
--- libc/nscd/connections.c.jj	2008-04-22 10:51:00.000000000 +0200
+++ libc/nscd/connections.c	2008-04-22 10:51:51.000000000 +0200
@@ -226,7 +226,7 @@ static int sock;
 unsigned long int client_queued;
 
 /* Data structure for recording in-flight memory allocation.  */
-__thread struct mem_in_flight mem_in_flight;
+__thread struct mem_in_flight mem_in_flight attribute_tls_model_ie;
 /* Global list of the mem_in_flight variables of all the threads.  */
 struct mem_in_flight *mem_in_flight_list;
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]