public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol
@ 2015-02-28  9:24 hjl.tools at gmail dot com
  2015-02-28 20:11 ` [Bug target/65248] " hjl.tools at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-02-28  9:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

            Bug ID: 65248
           Summary: [5 Regression] Copy relocation in PIE against
                    protected symbol
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: tmsriram at google dot com

Copy relocation doesn't work with protected symbol and BFD linker
enforces it.  GCC 5 uses copy relocation in PIE. It either causes
linker error or run-time error:

[hjl@gnu-6 copyreloc-prot]$ cat x.c
extern int a;

extern void bar (void);

int main()
{
  bar ();
  if (a != 30)
    __builtin_abort();
  return 0;
}
[hjl@gnu-6 copyreloc-prot]$ cat bar.c
int a;

__attribute__((visibility("protected"))) int a;

void
bar ()
{
  a = 30;
}
[hjl@gnu-6 copyreloc-prot]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -fpie    -c -o x.o x.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -fpic    -c -o bar.o
bar.c
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie  -shared -o libbar.so
bar.o
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -o x x.o libbar.so
-Wl,-R,.
/usr/local/bin/ld: copy reloc against protected `a' is invalid
/usr/local/bin/ld: failed to set dynamic section sizes: Bad value
collect2: error: ld returned 1 exit status
make: *** [x] Error 1
[hjl@gnu-6 copyreloc-prot]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -pie -O3 -o x x.o libbar.so
-Wl,-R,. -fuse-ld=gold
[hjl@gnu-6 copyreloc-prot]$ ./x
Aborted
[hjl@gnu-6 copyreloc-prot]$


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] [5 Regression] Copy relocation in PIE against protected symbol
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
@ 2015-02-28 20:11 ` hjl.tools at gmail dot com
  2015-03-02  8:43 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-02-28 20:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-28
   Target Milestone|---                         |5.0
     Ever confirmed|0                           |1

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
A patch is posted at

https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01746.html


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] [5 Regression] Copy relocation in PIE against protected symbol
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
  2015-02-28 20:11 ` [Bug target/65248] " hjl.tools at gmail dot com
@ 2015-03-02  8:43 ` rguenth at gcc dot gnu.org
  2015-03-04 14:13 ` [Bug target/65248] " hjl.tools at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-03-02  8:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-*-*, i?86-*-*
           Priority|P3                          |P1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] Copy relocation in PIE against protected symbol
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
  2015-02-28 20:11 ` [Bug target/65248] " hjl.tools at gmail dot com
  2015-03-02  8:43 ` rguenth at gcc dot gnu.org
@ 2015-03-04 14:13 ` hjl.tools at gmail dot com
  2015-03-04 23:34 ` [Bug target/65248] Copy relocation against protected symbol doesn't work hjl.tools at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-03-04 14:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[5 Regression] Copy         |Copy relocation in PIE
                   |relocation in PIE against   |against protected symbol
                   |protected symbol            |

--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
It never worked with normal executable.  I proposed a solution:

https://groups.google.com/forum/#!topic/x86-64-abi/Nbfw6bX0DpI


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] Copy relocation against protected symbol doesn't work
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
                   ` (2 preceding siblings ...)
  2015-03-04 14:13 ` [Bug target/65248] " hjl.tools at gmail dot com
@ 2015-03-04 23:34 ` hjl.tools at gmail dot com
  2015-03-06 13:28 ` hjl.tools at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-03-04 23:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
BInutils, glibc and GCC patches are posted at

https://gcc.gnu.org/ml/gcc-patches/2015-03/msg00257.html


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] Copy relocation against protected symbol doesn't work
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
                   ` (3 preceding siblings ...)
  2015-03-04 23:34 ` [Bug target/65248] Copy relocation against protected symbol doesn't work hjl.tools at gmail dot com
@ 2015-03-06 13:28 ` hjl.tools at gmail dot com
  2015-03-27 18:26 ` hjl at gcc dot gnu.org
  2015-03-27 18:31 ` hjl.tools at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-03-06 13:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugdal at aerifal dot cx

--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
*** Bug 55012 has been marked as a duplicate of this bug. ***


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] Copy relocation against protected symbol doesn't work
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
                   ` (4 preceding siblings ...)
  2015-03-06 13:28 ` hjl.tools at gmail dot com
@ 2015-03-27 18:26 ` hjl at gcc dot gnu.org
  2015-03-27 18:31 ` hjl.tools at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: hjl at gcc dot gnu.org @ 2015-03-27 18:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

--- Comment #5 from hjl at gcc dot gnu.org <hjl at gcc dot gnu.org> ---
Author: hjl
Date: Fri Mar 27 18:11:00 2015
New Revision: 221742

URL: https://gcc.gnu.org/viewcvs?rev=221742&root=gcc&view=rev
Log:
Add default_binds_local_p_2 and use it for x86

Protected data symbol means that it can't be pre-emptied.  It doesn't mean
its address won't be external.  This is true for pointer to protected
function.  With copy relocation, address of protected data defined in the
shared library may also be external.  We only know that for sure at
run-time.  TARGET_BINDS_LOCAL_P should return false on protected data
symbol.

gcc/

    PR target/65248
    * output.h (default_binds_local_p_2): New.
    * varasm.c (default_binds_local_p_2): Renamed to ...
    (default_binds_local_p_3): This.  Don't return true on protected
    data symbol if protected data may be external.
    (default_binds_local_p): Use default_binds_local_p_3.
    (default_binds_local_p_1): Likewise.
    (default_binds_local_p_2): New.
    * config/i386/i386.c (TARGET_BINDS_LOCAL_P): Set to
    default_binds_local_p_2 if TARGET_MACHO is undefined.

gcc/testsuite/

    PR target/65248
    * gcc.target/i386/pr65248-1.c: New file.
    * gcc.target/i386/pr65248-2.c: Likewise.
    * gcc.target/i386/pr65248-3.c: Likewise.
    * gcc.target/i386/pr65248-4.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.target/i386/pr65248-1.c
    trunk/gcc/testsuite/gcc.target/i386/pr65248-2.c
    trunk/gcc/testsuite/gcc.target/i386/pr65248-3.c
    trunk/gcc/testsuite/gcc.target/i386/pr65248-4.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/output.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/varasm.c


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/65248] Copy relocation against protected symbol doesn't work
  2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
                   ` (5 preceding siblings ...)
  2015-03-27 18:26 ` hjl at gcc dot gnu.org
@ 2015-03-27 18:31 ` hjl.tools at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: hjl.tools at gmail dot com @ 2015-03-27 18:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65248

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed for GCC 5. No plan for backport.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-27 18:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-28  9:24 [Bug target/65248] New: [5 Regression] Copy relocation in PIE against protected symbol hjl.tools at gmail dot com
2015-02-28 20:11 ` [Bug target/65248] " hjl.tools at gmail dot com
2015-03-02  8:43 ` rguenth at gcc dot gnu.org
2015-03-04 14:13 ` [Bug target/65248] " hjl.tools at gmail dot com
2015-03-04 23:34 ` [Bug target/65248] Copy relocation against protected symbol doesn't work hjl.tools at gmail dot com
2015-03-06 13:28 ` hjl.tools at gmail dot com
2015-03-27 18:26 ` hjl at gcc dot gnu.org
2015-03-27 18:31 ` hjl.tools at gmail dot com

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).