public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/23058] New: visibility attribute does not work for aliased symbols
@ 2005-07-25 11:53 bruno at clisp dot org
2005-07-25 12:53 ` [Bug middle-end/23058] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: bruno at clisp dot org @ 2005-07-25 11:53 UTC (permalink / raw)
To: gcc-bugs
When a function or variable has its assembler name given through an
__asm__, the __attribute__((__visibility__("default"))) present on the
same declaration is ignored.
$ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /freebsd/gnu/linuxarchive/gcc-4.0.1/configure
--prefix=/packages/gnu-inst-gcc/4.0.1 --enable-shared
--enable-version-specific-runtime-libs --enable-nls --enable-threads=posix
--enable-__cxa_atexit --with-as=/packages/gnu/bin/as
--with-ld=/packages/gnu/bin/ld
Thread model: posix
gcc version 4.0.1
$ cat bug.c
extern
int hidden_var
__asm__("my_hidden_var");
extern __attribute__((__visibility__("default")))
int exported_var
__asm__("my_exported_var");
extern
int hidden_func (void)
__asm__("my_hidden_func");
extern __attribute__((__visibility__("default")))
int exported_func (void)
__asm__("my_exported_func");
int my_hidden_var = 0;
int my_exported_var = 0;
int my_hidden_func (void) { return 0; }
int my_exported_func (void) { return 0; }
$ gcc -c -fvisibility=hidden bug.c
$ readelf --syms bug.o
Symbol table '.symtab' contains 11 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 00000000 0 FILE LOCAL DEFAULT ABS bug.c
2: 00000000 0 SECTION LOCAL DEFAULT 1
3: 00000000 0 SECTION LOCAL DEFAULT 2
4: 00000000 0 SECTION LOCAL DEFAULT 3
5: 00000000 0 SECTION LOCAL DEFAULT 5
6: 00000000 0 SECTION LOCAL DEFAULT 4
7: 00000000 4 OBJECT GLOBAL HIDDEN 3 my_hidden_var
8: 00000004 4 OBJECT GLOBAL HIDDEN 3 my_exported_var
9: 00000000 10 FUNC GLOBAL HIDDEN 1 my_hidden_func
10: 0000000a 10 FUNC GLOBAL HIDDEN 1 my_exported_func
$ gcc -shared -o bug.so bug.o && nm bug.so | grep my_
00000476 t my_exported_func
000015e4 b my_exported_var
0000046c t my_hidden_func
000015e0 b my_hidden_var
As you can see, the symbols my_exported_func, my_exported_var are not
exported from bug.so, because their visibility was "HIDDEN" in bug.o.
Known workaround: If I write "int exported_var = 0;" instead of
"int my_exported_var = 0;", and "int exported_func (void) { return 0; }"
instead of ""int my_exported_func (void) { return 0; }", the problem
disappears.
--
Summary: visibility attribute does not work for aliased symbols
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bruno at clisp dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23058
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/23058] visibility attribute does not work for aliased symbols
2005-07-25 11:53 [Bug c/23058] New: visibility attribute does not work for aliased symbols bruno at clisp dot org
@ 2005-07-25 12:53 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-25 12:53 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23058
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-07-25 12:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-25 11:53 [Bug c/23058] New: visibility attribute does not work for aliased symbols bruno at clisp dot org
2005-07-25 12:53 ` [Bug middle-end/23058] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).