This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/18801] PIE binary with STT_GNU_IFUNC symbol and TEXTREL segfaults on x86_64


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]