Thanks, but to clarify, I now have the linker working as it is
supposed to. The problem is that under certain conditions sdcc deletes
the linker output, as demonstrated in the attachment to the bug
report. I can work around it for now though.

2009/7/10 David Lucena <yakumokl...@yahoo.es>:
>
>
>
> --- El vie, 10/7/09, Alistair Buxton <a.j.bux...@gmail.com> escribió:
>
>> De: Alistair Buxton <a.j.bux...@gmail.com>
>> Asunto: Re: [Sdcc-user] Z80 and custom crt0 - gsinit is pointing to GSFINAL 
>> instead of GSINIT
>> Para: sdcc-user@lists.sourceforge.net
>> Fecha: viernes, 10 julio, 2009 11:31
>> 2009/7/7 Alistair Buxton <a.j.bux...@gmail.com>:
>> > 2009/7/7  <bob...@comcast.net>:
>> >>
>> >> ----- Alistair Buxton wrote:
>> >>
>> >>> When I use my custom crt0, in the final
>> binary, gsinit: is pointing to
>> >>> GSFINAL instead of GSINIT.
>> >>
>> >> crt0 needs to be the first module in the list of
>> modules you link.
>> >> If it is not first, then the gsinit label will not
>> be ahead of the stuff
>> >> the compiler puts in the GSINIT area.  This is
>> not documented
>> >> very well.  I think that when you let sdcc
>> magically add crt0, it
>> >> places it ahead of everything else you link.  But
>> when you use
>> >> the "--no-std-crto", it is up to you to put it
>> first.
>> >
>> > If I place crt0 first in the list of files for the
>> linker, it produces
>> > no output at all. No error messages, and no IHX file.
>> > The linker seems to want the .o file with main()
>> first.
>>
>> After digging deeper this seems to be a problem with the
>> sdcc front
>> end - the linker produces correct output and then sdcc
>> promptly
>> deletes it because it expected the linker to use an
>> intermediate file
>> name, but link-z80 directly uses the name specified by -o.
>>
>
> I don't know if this will help you. It has passed many months since I last
> worked with a z80 machine, but I have an example of .lnk file that I generate 
> automatically with makefile and worked for me:
>
> -->START<--
> --
> -m
> -j
> -x
> -i /home/yakumo/dev/prj/msx/sdk/build/demos/testmake/bin/testmake
> -b _CODE = 0x4020
> -b _DATA = 0x8000
> -k /usr/local/share/sdcc/lib/z80
> -l z80
> /home/yakumo/dev/prj/msx/sdk/build/libraries/startup/bin/crt0msx_rom.o
> /home/yakumo/dev/prj/msx/sdk/build/demos/testmake/obj/psg.o
> /home/yakumo/dev/prj/msx/sdk/build/demos/testmake/obj/debug.o
> /home/yakumo/dev/prj/msx/sdk/build/demos/testmake/obj/main.o
> /home/yakumo/dev/prj/msx/sdk/build/demos/testmake/obj/psgasm.o
> /home/yakumo/dev/prj/msx/sdk/build/demos/testmake/obj/test.o
> -l z80.lib
> -->END<--
>
> As you can see, I link with a custom crt. In case it would be helpful for
> you, I'll paste also the contents of the crt file.
>
> -->START<--
>        ; Generic crt0.s for a Z80
>                .module crt0msx_rom_s
>                .globl  _main
>
>        .area _HEADER (ABS)
>        ; Reset vector
>        .org    0x4000
>        .db     0x41
>        .db     0x42 ; "AB" HEADER
>        .dw     init
>        .dw     0x0000
>        .dw     0x0000
>        .dw     0x0000
>        .dw     0x0000
>        .dw     0x0000
>        .dw     0x0000
>
> init:
>        ;
>        ; Stack at the top of memory.
>        ld      sp,(0xfc4a)
>
>        ; Initialise global variables
>                call    gsinit
>                call    _main
>                ;jp             _exit
>
>        ; Ordering of segments for the linker.
>        .area   _CODE
>        .area   _GSINIT
>        .area   _GSFINAL
>
>        .area   _DATA
>        .area   _BSS
>
>    .area   _CODE
>
>    ; Special RLE decoder used for initializing global data
> ;__initrleblock::
> ;        ret
>
>        .area   _GSINIT
> gsinit::
>
>        .area   _GSFINAL
>        ret
> -->END<--
>
> Hope it could help.
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> Enter the BlackBerry Developer Challenge
> This is your chance to win up to $100,000 in prizes! For a limited time,
> vendors submitting new applications to BlackBerry App World(TM) will have
> the opportunity to enter the BlackBerry Developer Challenge. See full prize
> details at: http://p.sf.net/sfu/Challenge
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
>



-- 
Alistair Buxton
a.j.bux...@gmail.com

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to