Help save net neutrality! Learn more.

#2076 core dump from sdldz80 if relative jump exceeds range

linker (61)

If a library contains a function which uses a "jr" to a label in another library function, and that jump exceeds the range of a relative jump, the linker will core dump:

$ pstack core
core 'core' of 5496: /build/sdcc/8070/bin/sdldz80 -nf
08063c17 errdmp3 (807a720, 8067b54, feffe2b8, 806595b, 205, f) + b7
08063d6a relerr3 (8067b54, 6, feffe308, fe6c260f, 6, ffffffff) + 1a
0806454f relr3 (52, 0, feffe368, ffffff05, feffe3ba, 82fdf9e) + 26f
0805dcd4 link_main (feffe370, 400, 807a760, 700074, 8003052, 3) + 54
080634cb load_rel (807a760, e3, 0, fe6c5d94, 8320e80, 0) + 6b
0805755f loadfile_ar (832cba0, 400, 807a760, 806595b, 82fd798, 82fd798) + 9f
0805c5f0 library (807a720, feffe9d5, 66, fe7fb8bc, feffe830, fe7be504) + 30
0805f7a5 main (3, feffe860, feffe870, 8054342, 8066630, 0) + 385
080543a3 _start (3, feffe9b4, feffe9d1, feffe9d5, 0, feffe9dd) + 83

I've reduced this to as simple a test case as I can - attached - it should be self-contained and assemble ok.
Although it's a contrived test case, the linker should not core dump.

The output is:

$ make
/build/sdcc/8070/bin/sdasz80 -plosffwz crt.s
/build/sdcc/8070/bin/sdasz80 -plosffwz bigfile.s
/build/sdcc/8070/bin/sdasz80 -plosffwz jr_from.s
/build/sdcc/8070/bin/sdasz80 -plosffwz jr_to.s
/usr/bin/rm -f jr.lib
/usr/bin/ar -crS jr.lib bigfile.rel jr_from.rel jr_to.rel
/build/sdcc/8070/bin/sdranlib jr.lib
/build/sdcc/8070/bin/sdcc -mz80 --no-std-crt0 --out-fmt-ihx -o test.ihx crt.rel jr.lib

?ASlink-Warning-Byte PCR relocation error for symbol bigjump
file module area offset
*** Error code 1
make: Fatal error: Command failed for target `test.ihx'

$ /build/sdcc/8070/bin/sdcc -v
SDCC : z80 3.2.1 #8070 (Aug 19 2012) (Solaris i386)
(also seen with #8081)

In an ideal world, I would like to see the linker re-arrange the order of the objects within the resulting binary such that the jump can be accommodated (assuming it can), acknowledging this would mask certain programming errors, although I'll settle for a linker error and no core dump :-)


  • Brian Ruthven

    Brian Ruthven - 2012-09-03

    Test case for #8070

  • Philipp Klaus Krause

    • Category: --> sdld
  • Lee Morrison

    Lee Morrison - 2013-07-28
    • status: open --> open-fixed
    • assigned_to: Lee Morrison
  • Lee Morrison

    Lee Morrison - 2013-07-28

    The crash was caused by a Null pointer dereference in an error message.
    I fixed that issue, but have not attempt to make the linker re-arrange the object files.

  • Philipp Klaus Krause

    • status: open-fixed --> closed-fixed
  • Philipp Klaus Krause

    Well, re-arranging would be a feature request, so I'd say this bug report can be closed.



Log in to post a comment.