On Tue, Feb 10, 2015 at 1:19 PM, Richard Henderson <r...@redhat.com> wrote: >> @@ -7445,9 +7465,10 @@ default_elf_asm_output_external (FILE *file >> ATTRIBUTE_UNUSED, >> { >> /* We output the name if and only if TREE_SYMBOL_REFERENCED is >> set in order to avoid putting out names that are never really >> - used. */ >> + used. Always output visibility specified in the source. */ >> if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) >> - && targetm.binds_local_p (decl)) >> + && (DECL_VISIBILITY_SPECIFIED (decl) >> + || targetm.binds_local_p (decl))) >> maybe_assemble_visibility (decl); > > Explain? >
This is for the new testcase in my patch: [hjl@gnu-mic-2 testsuite]$ cat gcc.dg/visibility-23.c /* PR target/32219 */ /* { dg-do compile } */ /* { dg-require-visibility "" } */ /* { dg-final { scan-hidden "foo" } } */ /* { dg-options "-O2 -fPIC" { target fpic } } */ /* { dg-skip-if "" { "hppa*-*-hpux*" "*-*-aix*" "*-*-darwin*" } "*" { "" } } */ extern void foo () __attribute__((weak,visibility("hidden"))); int main() { if (foo) foo (); return 0; } [hjl@gnu-mic-2 testsuite]$ Here targetm.binds_local_p now returns false. But we must emit ".hidden foo" even if foo isn't defined in the TU. Otherwise, foo wont be hidden if it isn't defined in another TU. -- H.J.