linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Meissner <meissner@spectacle-pond.org>
To: Alexander Viro <viro@math.psu.edu>
Cc: Andrea Arcangeli <andrea@suse.de>,
	kumon@flab.fujitsu.co.jp, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] removal of "static foo = 0"
Date: Mon, 27 Nov 2000 23:15:11 -0500	[thread overview]
Message-ID: <20001127231511.C17104@munchkin.spectacle-pond.org> (raw)
In-Reply-To: <20001128042850.A29908@athlon.random> <Pine.GSO.4.21.0011272234550.7352-100000@weyl.math.psu.edu>
In-Reply-To: <Pine.GSO.4.21.0011272234550.7352-100000@weyl.math.psu.edu>; from viro@math.psu.edu on Mon, Nov 27, 2000 at 10:35:45PM -0500

On Mon, Nov 27, 2000 at 10:35:45PM -0500, Alexander Viro wrote:
> 
> 
> On Tue, 28 Nov 2000, Andrea Arcangeli wrote:
> 
> > On Tue, Nov 28, 2000 at 12:10:33PM +0900, kumon@flab.fujitsu.co.jp wrote:
> > > If you have two files:
> > > test1.c:
> > > int a,b,c;
> > > 
> > > test2.c:
> > > int a,c;
> > > 
> > > Which is _stronger_?
> > 
> > Those won't link together as they aren't declared static.
> 
> Try it. They _will_ link together.

This is a GCC extension (actually it is a pretty common UNIX extension, but the
official standard says you can only have one definition of a global variable).

Off the top of my head, here are some reasons variables could be put in
different orders:

   1)	The compilation system has the concept of a small data pointer, which
	is a register that is assumed by the compiler to point to a small
	region of memory (it is never allocated by the compiler and setup in
	the initialization modules).  The compiler decides to put some
	variables into the small data region and other variables outside of
	it.  Typically the choice is based on size of the variable.  Small data
	pointers are typically used when the machine has plenty of registers
	and it takes 2 or more instructions to build the address of a random
	variable in memory with load high/load low type instructions, and the
	small data pointer has the upper half already loaded, and uses special
	relocations to access the variable based off of the difference of a
	special symbol.

   2)	Even without a small data pointer, a compiler might decide to sort the
	variables emitted based on either size or number of accesses to take
	advantage of instructions with smaller offsets.

   3)	The above mentioned global, non-initialized variables (ie, the
	so-called 'common' variables).  Where the linker puts the variables
	into the bss section in any order it chooses.  For example, the VMS
	linker used to sort common variables alphabetically.

   4)	For static variables, the compilation system might decide to omit the
	variable until it sees a reference to the variable, and if the first
	variable is referenced in one function, and the second is referenced
	several functions later.

   5)	At some point in the future, on machines with many more registers than
	the normal 32, the linker might see all references to a variable, and
	decide to put it in a static register rather than memory.

   6)	A checkout compiler could randomly order things specifically to catch
	these type of errors (the problem with the normal checkout compilers
	that I'm aware of, is that the kernel uses structs to talk to real
	devices and interact with system calls with fixed layouts).

-- 
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-11-28  4:44 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-27  8:41 [PATCH] removal of "static foo = 0" Werner Almesberger
2000-11-27  5:56 ` Adam J. Richter
2000-11-27  8:39   ` David S. Miller
2000-11-27  9:08     ` Werner Almesberger
2000-11-27 17:21     ` Andrea Arcangeli
2000-11-27 17:36       ` Michael Meissner
2000-11-27 19:06         ` Andrea Arcangeli
2000-11-27 19:34           ` Richard B. Johnson
2000-11-28  0:28             ` Andrea Arcangeli
2000-11-28 11:25               ` Horst von Brand
2000-11-27 21:27         ` Marcus Sundberg
2000-11-28  0:49           ` real_root_dev Andries Brouwer
2000-11-28  3:10         ` [PATCH] removal of "static foo = 0" kumon
2000-11-28  3:28           ` Andrea Arcangeli
2000-11-28  3:35             ` Alexander Viro
2000-11-28  4:15               ` Michael Meissner [this message]
2000-11-28  9:55               ` Andreas Schwab
2000-11-28 15:16                 ` Andrea Arcangeli
2000-11-28 16:09                   ` Andreas Schwab
2000-11-28 19:29                     ` Andrea Arcangeli
2000-11-28 16:44                   ` Michael Meissner
2000-11-27 18:11       ` Richard B. Johnson
2000-11-27 18:01 ` Michael Meissner
  -- strict thread matches above, loose matches on Subject: below --
2000-11-26 17:53 Elmer Joandi
2000-11-26 18:36 ` Alexander Viro
2000-11-26 19:11   ` Elmer Joandi
2000-11-26 22:49 ` Rogier Wolff
2000-11-26 15:15 Adam J. Richter
2000-11-25 20:19 Andries Brouwer
2000-11-25 21:07 ` Russell King
2000-11-25 21:29   ` Andries Brouwer
2000-11-26  1:19     ` Russell King
2000-11-25 22:11 ` Herbert Xu
2000-11-25 22:46   ` Andries Brouwer
2000-11-25 22:53     ` James A Sutherland
2000-11-25 23:55       ` Tim Waugh
2000-11-26  3:10         ` James A Sutherland
2000-11-26 10:37         ` Tigran Aivazian
2000-11-26 14:52           ` Philipp Rumpf
2000-11-28  0:01           ` Peter Samuelson
2000-11-27  4:00         ` Michael Meissner
2000-11-25 23:02     ` Jeff Garzik
2000-11-26  2:08       ` Andries Brouwer
2000-11-26  9:22         ` Martin Mares
2000-11-25 23:33     ` Herbert Xu
2000-11-27 10:03     ` Helge Hafting
2000-11-27 20:33     ` Albert D. Cahalan
2000-11-27 22:57       ` Russell King
2000-11-29  1:46         ` Albert D. Cahalan
2000-11-29  3:21           ` Peter Samuelson
2000-11-29  7:25           ` Russell King
2000-11-25 22:27 ` Tigran Aivazian
2000-11-26  1:32   ` Andries Brouwer
2000-11-26  6:21     ` Werner Almesberger
2000-11-26  2:11   ` Georg Nikodym
2000-11-26  4:25     ` Alan Cox
2000-11-26  5:01       ` John Alvord
2000-11-26  5:10         ` Andre Hedrick
2000-11-26  6:22           ` Keith Owens
2000-11-26  6:28             ` Andre Hedrick
2000-11-26 10:43         ` Tigran Aivazian
2000-11-26 10:52         ` Tigran Aivazian
2000-11-24  7:47           ` Pavel Machek
2000-11-26 14:32           ` bert hubert
2000-11-26 10:52         ` Rogier Wolff
2000-11-26 14:13       ` Philipp Rumpf
2000-11-26 20:47       ` H. Peter Anvin
2000-11-27 21:12         ` Kai Henningsen
2000-11-26 15:19     ` Georg Nikodym

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=20001127231511.C17104@munchkin.spectacle-pond.org \
    --to=meissner@spectacle-pond.org \
    --cc=andrea@suse.de \
    --cc=kumon@flab.fujitsu.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@math.psu.edu \
    /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 NNTP newsgroup(s).