public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/18801] PIE binary with STT_GNU_IFUNC symbol and TEXTREL segfaults on x86_64
Date: Mon, 10 Aug 2015 20:21:00 -0000	[thread overview]
Message-ID: <bug-18801-131-O97KZaeEVD@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-18801-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=18801

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Sriraman Tallam from comment #0)
> Created attachment 8500 [details]
> Preserve the original segment's execute permissions when protecting the page
> for writing it.
> 
> We have a PIE binary with TEXTREL and a STT_GNU_IFUNC symbol that segfaults
> at start-up.
> 
> How to reproduce the problem:
> 
> zoo.cc
> -------
> int zoo_1 () {
>   return 0;
> }
> 
> extern "C"
> void *selector () {
>   return (void *)&zoo_1;
> }
> 
> int zoo() __attribute__ ((ifunc ("selector")));
> 
> int main() {
>   return zoo ();
> }
> 
> $ g++ -mcmodel=large -pie foo.cc
> 
> $readelf -Wta ./a.out | grep TEXTREL
> 0x0000000000000016 (TEXTREL)            0x0
> 0x000000000000001e (FLAGS)              TEXTREL
> 
> $ ./a.out
> Segmentation Fault
> 
> Notes:
> * Use mcmodel=large and -pie to create Text relocations.

Please add the testcase to your patch.  Please don't use

__attribute__ ((ifunc ("selector")));

since older compilers don't support it.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  parent reply	other threads:[~2015-08-10 20:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-10 20:12 [Bug libc/18801] New: " tmsriram at google dot com
2015-08-10 20:12 ` [Bug libc/18801] " tmsriram at google dot com
2015-08-10 20:13 ` ppluzhnikov at google dot com
2015-08-10 20:21 ` hjl.tools at gmail dot com [this message]
2015-08-11 20:11 ` tmsriram at google dot com
2015-08-11 20:20 ` ppluzhnikov at google dot com
2015-08-11 20:28 ` hjl.tools at gmail dot com
2015-08-11 20:43 ` tmsriram at google dot com
2015-08-11 20:43 ` tmsriram at google dot com
2015-08-11 20:56 ` hjl.tools at gmail dot com
2015-08-11 21:03 ` tmsriram at google dot com
2015-08-11 21:05 ` hjl.tools at gmail dot com

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=bug-18801-131-O97KZaeEVD@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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).