This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: Proper way of replacing crt0.o/GCC search path for startup files
- From: David Paterson <dnpaterson at gmail dot com>
- To: "Schwarz, Konrad" <konrad dot schwarz at siemens dot com>
- Cc: Nicholas Clifton <nickc at redhat dot com>, "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Mon, 18 May 2015 11:08:32 +0100
- Subject: Re: Proper way of replacing crt0.o/GCC search path for startup files
- Authentication-results: sourceware.org; auth=none
- References: <A45B1767F1002449A37508C2CC6003D711E2CB at DEFTHW99EJ1MSX dot ww902 dot siemens dot net> <55508869 dot 5000908 at redhat dot com> <A45B1767F1002449A37508C2CC6003D71210D3 at DEFTHW99EJ1MSX dot ww902 dot siemens dot net>
Hi Konrad,
I've done something similar, and used a customised linker script to
provide extra information (as well as the memory mapping for my
particular system). The linker scrip I'm using has commands similar
to :
ENTRY(_start)
STARTUP(my-crt0.o)
INPUT(crti.o crtbegin.o crtend.o crtn.o)
GROUP(-lmylib -lc -lstdc++ -lgcc)
and is invoked by using gcc -nostartfiles -Tmyscript.ld ... etc.
To me, this seemed the easiest way to include my crt0, rather than
modifying spec files.
Regards,
DavidP
On 15 May 2015 at 15:13, Schwarz, Konrad <konrad.schwarz@siemens.com> wrote:
>> -----Original Message-----
>> From: Nicholas Clifton [mailto:nickc@redhat.com]
>> > I have written an alternative crt0.o (the startup file placed at
>> the
>> > beginning of the executable) for a bare-metal system.
>> >
>> > For GCC to use this, it requires a new specs file.
>>
>> Have you considered using --nostartfiles instead ?
>
> I think this would require getting the user to explicitly add
> <gcc-startup-dir>/crti.o and <gcc-startup-dir>/crtbegin.o, in addition
> to the special crt0.o, to the link, and seems more painful.
>
>> > I was unable to find precise documentation on how GCC searches for
>> > specs files and for startup files. It seems like directories added
>> by
>> > -L are not searched for spec or startup files, for example. (I.e.,
>> > my_crt0%o%s was not found by GCC, despite an appropriate -L
>> argument).
>>
>> Have you tried using -B instead of -L ?
>
> -B seems to change a lot more things.
>
> In any case, thanks very much for your suggestions!
>
> Regards
>
> Konrad