From: Laurent Bercot <ska-dietlibc@skarnet.org>
To: musl@lists.openwall.com
Subject: Re: Transition path for removing lazy init of thread pointer
Date: Tue, 25 Mar 2014 06:35:02 +0000 [thread overview]
Message-ID: <53312396.5060307@skarnet.org> (raw)
In-Reply-To: <20140325015531.GB23474@brightrain.aerifal.cx>
On 25/03/2014 01:55, Rich Felker wrote:
> The mandatory syscall is set_thread_area or equivalent, e.g.
> arch_prctl on x86_64. It's there because most archs need a syscall to
> set the thread pointer used for accessing TLS. Even in single-threaded
> programs, there are reasons one may want to have it.
>
> The big reason is that, on most archs, stack protector's canary value
> is stored at a fixed offset from the thread pointer rather than in a
> global, so stack protector can't work without the thread pointer being
> initialized. Up to now we've tried to detect whether stack protector
> is used based on symbol references to __stack_chk_fail, but this check
> gives a false negative (and thus crashing programs) if gcc optimizes
> out the check to __stack_chk_fail but not the load of the canary, e.g.
> in the program: int main() { exit(0); }
That's a good reason indeed.
I take it you're still hell-bent against compile-time options ? Because
a musl compile-time option "I don't want this musl to support stack
protector, yes I know it will crash programs compiled with it, but I'm
a big boy and know what I'm doing" would be great for OCD people like
me who like their strace clean. :)
> The other main reason is that lazy initialization is a lot more
> expensive at runtime.
That's not a good reason for single-threaded programs.
> So despite always initializing the thread pointer kinda looking like
> "bloat" from a minimal-program standpoint, it's really a major step
> forward in debloating and simplifying lots of code.
I totally understand and approve for multi-threaded programs and
programs using stack protection. I just wish there were a special
optimization for "int main() { return 0; }".
--
Laurent
next prev parent reply other threads:[~2014-03-25 6:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 17:49 Rich Felker
2014-03-24 23:04 ` Rich Felker
2014-03-24 23:44 ` Justin Cormack
2014-03-25 0:01 ` Laurent Bercot
2014-03-25 1:55 ` Rich Felker
2014-03-25 6:35 ` Laurent Bercot [this message]
2014-03-25 7:11 ` Rich Felker
2014-03-25 0:58 ` Rich Felker
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=53312396.5060307@skarnet.org \
--to=ska-dietlibc@skarnet.org \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).