error: "expression too complex"; complex relocation?

Peter Tanski p.tanski at gmail.com
Fri Dec 8 09:47:31 PST 2006


Hello,

I am attempting to use Yasm as a replacement for GAS to compile  
assembler output from a functional language compiler, the Glasgow  
Haskell Compiler (GHC).  GHC currently works with GAS on Windows  
(mingw) but I am looking to Yasm for Win32 object format (GAS-COFF is  
not compatible with the Microsoft linker and Yasm is Windows-native).

When I use Yasm to compile a GHC-output assembler file with the  
command, I get an "expression too complex" error for code similar to  
the following example:

.const_data
.align 2
_szy_srt:							; symbol1 here
	.long	_base_GHCziBase_unpackCStringzh_closure

; ...

.text
.align 2
_szy_info_dsp:
	.long	_szy_srt-(_szy_info)+0	; error here
	.long	0
	.long	1441793
_szy_info:							; symbol2 here
	addi	r31, r22, -8
	cmplw	r31, r24
	blt	LczU
	addi	r25, r25, 8
	cmplw	r25, r26
	; ...
	b	_stg_ap_n_fast
LczU:
	li	r31, 8
	stw	r31, 112(r27)
	b	___stg_gc_enter_1
	.long  _szy_info - _szy_info_dsp	;  used here

The error occurs with the satement:
	_szy_srt-(_szy_info)
which is a complex relocation (_szy_srt and _szy_info are the start  
addresses of two different sections); WRT in Nasm.

Yasm outputs the "expression too complex" error for all output object  
formats--except 'bin' and 'dbg', of course.

I traced the "expression too complex" error to libyasm/value.c  
yasm_value_output_basic(), which according to the Note should not be  
used for cases where a reloc is needed.  Is this a bug in Yasm?

Thanks in advance,
Peter Tanski




More information about the yasm-devel mailing list