10.9.1. Range restrictions

The linker ensures that no branch or subroutine call violates these range restrictions. If you place your execution regions in such a way as to require inter-region branches beyond the range, the linker generates an error message stating:

Relocated value too big for instruction sequence

There are two ways to work around this restriction:

Function pointers

For example, if the application currently has a function:

int func(int a, int b);

that is invoked as:

func(a, b);

you can change this using function pointers into:

typedef int FuncType(int, int);
FuncType *fn = func;

and invoke the function as:

fn(a, b);

Assembly language veneers

If you use assembly language veneers, you can write the function as:

asm_func(a,b);

where asm_func is an assembly language routine.

Because ARM and Thumb assembly languages differ, the code for the veneers is slightly different.

The following is the assembly language veneer for ARM:

	AREA 		arm_longbranch_veneers, CODE, READONLY
	EXPORT 		asm_func
	IMPORT 		func
asm_func
	LDR 		pc, addr_func
addr_func
	DCD 		func
	END

The following is the assembly language veneer for Thumb:

	AREA 		thumb_longbranch_veneers, CODE, READONLY
	EXPORT 		asm_func
	IMPORT 		func
asm_func
	SUB		sp,#4
	PUSH 		{r0}
	LDR 		r0, addr_func
	STR 		r0, [sp,#4]
	POP 		{r0,pc}
	ALIGN
addr_func
	DCD 		func
	END

Note

You must ensure that the file containing these veneers is within range of the module calling asm_func(a,b).

Copyright © 1997, 1998 ARM Limited. All rights reserved.ARM DUI 0040D
Non-Confidential