c/6343: attribute((weak)) not working on second declaration
harinath@cs.umn.edu
harinath@cs.umn.edu
Wed Apr 17 18:30:00 GMT 2002
>Number: 6343
>Category: c
>Synopsis: attribute((weak)) not working on second declaration
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Apr 17 18:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: harinath@cs.umn.edu
>Release: gcc version 3.2 20020416 (experimental)
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
gcc/crtstuff.c depends on being able to do
int foo(void);
int foo(void) attribute((weak));
and have the symbol 'foo' being marked weak.
This doesn't seem to be working.
Here are two compiles of the attached file, and the output of nm.
$ gcc -shared -o foo.so foo.c
$ nm --dynamic foo.so
00001838 A _DYNAMIC
00001914 A _GLOBAL_OFFSET_TABLE_
w _Jv_RegisterClasses
00001944 A __bss_start
w __cxa_finalize
U __deregister_frame_info_bases
w __gmon_start__
U __register_frame_info_bases
00001944 A _edata
00001960 A _end
00000810 T _fini
000005cc T _init
00000790 T bar
w foo
$ gcc -DNONWEAK -shared -o foo.so foo.c
$ nm --dynamic foo.so
00001838 A _DYNAMIC
00001914 A _GLOBAL_OFFSET_TABLE_
w _Jv_RegisterClasses
00001944 A __bss_start
w __cxa_finalize
U __deregister_frame_info_bases
w __gmon_start__
U __register_frame_info_bases
00001944 A _edata
00001960 A _end
00000810 T _fini
000005cc T _init
00000790 T bar
U foo
Notice 'foo' is not marked weak in the second case. This is exactly the way this attribute is used in gcc/crtstuff.c (which is also reflected above, see the non-weak references to __register_frame_info_bases, and the weak reference to __cxa_finalize).
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="foo.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="foo.c"
I2lmIGRlZmluZWQgTk9OV0VBSwppbnQgZm9vKHZvaWQpOwojZW5kaWYKaW50IGZvbyh2b2lkKSBf
X2F0dHJpYnV0ZV9fKChfX3dlYWtfXykpOwoKaW50IGJhcih2b2lkKQp7CiAgaWYgKGZvbykgcmV0
dXJuIGZvbygpOwogIHJldHVybiAtMTsKfQoK
More information about the Gcc-bugs
mailing list