Skip to contentSkip to conversation

List of all-zero .data variables in linux-2.4.3 available

DISCUSSION Adam J. Richter 3 participants 3 messages Apr 12, 2001

lore
Share & tools
lore
#0 lore raw
Quoted 1 line · [email protected] writes:

Shouldn't a compiler be able to deal with this instead?

Yes. I sent some email to bug-gcc about this a couple of
months ago and even posted some (probably horribly incorrect) code showing roughly the change I had in mind in the gcc source code for the simple case of scalar variables. I was told that some code to this was put in and then removed from gcc a long time ago, and nobody seemed interested in putting it back in. I would think that this would be a basic optimization that I would expect the compiler to make, just like deleting "if(0) {......}" code, but gcc does not currently do that. If somebody would like to fix gcc and do the necessary lobbying to get such a change integrated, that would be great. However, until that actually happens, I hope the file that I posted to ftp://ftp.yggdrasil.com/private/adam/linux/zerovars/ will be useful to individual maintainers and in identifying the largest arrays of zeroes that can fix fixed in a few lines.

Adam J. Richter     __     ______________   4880 Stevens Creek Blvd, Suite 104
[email protected]     \ /                  San Jose, California 95129-1034
+1 408 261-6630         | g g d r a s i l   United States of America

fax +1 408 261-6631 "Free Software For The Rest Of Us."

#1 lore raw
Quoted 3 lines · Adam J. Richter
Quoted 1 line

Shouldn't a compiler be able to deal with this instead?

Yes.

No. gcc must not do this. There are situations where you must place a zero-initialized variable in .data. It is a programmer problem.

Signature · 3 lines
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------
#2 lore raw
In reply to Adam J. Richter
Followup to:  <[email protected]>
By author:    Ulrich Drepper <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 10 lines
Quoted 3 lines · Adam J. Richter
Quoted 1 line

Shouldn't a compiler be able to deal with this instead?

Yes.

No. gcc must not do this. There are situations where you must place a zero-initialized variable in .data. It is a programmer problem.

And this cannot be decorated with __attribute__((section(".data"))) why?

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt