Closed tkchia closed 7 years ago
Thanks for the analysis! Coincidentally, I was actually investigating this exact problem today, though I came up with a different fix, just splitting up the calculation:
__lbss0 = __ebss - __sbss;
__lbss1 = __lbss0 + 1;
__lbss = __lbss1 / 2;
I'll commit this momentarily so that it will be fixed in the next release.
I think this is an actual linker bug rather than a problem with being section-relative - I've been doing most of my testing with a more recent version of binutils (the one in https://github.com/crtc-demos/binutils-ia16) which doesn't have this problem, but unfortunately the Mentor Graphics release used an older version of binutils in which this wasn't fixed.
Thank you! I await your next release. :)
I wrote a simple program
qux.c
(linked) which just does aprintf
and exits. When compiled, the.com
file startswhich crashes at the
rep stosw
due to a bogus BSS length (__lbss = 0xb1cb
).It seems
ld
got confused by the arithmetic in the expressionin
libgloss/ia16/dos-com.ld
, and thought that__lbss
should be relative to some section, rather than an absolute symbol.Changing the expression to e.g.
or
should fix the problem.
And, thank you very much for your
gcc
port! :)