[llvm-bugs] [Bug 28306] New: Reference external functions without PLT

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 25 16:08:57 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28306

            Bug ID: 28306
           Summary: Reference external functions without PLT
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: hjl.tools at gmail.com
                CC: david.l.kreitzer at intel.com, llvm-bugs at lists.llvm.org,
                    zia.ansari at intel.com
    Classification: Unclassified

There are extensions to x86-64 psABI:

https://groups.google.com/forum/#!topic/x86-64-abi/de5_KnLHxtI

and i386 psABI:

https://groups.google.com/forum/#!topic/ia32-abi/awsRSvJOJfs

with alternate code sequences to reference external functions without
PLT:

[hjl at gnu-tools-1 pr67400]$ cat z.i
extern int bar (void);

int
foo (void)
{
   return bar ();
}
[hjl at gnu-tools-1 pr67400]$ cat f.i
extern int name (void);

void *
ptr (void)
{
 return name;
}
[hjl at gnu-tools-1 pr67400]$ cat t.i
static __thread int ld;
extern __thread int gd;

int *
get_ld (void)
{
  return &ld;
}

int *
get_gd (void)
{
  return &gd;
}
[hjl at gnu-tools-1 pr67400]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt  -S z.i
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt  -S f.i
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt  -fPIC -S t.i
[hjl at gnu-tools-1 pr67400]$ cat z.s
    .file    "z.i"
    .text
    .p2align 4,,15
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    jmp    *bar at GOTPCREL(%rip)
    .cfi_endproc
.LFE0:
    .size    foo, .-foo
    .ident    "GCC: (GNU) 7.0.0 20160625 (experimental)"
    .section    .note.GNU-stack,"", at progbits
[hjl at gnu-tools-1 pr67400]$ cat f.s
    .file    "f.i"
    .text
    .p2align 4,,15
    .globl    ptr
    .type    ptr, @function
ptr:
.LFB0:
    .cfi_startproc
    movq    name at GOTPCREL(%rip), %rax
    ret
    .cfi_endproc
.LFE0:
    .size    ptr, .-ptr
    .ident    "GCC: (GNU) 7.0.0 20160625 (experimental)"
    .section    .note.GNU-stack,"", at progbits
[hjl at gnu-tools-1 pr67400]$ cat t.s
    .file    "t.i"
    .text
    .p2align 4,,15
    .globl    get_ld
    .type    get_ld, @function
get_ld:
.LFB0:
    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    leaq    ld at tlsld(%rip), %rdi
    call    *__tls_get_addr at GOTPCREL(%rip)
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    addq    $ld at dtpoff, %rax
    ret
    .cfi_endproc
.LFE0:
    .size    get_ld, .-get_ld
    .p2align 4,,15
    .globl    get_gd
    .type    get_gd, @function
get_gd:
.LFB1:
    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    .byte    0x66
    leaq    gd at tlsgd(%rip), %rdi
    .byte    0x66
    rex64
    call    *__tls_get_addr at GOTPCREL(%rip)
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc
.LFE1:
    .size    get_gd, .-get_gd
    .section    .tbss,"awT", at nobits
    .align 4
    .type    ld, @object
    .size    ld, 4
ld:
    .zero    4
    .ident    "GCC: (GNU) 7.0.0 20160625 (experimental)"
    .section    .note.GNU-stack,"", at progbits
[hjl at gnu-tools-1 pr67400]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt  -m32  -S z.i
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt  -m32  -S f.i
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fno-plt  -m32  -fPIC -S
t.i
[hjl at gnu-tools-1 pr67400]$ cat z.s
    .file    "z.i"
    .text
    .p2align 4,,15
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    jmp    *bar at GOT
    .cfi_endproc
.LFE0:
    .size    foo, .-foo
    .ident    "GCC: (GNU) 7.0.0 20160625 (experimental)"
    .section    .note.GNU-stack,"", at progbits
[hjl at gnu-tools-1 pr67400]$ cat f.s
    .file    "f.i"
    .text
    .p2align 4,,15
    .globl    ptr
    .type    ptr, @function
ptr:
.LFB0:
    .cfi_startproc
    movl    name at GOT, %eax
    ret
    .cfi_endproc
.LFE0:
    .size    ptr, .-ptr
    .ident    "GCC: (GNU) 7.0.0 20160625 (experimental)"
    .section    .note.GNU-stack,"", at progbits
[hjl at gnu-tools-1 pr67400]$ cat t.s
    .file    "t.i"
    .text
    .p2align 4,,15
    .globl    get_ld
    .type    get_ld, @function
get_ld:
.LFB0:
    .cfi_startproc
    call    __x86.get_pc_thunk.dx
    addl    $_GLOBAL_OFFSET_TABLE_, %edx
    subl    $12, %esp
    .cfi_def_cfa_offset 16
    leal    ld at tlsgd(%edx), %eax
    call    *___tls_get_addr at GOT(%edx)
    addl    $12, %esp
    .cfi_def_cfa_offset 4
    ret
    .cfi_endproc
.LFE0:
    .size    get_ld, .-get_ld
    .p2align 4,,15
    .globl    get_gd
    .type    get_gd, @function
get_gd:
.LFB1:
    .cfi_startproc
    call    __x86.get_pc_thunk.dx
    addl    $_GLOBAL_OFFSET_TABLE_, %edx
    subl    $12, %esp
    .cfi_def_cfa_offset 16
    leal    gd at tlsgd(%edx), %eax
    call    *___tls_get_addr at GOT(%edx)
    addl    $12, %esp
    .cfi_def_cfa_offset 4
    ret
    .cfi_endproc
.LFE1:
    .size    get_gd, .-get_gd
    .section    .tbss,"awT", at nobits
    .align 4
    .type    ld, @object
    .size    ld, 4
ld:
    .zero    4
    .section   
.text.__x86.get_pc_thunk.dx,"axG", at progbits,__x86.get_pc_thunk.dx,comdat
    .globl    __x86.get_pc_thunk.dx
    .hidden    __x86.get_pc_thunk.dx
    .type    __x86.get_pc_thunk.dx, @function
__x86.get_pc_thunk.dx:
.LFB2:
    .cfi_startproc
    movl    (%esp), %edx
    ret
    .cfi_endproc
.LFE2:
    .ident    "GCC: (GNU) 7.0.0 20160625 (experimental)"
    .section    .note.GNU-stack,"", at progbits
[hjl at gnu-tools-1 pr67400]$ 

llvm should also implement -fno-plt.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160625/e380acbb/attachment.html>


More information about the llvm-bugs mailing list