* [PATCH] Better ld -pie bug workaround for nscd
@ 2008-04-22 9:06 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2008-04-22 9:06 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-04-22 9:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-22 9:06 [PATCH] Better ld -pie bug workaround for nscd Jakub Jelinek
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).