xcc -nostdlib includes startup files in tools 13 and 14 Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
ers35
Active Member
Posts: 62
Joined: Mon Jun 10, 2013 2:14 pm

xcc -nostdlib includes startup files in tools 13 and 14

Post by ers35 »

In tools 12.2.0, xcc -nostdlib builds an xe that contains only the code specified on the command line. In tools 13.0.0 and 14.2.0, the startup code is still included and the wrong _start from a different loadable is used.

Compare the following commands in tools 12 and tools 14:

Code: Select all

// test.S
// xcc -target=XR-AVB-LC-BRD -nostdlib test.S -o test.xe
// xobjdump -d test.xe
// xsim --trace test.xe
.text

.global _start
_start:
  ldc r0, 0
  ldc r1, 0
  ldc r2, 0
  ldc r3, 0
  ecallf r0
Is there a way to get the tools 12 behavior in tools 14.2.0 or is this a bug?


View Solution
robertxmos
XCore Addict
Posts: 169
Joined: Fri Oct 23, 2015 10:23 am

Post by robertxmos »

Hi ers35,

In version 12, the 'linker' (mapper) will only produce 'Lodable 1', the explicit user code, and no network setup code under certain conditions.
In version 13 & 14 the network setup and user code is always produced. You can turn this off using "--bootstyle=forsim"

Code: Select all

xcc -target=XR-AVB-LC-BRD -nostdlib test.S -o test.xe -Xmapper --bootstyle=forsim
Explanation:

The XR-AVB-LC-BRD is a two tile device.
For each tile, initialization and user code will be created.
Thus we have:
Loadable 1 for tile[0] // network setup for tile 0
Loadable 1 for tile[1] // network setup for tile 1
Loadable 2 for tile[0] // user code for tile 0
Loadable 2 for tile[1] // user code for tile 1

The debugger uses the Loadable 1, xflash ignore this when building an image.

In your example, Loadable 2 for tile[0] is as expected:

Code: Select all

  Loadable 2 for tile[0] (node "0", tile 0):
  Disassembly of section .text (size: 10)
  <_start>:
               0x00010000: 00 68:       ldc (ru6)       r0, 0x0
               0x00010002: 40 68:       ldc (ru6)       r1, 0x0
               0x00010004: 80 68:       ldc (ru6)       r2, 0x0
               0x00010006: c0 68:       ldc (ru6)       r3, 0x0
               0x00010008: e0 4f:       ecallf (1r)     r0
As you are not using the second code, it must be given something to do!
In the code below it 'tells' the debugger it has finished:

Code: Select all

Loadable 2 for tile[1] (node "1", tile 0):
Disassembly of section .text (size: 12)
<_start>:
             0x00010000: 07 68:       ldc (ru6)       r0, 0x7
             0x00010002: 02 d0:       bl (u10)        0x2 <_DoSyscall>
             0x00010004: ed 07:       clre (0r)       
             0x00010006: ec 07:       waiteu (0r)     
<_DoSyscall>:
             0x00010008: d0 a6:       mkmsk (rus)     r0, 0x20
             0x0001000a: c0 77:       retsp (u6)      0x0