public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32458]  New: __attribute((section(".myname"))) is not working as expected in G++ but works ni GCC
@ 2007-06-21 16:21 prem dot mallappa at gmail dot com
  2007-06-21 20:34 ` [Bug c++/32458] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: prem dot mallappa at gmail dot com @ 2007-06-21 16:21 UTC (permalink / raw)
  To: gcc-bugs

I used the simple program provided in the gcc help pages.
i am using gcc-4.2.0 cross compiler for ARM (I think the problem
should persist in native compilers as well)

------------a.c--------
#include <stdio.h>
int main(void) {
static int  a __attribute__ ((section (".offsets"))) = 0;
static int myname __attribute__ ((section (".offsets"))) =  0 ;
//static char stack[10000] __attribute__ ((section (".stack"))) =
{ 0 };
static int init_data __attribute__ ((section (".prems"))) = 0;

        printf("Hellow world %d\n", 0);
        return 0;
}

---------------------------

---------------a.cc----------------
#include <stdio.h>
int main(void) {
static int  a __attribute__ ((section (".offsets"))) = 0;
static int myname __attribute__ ((section (".offsets"))) =  0 ;
//static char stack[10000] __attribute__ ((section (".stack"))) =
{ 0 };
static int init_data __attribute__ ((section (".prems"))) = 0;

        printf("Hellow world %d\n", 0);
        return 0;
}

-------------------------------------

The files 'a.c' and 'a.cc' are the same except that the 'a.cc' is
treated as c++ file.
in a.o created from 'a.c' has the sections. but the a.o created from
'a.cc' doesn't have

command used:
arm-none-linux-gnueabi-gcc -c a.c

arm-none-linux-gnueabi-gcc -c a.cc

Please let me know if I am wrong here, or let me know if there is a
workaround to make the 'a.cc' to have the sections compiled in.

/Prem


-- 
           Summary: __attribute((section(".myname"))) is not working as
                    expected in G++ but works ni GCC
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: prem dot mallappa at gmail dot com
 GCC build triplet: x86_64-pc-linux
  GCC host triplet: x86_64-pc-linux
GCC target triplet: x86_64-pc-linux


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


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

* [Bug c++/32458] __attribute((section(".myname"))) is not working as expected in G++ but works ni GCC
  2007-06-21 16:21 [Bug c++/32458] New: __attribute((section(".myname"))) is not working as expected in G++ but works ni GCC prem dot mallappa at gmail dot com
@ 2007-06-21 20:34 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-21 20:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-06-21 20:34 -------
You forgot to mark the variables as being used.
You mark the variable used with the attribute used.
Once you do that, the variables are emitted.
This is not a bug but by design that GCC can optimize out unused variables,
even the ones marked with a different section.


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2007-06-21 20:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-21 16:21 [Bug c++/32458] New: __attribute((section(".myname"))) is not working as expected in G++ but works ni GCC prem dot mallappa at gmail dot com
2007-06-21 20:34 ` [Bug c++/32458] " 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).