error "expression too complex"; complex relocation? (correction)

Peter Tanski peter_tanski at cox.net
Sun Dec 10 11:51:01 PST 2006


> On Fri, 8 Dec 2006, Peter Tanski wrote:
>> 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?
>>

On Dec 9, 2006, at 4:21 PM, Peter Johnson wrote:
> More like an not-yet-supported feature :).  Yes, it's a bug.  NASM  
> doesn't support cross-section references of this form but GAS  
> does.  Yasm has support for expressions of the form (sym in other  
> section)-(current position, e.g. "." or "$"), but I didn't think  
> through the fact this could be extended for the general case of  
> (sym in other section)-(sym in current section).
>
> I'll get a fix for this committed sometime this weekend.

On Dec 10, 2006, at 2:05 AM, Peter Johnson wrote:
> Fixed in [1705].

Great job!  Thanks!

I tested the fix using the original GHC-output assembler file,  
"hello.s" and found that Windows will complain that the final  
executable is not a valid Win32 executable (Mdbg issues an Exception:  
"HRESULT: ... 0x800700C1").  The problem was with some sections-- 
possibly .stab ? I did not request any debug info from Yasm--that the  
Windows loader has trouble with.  After relinking the same object  
file by passing Mingw's 'ld' the "-s" option to strip all debugging  
symbols everything ran fine...  For example:

 > yasm -a x86 -p gas -f win32 hello.s -o hello.o

-- ghc contains the linker data to create an executable...
 > ghc hello.o -o hello

 > ./hello
-- bad Win32 executable

-- '-optl' passes an option to the linker (currently Mingw's 'ld')
-- here, the linker option is '-s' :
 > ghc -optl-s hello.o -o hello

 > ./hello
yasm works!

If there is anything I can do to help further, let me know.  Right  
now I am attempting to port the build and Native Code Generation for  
Ghc to use Yasm.  I am much more knowledgeable about PowerPC,  
however, since I do the bulk of my development work on Mac OS X.  (It  
would be nice to port Yasm to OS X and then add PPC output, but I'm a  
bit short of time at the moment.)

Thanks again!
Peter Tanski


More information about the yasm-devel mailing list