Compile the following file (div.c) using "sdcc -mz80 div.c":
==== begin div.c ====
do_div(int a, int b)
int a = 23;
int b = 3;
return (do_div(a, b));
==== end div.c ====
then inspect the div.map file. The following lines appear at in the "Libraries Linked" section:
Libraries Linked [ object file ]
/tmp/sdcc/bin/../share/sdcc/lib/z80/z80. [ divsigned.rel ]
/tmp/sdcc/bin/../share/sdcc/lib/z80/z80. [ /0 ]
Looking at the functions in the _CODE section, eliminating the contents of div.c and divsigned.rel, then matching up with other libraries which make up z80.lib, it appears the second library should be "divusigned.rel".
I've tried with the hc08 and mcs51, and neither of those seem to suffer the same problem (at least for the same library). Only the z80 library seems affected (although I can't say that no other library file/object file will show up the same symptom).
I can't spot any obvious difference between divsigned.s and divunsigned.s which might explain it (although if this were the case, I'd expect other ports to show the same symptom) so I presume this is buried somewhere in the library handling of the z80 port.
The version of ar used to generate the library is that included in Solaris 11 express:
$ /usr/bin/ar -V
ar: Software Generation Utilities (SGU) Solaris-ELF (4.0)
The above code fragment was compiled with sdcc 3.0.2 #6382, built on Solaris using GCC 4.3.
This is not a new problem. If I re-build an old copy of sdcc (2.9.7 #5973), I see the same behaviour in the z80 port.