public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/14911] New: static const symbols lost when referred in asm
@ 2004-04-10 19:39 monge at sns dot it
  2004-04-10 19:51 ` [Bug c/14911] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: monge at sns dot it @ 2004-04-10 19:39 UTC (permalink / raw)
  To: gcc-bugs

could not compile MPlayer with 3.4 prerelease :-( 
 
gcc -v : 
 Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.0/specs 
Configured with: ../configure --prefix=/usr --program-suffix=-3.4 --with-gnu-as 
--with-gnu-ld --with-cpu=i686 --enable-__cxa_atexit --enable-languages=c,c++ 
Thread model: posix 
gcc version 3.4.0 20040407 (prerelease) 
 
the follwing code: 
 
//------------BEGIN--------------- 
static const int hello = 56; 
int main() 
{ 
	asm( 
	"mov hello, %eax\n" 
	); 
	return 0; 
} 
//------------END----------------- 
 
compiles with  
 
gcc code.c 
 
but fails with 
 
gcc -O2 code.c 
/tmp/ccgUsUmb.o(.text+0xd): In function `main': 
: undefined reference to `hello' 
collect2: ld returned 1 exit status 
 
gcc 3.2.3 always works. 
 
Thanx

-- 
           Summary: static const symbols lost when referred in asm
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: monge at sns dot it
                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=14911


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/14911] static const symbols lost when referred in asm
  2004-04-10 19:39 [Bug c/14911] New: static const symbols lost when referred in asm monge at sns dot it
@ 2004-04-10 19:51 ` pinskia at gcc dot gnu dot org
  2004-04-22 17:35 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-10 19:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-10 18:27 -------
Invalid, you have to mark the static const as used if you are going to use it in asm.
Do the following:
static const int hello __attribute__((used)) = 56; 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14911


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/14911] static const symbols lost when referred in asm
  2004-04-10 19:39 [Bug c/14911] New: static const symbols lost when referred in asm monge at sns dot it
  2004-04-10 19:51 ` [Bug c/14911] " pinskia at gcc dot gnu dot org
@ 2004-04-22 17:35 ` pinskia at gcc dot gnu dot org
  2004-05-14  8:58 ` pinskia at gcc dot gnu dot org
  2004-05-18 23:38 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-22 17:35 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-22 17:20 -------
Just to let you know that I hear that mplayer has not accepted a patch to fix this yet, here is a way to 
use the attribute for both 3.4.0 and above and 2.95.3:
#define ATTRIBUTE_USED
#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >=4)
#undef ATTRIBUTE_USED
#define ATTRIBUTE_USED __attribute__((used))
#endif
static const int hello ATTRIBUTE_USED  = 56;
int main()
{
        asm(
        "mov hello, %eax\n"
        );
        return 0;
}

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14911


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/14911] static const symbols lost when referred in asm
  2004-04-10 19:39 [Bug c/14911] New: static const symbols lost when referred in asm monge at sns dot it
  2004-04-10 19:51 ` [Bug c/14911] " pinskia at gcc dot gnu dot org
  2004-04-22 17:35 ` pinskia at gcc dot gnu dot org
@ 2004-05-14  8:58 ` pinskia at gcc dot gnu dot org
  2004-05-18 23:38 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-14  8:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-13 14:49 -------
*** Bug 15421 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dueffert at informatik dot
                   |                            |hu-berlin dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14911


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c/14911] static const symbols lost when referred in asm
  2004-04-10 19:39 [Bug c/14911] New: static const symbols lost when referred in asm monge at sns dot it
                   ` (2 preceding siblings ...)
  2004-05-14  8:58 ` pinskia at gcc dot gnu dot org
@ 2004-05-18 23:38 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-05-18 23:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-05-18 13:56 -------
*** Bug 15517 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |td at pre-secure dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14911


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-05-18 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-10 19:39 [Bug c/14911] New: static const symbols lost when referred in asm monge at sns dot it
2004-04-10 19:51 ` [Bug c/14911] " pinskia at gcc dot gnu dot org
2004-04-22 17:35 ` pinskia at gcc dot gnu dot org
2004-05-14  8:58 ` pinskia at gcc dot gnu dot org
2004-05-18 23:38 ` 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).