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

Reply via email to