A89: bug in mlink, please get v2.11 (uninitialized data...)
[Prev][Next][Index][Thread]
A89: bug in mlink, please get v2.11 (uninitialized data...)
Hi!
Short version:
I just fixed a nasty bug in mlink. *Now* it properly deals with
uninitialized data. Please download the latest version (v2.11) from
http://alh.dhs.org/ti89/
Long version:
Until recently, I didn't know that there are three ways to declare public/
external variables in C, i.e. that it is perfectly valid to leave out the
`extern' keyword for external references:
(at the top level:)
int a = 0; /* Creates a memory cell with contents `zero' and assigns the
* global name `a' to it.
*/
extern int a; /* Tells the C compiler that there is a global variable
* called `a' and that space is allocated somewhere else.
*/
int a; /* Creates a global variable called `a', but no space is allocated.
* The variable is declared as a common block. Common blocks are
* overlayed by the linker (they share memory space), i.e. all
* common `a' blocks (variables) will share the same memory cell.
*/
This is the reason why Xavier's linked fails on uninitialized data: There
is no space allocated for the variables, not in any object file! mlink
prior to v2.11 didn't care about this either (because I didn't know! and for
some reason it seemed to work anyway?), but now it knows better. mlink
v2.11 handles these common blocks properly and merges and allocates space
for them as necessary. Variables that are never used (e.g. the special
"flag" variables `_ti89', `_ti92plus', `_nostub' etc) will be optimized
away and not included in the final program image.
--
Johan "Knowledge is an illusion without answers."