Hi,

On Fri, 2012-12-07 at 12:23 +0200, Alexandru Stefan wrote:

> When trying to compile with debugging symbols activated (-g option), the 
> linker puts out the following error messages:
> 
>      build/board_pdd036/drivers/input/buttons.o:(.debug_loc+0x6b): 
> relocation truncated to fit: R_MSP430_16_BYTE against `no symbol'
>      build/board_pdd036/drivers/input/buttons.o:(.debug_loc+0x75): 
> relocation truncated to fit: R_MSP430_16_BYTE against `no symbol'
> 

I've debugged this problem further and found out the source of the
problem in the ld source code. There's a validation in
bfd/elf32-msp430.c in function msp430_final_link_relocate:

  switch (howto->type)
    {

...
    case R_MSP430_16_PCREL_BYTE:
    case R_MSP430_16_BYTE:
      bfd_put_16 (input_bfd, MSP430_MASK_16 (srel), contents);
      if (r == bfd_reloc_ok && !MSP430_16_IN_RANGE (srel))
        r = bfd_reloc_overflow;
      break;
...

Our problem is that MSP430_16_IN_RANGE (srel) returns 0 and the ld code
goes on the error path from here.

In our case, it seems there are some relocations inside some debug
sections (the link error appears only when compiling with -g) which
exceed the 16-bit address space. I've added the following printf inside
the if statement:


printf("srel = 0x%X, name = %s, section = %s\n", srel, howto->name,
input_section->name);

and I get something like this in the output:

srel = 0x15431, name = R_MSP430_16_BYTE, section = .debug_loc
srel = 0x15431, name = R_MSP430_16_BYTE, section = .debug_loc
srel = 0x3C9A1, name = R_MSP430_16_BYTE, section = .debug_loc


I'm not very familiar with ld, but why is this check performed for debug
sections? Please correct me if I'm wrong, but as far as I know these
sections have meaning only for the debugger on the host, they don't get
into the image flashed on the target.


Thanks,
Ionut.



------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to