Jump to content

Talk:.bss

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Should this be moved to "BSS"?

[edit]

Shouldn't this be moved to BSS? --Mjbauer95 (talk) 06:49, 3 January 2009 (UTC)[reply]

Well,
  • We already have a disambiguation page at BSS.
  • The proper name for this concept is "bss" or ".bss", in lower case letters (because Unix object code is case-sensitive).
So I'd prefer to not move it. Cheers, CWC 11:00, 8 January 2009 (UTC)[reply]

I don't see any good reason either. Is there some kind of precedance? Dan, the CowMan (talk) 03:31, 9 January 2009 (UTC)[reply]

It seems to be named after a feature in US-SAP, and later FAP, both of which worked with a six bit code with no lower case. Gah4 (talk) 06:39, 18 October 2017 (UTC)[reply]

Initialized to zero?

[edit]

Must the .bss always be initialized to zero? The defining feature of BSS storage is that it isn't part of the code initialized with a specific value, but is uninitialized storage space to be filled in later. Re BSS= "Better Save Space", back in the 70s I remember a programmer telling me the BSS stood for "BullShit Storage" and could be uninitialized, you shouldn't trust it and always initialize your variables. See http://docs.oracle.com/cd/E19205-01/819-5262/aeugh/index.html or https://gcc.gnu.org/onlinedocs/gcc-3.4.6/g77/Prefer-Automatic-Uninitialized-Variables.html, the .no_init part of http://www.nongnu.org/avr-libc/user-manual/mem_sections.html for examples of Uninitialized_variable Drf5n (talk) 01:52, 13 February 2015 (UTC)[reply]

As well as I understand it, the unix linkers zero the .bss. It seems to be named after a feature of old IBM systems, which may or may not initialize them. The OS/360 equivalent, COM, is not initialized. (z/OS linkers still support the OS/360 object format.) OS/360 (and I suspect successors) doesn't special case zeros: if you want to initialize to zero, you write them all into the object program. Gah4 (talk) 06:24, 18 October 2017 (UTC)[reply]
The Oracle document says

Some systems automatically initialize local and COMMON variables to zero or some “not-a-number” (NaN) value. However, there is no standard practice, and programs should not make assumptions regarding the initial value of any variable. To assure maximum portability, a program should initialize all variables.

