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

            Bug ID: 78796
           Summary: TLS fails to link on aarch64 with -mcmodel=large
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

/* { dg-do run } */
/* { dg-options "-O2" } */
/* { dg-additional-options "-mcmodel=large" { target aarch64-*-* } } */
/* { dg-require-effective-target tls } */

struct S { int a, b, c, d, e; };
struct S t;
__thread struct S s;

__attribute__((used, noinline, noclone)) void
foo (int *x, int *y)
{
  asm volatile ("" : : "g" (x), "g" (y) : "memory");
  if (*x != 1 || *y != 2)
    __builtin_abort ();
}

__attribute__((used, noinline, noclone)) void
bar (void)
{
  foo (&t.c, &s.c);
}

int
main ()
{
  t.c = 1;
  s.c = 2;
  bar ();
  return 0;
}

fails to link on aarch64, with:
/usr/bin/ld: /tmp/cctoEMbM.o(.text+0x40): R_AARCH64_ABS64 used with TLS symbol
.LANCHOR0
/usr/bin/ld: /tmp/cctoEMbM.o(.text.startup+0x40): R_AARCH64_ABS64 used with TLS
symbol .LANCHOR0
or with additional -fno-section-anchors just complaining that R_AARCH64_ABS64
used with TLS symbol s.  The bug affects 4.8, 5, 6, I think it has been fixed
with r237607.

Reply via email to