This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

linker cannot fix X bytes into a hole X bytes long!

I am getting a very strange error from the C6000 linker:

lnk6x -mv=6600 _tsk.obj debug\single\_linker.cmd


"_linker.cmd", line 5: error: program will not fit into available memory.  placement with alignment fails for section ".text" size 0x1220 .
   Available memory ranges:
   MEM_18       size: 0x1220       unused: 0x1220       max hole: 0x1220
error: errors encountered during linking; "$kernel.out" not built

The alignment of the .text section is 32 (from ofd6x):

      18 .text                     0x00000000 0x00000000 0x1220    32   Y

The relevant part of the command file is:

MEMORY {
   MEM_18: o=0x00800420 l=0x00001220
}
SECTIONS {
   .text > MEM_18
}

So the error is saying that it can't fit 0x1220 bytes into a properly-aligned hole at 0x00800420 that is 0x1220 bytes long!

There are no other .text sections or subsections.

The input object and command files are attached.

single.zip
  • The error message is a bit misleading about the size of .text.   The reported size is the total size of the input sections named .text, but doesn't account for the trampolines that the linker had to add.  If you look at the linker map file (the linker option --map_file), you'll see that the actual size of .text after trampolines are added is 0x14e0.  Certainly that error message needs to be made clearer; I've submitted SDSCM00046391 to track that issue.