From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27160 invoked by alias); 10 Aug 2015 20:21:50 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 27124 invoked by uid 48); 10 Aug 2015 20:21:46 -0000 From: "hjl.tools at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.21 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: ppluzhnikov at google dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-08/txt/msg00273.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=18801 --- Comment #1 from H.J. Lu --- (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.