which, in practice, means "you can get away with not initializing variables on Solaris (a UNIX), because they'll be initialized to 0, and you can get away with it on other UN*Xes as well, but you can't guarantee it'll work on all systems which your program might run, as there are Fortrans (probably compiling code for non-UN*X and non-Windows OSes) that don't guarantee this". The GCC manual is talking about automatic variables, which are put on the stack, not in the BSS section. The nongnu.org manual is talking about code running on, I suspect, either no operating system or a non-UNIX (and non-Windows) real-time kernel.
So the answer is "The BSS segment isn't guaranteed to be initialized to zero on all platforms, but you can count on it on UN*Xes and on Windows, and possibly other platforms". I will update it to note that the guarantee of initialization to zero is not universal. (Although it might now be more common, if that's what's necessary to guarantee that you don't get to see whatever stuff happened to be in that physical memory location before your program used it, and exposing random data from other programs is considered a security risk.) Guy Harris (talk) 06:29, 18 October 2017 (UTC)[reply]
Reference[1] to FAP documentation, indicating that it is not zeroed. Gah4 (talk) 09:20, 18 October 2017 (UTC)[reply]
The C standard guarantees all .bss variables to be initialized to zero (0) or some sort of it (e.g. NULL pointer), independent of the OS. --79.238.107.199 (talk) 10:54, 16 November 2017 (UTC)[reply]
Apple's Preview fails to find the string "bss" in the PDFs I have of the C90, C99, and C11 specifications, so it appears that the C standard guarantees nothing about .bss. What the C90 standard says is that

If an object that has static storage duration is not initialized explicitly, it is initialized implicitly as if every member that has arithmetic type were assigned 0 and every member that has pointer type were assigned a null pointer constant.

This is not guaranteed to be done by placing those objects in a .bss segment, as it's not guaranteed that a platform even has a notion of a .bss segment, nor, if it does, that the platform will initialize the .bss segment to 0. If the platform has no notion of a .bss segment, the C implementation might have to put all such objects in an explicitly initialized data segment, and explicitly initialize them to 0/NULL (e.g. by putting bytes/words of 0 into that segment). If the platform has the notion of a .bss segment, but doesn't itself initialize the .bss segment to 0 when the program is started, the C implementation might have to have run-time initialization code that zeroes out the .bss segment before calling main().
So the C standard does not guarantee that the OS zeroes out the .bss segment, it guarantees that if the OS doesn't do it, the C implementation will do it. Guy Harris (talk) 19:04, 16 November 2017 (UTC)[reply]
Look at it the other way around. C guarantees that static variables are initialized to zero. Some people call the process of doing that, .bss. For systems designed to work with C, it is possible that such allocation method in the linker (which I believe C also doesn't require) will be named .bss. As noted above, OS/360 doesn't have .bss, but does have a way to initialize value by putting them in a CSECT. Fortran has BLOCK DATA allowing COMMON variables to be initialized, from years before C existed. But for many systems, it isn't that C requires .bss, but that people name the thing that C requires .bss anyway. Gah4 (talk) 22:56, 16 November 2017 (UTC)[reply]
"C guarantees that static variables are initialized to zero. Some people call the process of doing that, .bss." Well, they should stop doing so. It confuses C's requirement with a capability that 1) isn't necessarily present in the object/executable file format, linker, and program loader of all platforms that support C and 2) may be present on systems that antedated C.
This page absolutely should not claim that BSS space is always initialized to zero, regardless of whether some people call the process of initializing C's static variables to 0/NULL ".bss". Guy Harris (talk) 23:39, 16 November 2017 (UTC)[reply]
You can be pretty sure that no-one is running UA-SAP or FAP now, even if they have a 709 or 7090. As well as I know, those have BSS instead of .bss. (They use a six bit character code, so no lower case.) Are there any systems with a .bss that don't zero them? Gah4 (talk) 00:14, 17 November 2017 (UTC)[reply]

OK, so what is this page about?

Is it about the general notion of an object/executable file format allowing regions of the address space to be available to the program but not explicitly initialized by data in the file? If so, the article should probably be called something with "BSS" in the name, all-caps, and must not claim that it's implicitly initialized to zero, as per, for example, the 7090 FAP manual.

Is it about the UNIX notion of "the bss portion of the data segment" (to quote the 6th Edition a.out page), which is zeroed out (the V6 man page doesn't say it, but the a.out man page in the V7 manual does)? If so, it should speak only of UN*Xes and of systems with UN*X-derived or UN*X-inspired object/executable file formats (e.g., Windows), and should perhaps say less about C - and should perhaps just be called "bss segment" or something such as that, given that the leading "." wasn't there in a.out (there was no notion of named sections in a.out, so there was obviously no ".bss section"). Guy Harris (talk) 03:18, 17 November 2017 (UTC)[reply]

References

  1. ^ "FORTRAN ASSEMBLY PROGRAM (FAP) for the IBM 709/7090" (PDF). archive.computerhistory.org. p. 30. Retrieved 18 October 2017.
So far, there are no C compilers for the 7090, so this problem hasn't actually come up. However, Living Computer Museum might have one, and if they do, it might run someday, in which case it would be nice to have a C compiler. Specifically, since C allows for sign-magnitude representation for integers, we should be able to try it out. As mentioned above, for OS/360 and successors, you can have a separate COM (not intialized) or CSECT (initialized) block. However, more usual is to just put the variables in the same CSECT as the program. (That is in the pre-cache days, it isn't recommended for newer processors.) Inside a CSECT, you can have either initialized or uninitialized data. Gah4 (talk) 04:05, 17 November 2017 (UTC)[reply]

the Richard book

[edit]

Why is the Richard book being listed under References at all? --johayek (talk) 12:04, 24 February 2016 (UTC)[reply]

suggestion

[edit]

Suggestion: Move to "bss segment"

104.228.101.152 (talk) 00:49, 17 February 2018 (UTC)[reply]