[PING][PATCH 0/3][BFD][MSP430] Fix relocation overflows for -mcpu=msp430

Jozef Lawrynowicz jozef.l@mittosystems.com
Tue Jan 28 10:20:00 GMT 2020


ping for below.

Would be good to get this into 2.34 if possible.

Thanks,
Jozef

On Tue, 21 Jan 2020 20:21:43 +0000
Jozef Lawrynowicz <jozef.l@mittosystems.com> wrote:

> The GCC testsuite has a number of failures for -mcpu=msp430 (the 430 ISA),
> caused by the linker error:
> 
> > relocation truncated to fit: R_MSP430_10_PCREL against symbol  
> 
> The failures are somewhat transient; changes to code generation can cause
> them to appear/disappear for certain tests.
> 
> The relocation truncations occur because msp430_elf_relax_section knows how to
> relax unconditional branches into jumps but not how to relax jumps back to
> unconditional branches, which is required if that jump is later put out of
> range.
> 
> This bug is not fundamentally specific to the 430 ISA, however it only appears
> to manifest for it because it requires branch instructions to addresses >~1KB
> away to be generated. This only really happens when generating code for the 430
> ISA, which makes use of branches to library helper routines to pop the required
> number of registers off the stack on exit from a function
> (__mspabi_func_epilog_X).
> 
> The errors were caused by the enabling of the relaxation of unconditional
> branches for the 430 ISA back in 133193b8ae/cfe7b9bd58.
> 
> Reverting these changes fixes the relocation overflows and some execution
> failures, so I have regtested my patches against that reverted state, to ensure
> no fallout is missed.
> 
> Successfully regtested GCC/G++/Binutils testsuites for -mcpu=msp430,
> -mcpu=msp430x, -mlarge and
> -mlarge/-mdata-region=either/-mcode-region=either.
> 
> Ok to apply?
> 
> Jozef Lawrynowicz (3):
>   MSP430: Add printf statements to assist with debugging during
>     relaxation
>   MSP430: Enable relaxation of relocs in unconditional branch insns
>   MSP430: Enable relaxation of jump instructions to hard-coded prcrel
>     offsets
> 
>  bfd/elf32-msp430.c | 255 +++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 212 insertions(+), 43 deletions(-)
> 



More information about the Binutils mailing list