public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/66912] New: Copy relocation against protected symbol doesn't work
@ 2015-07-17 13:56 nsz at gcc dot gnu.org
  2015-07-20 13:16 ` [Bug target/66912] " rearnsha at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: nsz at gcc dot gnu.org @ 2015-07-17 13:56 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66912
           Summary: Copy relocation against protected symbol doesn't work
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

same as bug 65248 but for arm and aarch64.

On aarch64, gcc -S -O -fpic compiles

__attribute__((visibility("protected"))) int n;
int f () { return n; }

into

f:
        adrp    x0, n
        ldr     w0, [x0, #:lo12:n]
        ret
        .size   f, .-f
        .protected      n
        .comm   n,4,4

so the address of n is not loaded from GOT,
which means copy reloc against it in the main
executable won't work.

The expected code is

f:
        adrp    x0, :got:n
        ldr     x0, [x0, #:got_lo12:n]
        ldr     w0, [x0]
        ret


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

* [Bug target/66912] Copy relocation against protected symbol doesn't work
  2015-07-17 13:56 [Bug target/66912] New: Copy relocation against protected symbol doesn't work nsz at gcc dot gnu.org
@ 2015-07-20 13:16 ` rearnsha at gcc dot gnu.org
  2015-07-20 14:02 ` nsz at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2015-07-20 13:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Erm, isn't that the whole point of marking the symbol 'protected'?

>From the ELF spec:

<quote>
STV_PROTECTED
    A symbol defined in the current component is protected if it is visible in
other components but not preemptable, meaning that any reference to such a
symbol from within the defining component must be resolved to the definition in
that component, even if there is a definition in another component that would
preempt by the default rules. A symbol with STB_LOCAL binding may not have
STV_PROTECTED visibility. If a symbol definition with STV_PROTECTED visibility
from a shared object is taken as resolving a reference from an executable or
another shared object, the SHN_UNDEF symbol table entry created has STV_DEFAULT
visibility.
</quote>

If we know it will resolve to the definition inside this DSO, then we don't
need to indirect via the GOT to address it.


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

* [Bug target/66912] Copy relocation against protected symbol doesn't work
  2015-07-17 13:56 [Bug target/66912] New: Copy relocation against protected symbol doesn't work nsz at gcc dot gnu.org
  2015-07-20 13:16 ` [Bug target/66912] " rearnsha at gcc dot gnu.org
@ 2015-07-20 14:02 ` nsz at gcc dot gnu.org
  2015-10-20  9:38 ` nsz at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: nsz at gcc dot gnu.org @ 2015-07-20 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from nsz at gcc dot gnu.org ---
protected only means it cannot be overridden.

so we know the symbol will be resolved to the local one,
however it may be visible externally and then the address
must be the same in the other modules which is a problem
if the main executable has a copy reloc against this symbol.


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

* [Bug target/66912] Copy relocation against protected symbol doesn't work
  2015-07-17 13:56 [Bug target/66912] New: Copy relocation against protected symbol doesn't work nsz at gcc dot gnu.org
  2015-07-20 13:16 ` [Bug target/66912] " rearnsha at gcc dot gnu.org
  2015-07-20 14:02 ` nsz at gcc dot gnu.org
@ 2015-10-20  9:38 ` nsz at gcc dot gnu.org
  2015-10-20  9:51 ` nsz at gcc dot gnu.org
  2015-10-20  9:56 ` nsz at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nsz at gcc dot gnu.org @ 2015-10-20  9:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from nsz at gcc dot gnu.org ---
Author: nsz
Date: Tue Oct 20 09:37:27 2015
New Revision: 229024

URL: https://gcc.gnu.org/viewcvs?rev=229024&root=gcc&view=rev
Log:
Fix default_binds_local_p_2 for extern protected data

gcc:

        PR target/66912
        * varasm.c (default_binds_local_p_2): Turn on extern_protected_data.

gcc/testsuite:

        PR target/66912
        * gcc.target/aarch64/pr66912.c: New.
        * gcc.target/arm/pr66912.c: New.


Added:
    trunk/gcc/testsuite/gcc.target/aarch64/pr66912.c
    trunk/gcc/testsuite/gcc.target/arm/pr66912.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/varasm.c


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

* [Bug target/66912] Copy relocation against protected symbol doesn't work
  2015-07-17 13:56 [Bug target/66912] New: Copy relocation against protected symbol doesn't work nsz at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-10-20  9:38 ` nsz at gcc dot gnu.org
@ 2015-10-20  9:51 ` nsz at gcc dot gnu.org
  2015-10-20  9:56 ` nsz at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nsz at gcc dot gnu.org @ 2015-10-20  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from nsz at gcc dot gnu.org ---
Author: nsz
Date: Tue Oct 20 09:50:58 2015
New Revision: 229030

URL: https://gcc.gnu.org/viewcvs?rev=229030&root=gcc&view=rev
Log:
Fix default_binds_local_p_2 for extern protected data

        Backport from mainline r229024
        2015-10-20  Szabolcs Nagy  <szabolcs.nagy@arm.com>

gcc:
        PR target/66912
        * varasm.c (default_binds_local_p_2): Turn on extern_protected_data.

gcc/testsuite:

        PR target/66912
        * gcc.target/aarch64/pr66912.c: New.
        * gcc.target/arm/pr66912.c: New.


Added:
    branches/gcc-5-branch/gcc/testsuite/gcc.target/aarch64/pr66912.c
    branches/gcc-5-branch/gcc/testsuite/gcc.target/arm/pr66912.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/varasm.c


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

* [Bug target/66912] Copy relocation against protected symbol doesn't work
  2015-07-17 13:56 [Bug target/66912] New: Copy relocation against protected symbol doesn't work nsz at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-10-20  9:51 ` nsz at gcc dot gnu.org
@ 2015-10-20  9:56 ` nsz at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: nsz at gcc dot gnu.org @ 2015-10-20  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

nsz at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #5 from nsz at gcc dot gnu.org ---
fixed in r229030.


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

end of thread, other threads:[~2015-10-20  9:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-17 13:56 [Bug target/66912] New: Copy relocation against protected symbol doesn't work nsz at gcc dot gnu.org
2015-07-20 13:16 ` [Bug target/66912] " rearnsha at gcc dot gnu.org
2015-07-20 14:02 ` nsz at gcc dot gnu.org
2015-10-20  9:38 ` nsz at gcc dot gnu.org
2015-10-20  9:51 ` nsz at gcc dot gnu.org
2015-10-20  9:56 ` nsz at gcc dot gnu.org

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