From: Jakub Jelinek <jakub@redhat.com>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Glibc hackers <libc-hacker@sources.redhat.com>
Subject: [PATCH] Better ld -pie bug workaround for nscd
Date: Tue, 22 Apr 2008 09:06:00 -0000 [thread overview]
Message-ID: <20080422091608.GI3726@sunsite.mff.cuni.cz> (raw)
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
reply other threads:[~2008-04-22 9:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080422091608.GI3726@sunsite.mff.cuni.cz \
--to=jakub@redhat.com \
--cc=drepper@redhat.com \
--cc=libc-hacker@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).