[ell-i-developers] Re: Ellduino Emulator: Fixing issues for Linux (Ubuntu 12.04 LTS)

  • From: Pekka Nikander <pekka.nikander@xxxxxx>
  • To: ell-i-developers@xxxxxxxxxxxxx
  • Date: Thu, 20 Feb 2014 07:42:15 +0200

>> As in Mac OS X the gnu linker is not used, I cannot use a .ld file in Mac.  
>> Hence, for the emulator only, instead of a .ld file I use the emulator_post 
>> and emulator_pre objects, which define the _peripheral_start and 
>> _peripheral_end.  For Linux, you don't want them, but you want to create a 
>> linux.ld file, probably in emulator/ld/linux.ld.  For that, you have to 
>> create a new linker script, and either copy to it or include to it the 
>> default gcc 4.7 linker file for Linux.  That in turn requires that you first 
>> learn how the GNU ld scripts work and what happens here.  It is largely 
>> document in the comments, but only at a quite high level.
>> 
>> Please have a look at default internal linker script used by COMMAND ld in 
>> linux:
> 
> My questions is that how to use this default linker script and add the 
> peripheral initialization memory variables there ... isn't it so that we have 
> recompile the whole GCC toolchain for that script?

You definitely do *not* need to recompile the whole toolchain.

As far as I know, just like in Unix, in Linux one can link a binary either with 
gcc, which passes a number of default parameters to the ld command, or directly 
with the ld command, as we do for the ARM binaries.

From the arm ld command line (and the ld command manual page) you can see that 
that the -T or --script option can be used to pass the linker the linker script 
file.  Then, from the gcc command manual page you can see that one can use the 
-Xlinker option to pass an option to the linker.

> Is it possible, so that we link manually, calling the ld-script 
> written/(copied from default) ourselves e.g.  emulator/ld/linux.ld for the 
> emulator objects? Any idea how to call this ld script from emulator make file?

Putting the things above together, you should pass the following options to gcc:

   -Xlinker -T -Xlinker your-linker-script.ld

If you add those to the LDFLAGS variable in emulator.mk, that should work.

--Pekka


Other related posts: