public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: harinath@cs.umn.edu
To: gcc-gnats@gcc.gnu.org
Subject: c/6343: attribute((weak)) not working on second declaration
Date: Wed, 17 Apr 2002 18:06:00 -0000	[thread overview]
Message-ID: <20020418010242.28208.qmail@sources.redhat.com> (raw)


>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


             reply	other threads:[~2002-04-18  1:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 18:06 harinath [this message]
2002-04-23  1:52 mmitchel
2002-04-23  6:14 jason
2002-04-23  7:36 Raja R Harinath
2002-04-23 13:36 jason
2002-05-01 11:05 sirl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020418010242.28208.qmail@sources.redhat.com \
    --to=harinath@cs.umn.edu \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).