Controlling ld and as with GCC-Backend

Jens Mehler jens.mehler@mni.thm.de
Sun Mar 17 19:05:00 GMT 2013


Am 17.03.2013 13:50, schrieb Chung-Ju Wu:
> 2013/3/17 Jens Mehler <jens.mehler@mni.thm.de>:
>> Hi,
>>
>> the problem I keep running into is something that I don't fully
>> understand (yet).
>> I wrote a new backend for GCC, ported the GNU-Toolchain to my target and
>> got it running.
>>
>> The next thing I did:
>> I wrote a small helloworld.c a start.s and an end.s.
>> Everything that is needed is included in those files. When building the
>> program myself:
>> eco32-elf-gcc -S helloworld.c
>> eco32-elf-as -o hello.o start.s helloworld.s end.s
>> eco32-elf-ld -o hello.elf hello.o
>> everything works like a charm. The program even runs in the simulator
>> (after using eco32-elf-objdump -O binary hello.elf hello.bin)
>>
>> After that I tried using only gcc:
>> gcc -o hello.elf start.s helloworld.c end.s
>> after that I got "ld can't find crt0.o".
> Hi Jens,
>
> It is controlled by spec mechanism.
> The following is the link for its syntax:
> http://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html
>
> In your case, I think you should define your own
> STARTFILE_SPEC and ENDFILE_SPEC to guide gcc driver
> using start.o and end.o files.
>
>
> Best regards,
> jasonwucj
>
Hi Jasonwucj,

I implemented the start.o and end.o.
Fixed some errors in my binutils by letting the default functions taking
care of relaction and just adjust the reloc entries to the correct values.
Thanks for all your help!
~ Jens



More information about the Gcc-help mailing list