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

            Bug ID: 39236
           Summary: Static locals in inline functions should be hidden
                    with -fvisibility=hidden and
                    -fvisibility-inlines-hidden
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

This is a bug in the fix to https://llvm.org/pr37595, or r340386.

We encountered it in Chromium here: https://crbug.com/891992#c20

This probably isn't too hard to fix.

Pasting Hans's reproducer below:

Yes, it seems Clang and GCC behave differently here:

inline int foo() {
  static int x;
  return x++;
}

int use() { return foo(); }


$ g++ -fvisibility=hidden -fvisibility-inlines-hidden -c /tmp/a.cc && objdump
-t a.o

a.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    df *ABS*  0000000000000000 a.cc
0000000000000000 l    d  .text  0000000000000000 .text
0000000000000000 l    d  .data  0000000000000000 .data
0000000000000000 l    d  .bss   0000000000000000 .bss
0000000000000000 l    d  .bss._ZZ3foovE1x       0000000000000000
.bss._ZZ3foovE1x
0000000000000000 l    d  .text._Z3foov  0000000000000000 .text._Z3foov
0000000000000000 l    d  .note.GNU-stack        0000000000000000
.note.GNU-stack
0000000000000000 l    d  .eh_frame      0000000000000000 .eh_frame
0000000000000000 l    d  .comment       0000000000000000 .comment
0000000000000000 l    d  .group 0000000000000000 .group
0000000000000000 l    d  .group 0000000000000000 .group
0000000000000000 u     O .bss._ZZ3foovE1x       0000000000000004 .hidden
_ZZ3foovE1x   <---- foo()::x is hidden
0000000000000000  w    F .text._Z3foov  0000000000000015 .hidden _Z3foov
0000000000000000 g     F .text  000000000000000b .hidden _Z3usev


$ clang++ -fvisibility=hidden -fvisibility-inlines-hidden -c /tmp/a.cc &&
objdump -t a.o

a.o:     file format elf64-x86-64

SYMBOL TABLE:
0000000000000000 l    df *ABS*  0000000000000000 a.cc
0000000000000000 l    d  .text  0000000000000000 .text
0000000000000000 l    d  .text._Z3foov  0000000000000000 .text._Z3foov
0000000000000000  w    F .text._Z3foov  0000000000000019 .hidden _Z3foov
0000000000000000 g     F .text  000000000000000b .hidden _Z3usev
0000000000000000  w    O .bss._ZZ3foovE1x       0000000000000004 _ZZ3foovE1x   
<----- foo()::x is not hidden

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to