bug-binutils
[Top][All Lists]
Advanced

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

[Bug gold/20216] New: Gold should support x86-64 TLS code sequences with


From: hjl.tools at gmail dot com
Subject: [Bug gold/20216] New: Gold should support x86-64 TLS code sequences without PLT
Date: Tue, 07 Jun 2016 16:45:35 +0000

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

            Bug ID: 20216
           Summary: Gold should support x86-64 TLS code sequences without
                    PLT
           Product: binutils
           Version: 2.27 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: hjl.tools at gmail dot com
                CC: ian at airs dot com
  Target Milestone: ---
            Target: x86-64

ld supports x86-64 TLS code sequences without PLT:

commit e2cbcd9156d1606a9f2153aecd93a89fe6e29180
Author: H.J. Lu <address@hidden>
Date:   Mon Jun 6 11:06:55 2016 -0700

    Support x86-64 TLS code sequences without PLT

Gold should also support it:

address@hidden tls-10a]$ cat main.c 
#include <stdio.h>
#include <stdlib.h>

extern int * get_gd (void);
extern void set_gd (int);
extern int test_gd (int);
extern int * get_ld (void);
extern void set_ld (int);
extern int test_ld (int);

int
main ()
{
  int *p;

  p = get_gd ();
  set_gd (3);
  if (*p != 3 || !test_gd (3))
    abort ();

  p = get_ld ();
  set_ld (4);
  if (*p != 4 || !test_ld (4))
    abort ();

  printf ("PASS\n");

  return 0;
}
address@hidden tls-10a]$ cat def.c 
__thread int gd = 1;
address@hidden tls-10a]$ cat gd.S 
        .text
        .p2align 4,,15
        .globl  get_gd
        .type   get_gd, @function
get_gd:
        subq    $8, %rsp
        .byte   0x66
        leaq    address@hidden(%rip), %rdi
        .byte   0x66
        rex64
        call    address@hidden(%rip)
        addq    $8, %rsp
        ret
        .size   get_gd, .-get_gd
        .text
        .p2align 4,,15
        .globl  set_gd
        .type   set_gd, @function
set_gd:
        pushq   %rbx
        movl    %edi, %ebx
        .byte   0x66
        leaq    address@hidden(%rip), %rdi
        .value  0x6666
        rex64
        call    address@hidden
        movl    %ebx, (%rax)
        popq    %rbx
        ret
        .size   set_gd, .-set_gd
        .text
        .p2align 4,,15
        .globl  test_gd
        .type   test_gd, @function
test_gd:
        pushq   %rbx
        movl    %edi, %ebx
        .byte   0x66
        leaq    address@hidden(%rip), %rdi
        .byte   0x66
        rex64
        call    address@hidden(%rip)
        cmpl    %ebx, (%rax)
        popq    %rbx
        sete    %al
        movzbl  %al, %eax
        ret
        .size   test_gd, .-test_gd
        .section        .note.GNU-stack,"",@progbits
address@hidden tls-10a]$ cat ld.S 
        .text
        .p2align 4,,15
        .globl  get_ld
        .type   get_ld, @function
get_ld:
        subq    $8, %rsp
        leaq    address@hidden(%rip), %rdi
        call    address@hidden
        addq    $8, %rsp
        addq    address@hidden, %rax
        ret
        .size   get_ld, .-get_ld
        .text
        .p2align 4,,15
        .globl  set_ld
        .type   set_ld, @function
set_ld:
        pushq   %rbx
        movl    %edi, %ebx
        leaq    address@hidden(%rip), %rdi
        call    address@hidden(%rip)
        movl    %ebx, address@hidden(%rax)
        popq    %rbx
        ret
        .size   set_ld, .-set_ld
        .text
        .p2align 4,,15
        .globl  test_ld
        .type   test_ld, @function
test_ld:
        pushq   %rbx
        movl    %edi, %ebx
        leaq    address@hidden(%rip), %rdi
        call    address@hidden(%rip)
        cmpl    %ebx, address@hidden(%rax)
        popq    %rbx
        sete    %al
        movzbl  %al, %eax
        ret
        .size   test_ld, .-test_ld
        .section        .tbss,"awT",@nobits
        .align 4
        .type   ld, @object
        .size   ld, 4
ld:
        .zero   4
        .section        .note.GNU-stack,"",@progbits
address@hidden tls-10a]$ make
gcc -fuse-ld=gold -fPIE -O3 -fno-asynchronous-unwind-tables   -c -o main.o
main.c
gcc -fuse-ld=gold -fPIE -O3 -fno-asynchronous-unwind-tables   -c -o def.o def.c
gcc -fuse-ld=gold -fPIE -O3 -fno-asynchronous-unwind-tables -fPIC -c gd.S
gcc -fuse-ld=gold -fPIE -O3 -fno-asynchronous-unwind-tables -fPIC -c ld.S
ld.gold -shared -o libtls.so gd.o ld.o
gcc -fuse-ld=gold -o x main.o def.o libtls.so -Wl,-R,.
gcc -fuse-ld=gold -static -o y main.o def.o gd.o ld.o -Wl,-R,.
gd.o:function get_gd: error: TLS relocation against invalid instruction
gd.o:function get_gd: error: missing expected TLS relocation
gd.o:function set_gd: error: missing expected TLS relocation
gd.o:function test_gd: error: TLS relocation against invalid instruction
gd.o:function test_gd: error: missing expected TLS relocation
/usr/local/bin/ld.gold: error: missing expected TLS relocation
ld.o:function set_ld: error: TLS relocation against invalid instruction
ld.o:function set_ld: error: missing expected TLS relocation
ld.o:function set_ld: error: missing expected TLS relocation
ld.o:function test_ld: error: missing expected TLS relocation
ld.o:function test_ld: error: TLS relocation against invalid instruction
ld.o:function test_ld: error: missing expected TLS relocation
ld.o:function test_ld: error: missing expected TLS relocation
/usr/local/bin/ld.gold: error: missing expected TLS relocation
collect2: error: ld returned 1 exit status
Makefile:28: recipe for target 'y' failed
make: *** [y] Error 1
address@hidden tls-10a]$

-- 
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]