bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/24784] New: elf_x86_64_check_tls_transition should allow R_X86_6


From: maskray at google dot com
Subject: [Bug ld/24784] New: elf_x86_64_check_tls_transition should allow R_X86_64_GOTPCREL (-fno-plt)
Date: Sun, 07 Jul 2019 13:00:43 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=24784

            Bug ID: 24784
           Summary: elf_x86_64_check_tls_transition should allow
                    R_X86_64_GOTPCREL (-fno-plt)
           Product: binutils
           Version: 2.33 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: maskray at google dot com
  Target Milestone: ---

thread_local int a;
int main() { return a; }

% g++ -fno-plt -fpic a.cc -Wa,-mrelax-relocations=no -fuse-ld=bfd
/usr/bin/ld.bfd: /tmp/ccLggG8h.o: TLS transition from R_X86_64_TLSGD to
R_X86_64_GOTTPOFF against `a' at 0x8 in section `.text' failed
/usr/bin/ld.bfd: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

static thread_local int a;
int main() { return a; }

% g++ -fno-plt -fpic a.cc -Wa,-mrelax-relocations=no -fuse-ld=bfd
/usr/bin/ld.bfd: /tmp/ccO9KvlL.o: TLS transition from R_X86_64_TLSGD to
R_X86_64_TPOFF32 against `_ZL1a' at 0x8 in section `.text' failed
/usr/bin/ld.bfd: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

Due to -Wa,-mrelax-relocations=no, R_X86_64_GOTPCREL instead of
R_X86_64_GOTPCRELX is generated.

      a9:       callq   *(%rip)
                00000000000000ad:  R_X86_64_GOTPCREL    __tls_get_addr-4

// bfd/elf-x86-64.c:elf_x86_64_check_tls_transition
...
    if (largepic)
      return r_type == R_X86_64_PLTOFF64;
    else if (indirect_call)
      return r_type == R_X86_64_GOTPCRELX; // It should allow R_X86_64_GOTPCREL
    else
      return (r_type == R_X86_64_PC32 || r_type == R_X86_64_PLT32);

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]