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

            Bug ID: 67220
           Summary: GCC fails to properly handle libcall symbol visibility
                    of built functions
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

[hjl@gnu-6 builtins-2]$ cat x.c
typedef __SIZE_TYPE__ size_t;
extern void *memset(void *s, int c, size_t n)
  __attribute__ ((visibility ("hidden")));

void
foo1 (void *s, size_t n)
{
  memset (s, '\0', n);
}

void
foo2 (void *s, int c, size_t n)
{
  memset (s, c, n);
}
[hjl@gnu-6 builtins-2]$ make
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fPIC  -S -o x.s x.c
[hjl@gnu-6 builtins-2]$ cat x.s
        .file   "x.c"
        .section        .text.unlikely,"ax",@progbits
.LCOLDB0:
        .text
.LHOTB0:
        .p2align 4,,15
        .globl  foo1
        .type   foo1, @function
foo1:
.LFB0:
        .cfi_startproc
        movq    %rsi, %rdx
        xorl    %esi, %esi
        jmp     memset@PLT  <<<<<<<<<<<<<<  It shouldn't use PLT.
        .cfi_endproc
.LFE0:
        .size   foo1, .-foo1
        .section        .text.unlikely
.LCOLDE0:
        .text
.LHOTE0:
        .section        .text.unlikely
.LCOLDB1:
        .text
.LHOTB1:
        .p2align 4,,15
        .globl  foo2
        .type   foo2, @function
foo2:
.LFB1:
        .cfi_startproc
        jmp     memset
        .cfi_endproc
.LFE1:
        .size   foo2, .-foo2
        .section        .text.unlikely
.LCOLDE1:
        .text
.LHOTE1:
        .hidden memset
        .ident  "GCC: (GNU) 6.0.0 20150812 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-6 builtins-2]$

Reply via email to