This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/18713] Large program size due to uninitialised global data (SCO)
- From: "bygoh at genting dot com dot my" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Dec 2004 04:11:59 -0000
- Subject: [Bug target/18713] Large program size due to uninitialised global data (SCO)
- References: <20041129081500.18713.bygoh@genting.com.my>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bygoh at genting dot com dot my 2004-12-08 04:11 -------
Follow up on the earlier report, the size problem goes away when the global
variables are declared as static:
struct My_t {
char myData[2048];
};
static My_t myArr[10240];
int main ()
{
return 0;
}
Using nm on the object files that were generated:
without static keyword:
Symbols from foo.o:
[Index] Value Size Type Bind Other Shndx Name
[1] | 0| 0|FILE |LOCL |0 |ABS |foo.cpp
[2] | 0| 0|SECT |LOCL |0 |2 |
[3] | 0| 0|SECT |LOCL |0 |4 |
[4] | 0| 0|SECT |LOCL |0 |5 |
[5] | 0| 0|SECT |LOCL |0 |1 |
[6] | 0| 0|SECT |LOCL |0 |6 |
[7] | 0|20971520|OBJT |GLOB |0 |4 |myArr
[8] | 0| 30|FUNC |GLOB |0 |2 |main
with static keyword:
Symbols from foo.o:
[Index] Value Size Type Bind Other Shndx Name
[1] | 0| 0|FILE |LOCL |0 |ABS |foo.cpp
[2] | 0| 0|SECT |LOCL |0 |2 |
[3] | 0| 0|SECT |LOCL |0 |4 |
[4] | 0| 0|SECT |LOCL |0 |5 |
[5] | 0|20971520|OBJT |LOCL |0 |5 |myArr
[6] | 0| 0|SECT |LOCL |0 |1 |
[7] | 0| 0|SECT |LOCL |0 |6 |
[8] | 0| 30|FUNC |GLOB |0 |2 |main
The array was bound locally. Still doesn't solve the problem but its a work
around for programs with a main line entry point.
NOTE: static is deprecated in a global context. Not that its going to go away
or anything...
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18713