Starting a new thread since this is off-topic for "MSP430 simulator in gdb".

The discussion is how to take advantage of newlib's libc
infrastructure while replacing the system interface that is by default
provided by libgloss: i.e. implementations of
read()/write()/sbrk()/gettimeofday() and other functions that
interface with a host environment (hardware, OS framework, simulator,
whatever).

The msp430-elf port appears to make this difficult in two ways:

1) gcc has a hard-coded LIB_SPEC that automatically adds -lnosys
whenever  the user fails to specify the simulator as the target.  The
need in the situation being discussed is to provide an alternative
implementation to -lnosys.  I've worked around this by removing
%{!msim:-lnosys} from LIB_SPEC and building a new toolchain.

2) The msp430 port of newlib is nearly unique in discarding the
libnosys implementation provided by newlib in favor of its own
crippled implementation.  (Of the dozen+ supported newlib targets
spu-* is the only other one that does this).  I've worked around this
by patching the msp430 target to remove the CIO-based -lnosys provided
libgloss/msp430/Makefile.in and instead keep the default
config_libnosys=true, leveraging the standard libgloss stub system
function implementation.

I've verified that with this toolchain I can use the newlib standard
option -specs=nosys.specs to link applications with the stubbed
version from libgloss for cases where I don't want to replace the
implementation.  I've also done enough testing to be convinced I can
provide an alternative implementation of the system interface
functions, as is normally permitted by newlib.

However, the changes necessary to make this work require building a
special version of the toolchain with modified upstream sources.
Works for me; not really acceptable to most users.  So presumably this
isn't the way I'm supposed to do this.

How am I supposed to do this?

Peter

On Thu, Jun 5, 2014 at 6:09 AM, Peter Bigot <big...@acm.org> wrote:
> On Tue, Jun 3, 2014 at 6:35 PM, DJ Delorie <d...@redhat.com> wrote:
>>
>>> You can do that with the RH newlib as long as you don't link in
>>> libgloss's versions of the low-level routines - i.e. remove -lgloss
>>> from your link line and add -lbspacm.
>>
>> To clarify: don't link in -lnosys if you're not compiling with "-msim"
>> or don't link in -lsim if you are compiling with "-msim"
>>
>> Both of these are linked at the same point as libc and libgcc, by the
>> gcc driver, depending on whether or not you use the -msim option.
>
> Yes, first impressions suggest if I could get rid of libgloss entirely
> I could do what I want.
>
> But since gcc's LIB_SPEC helpfully adds -lnosys for me at no extra
> charge when I don't use -msim, how can I avoid linking it in?
>
> Peter

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to