But I don't want to allow expressions like (const:SI (plus:SI symbol_ref:SI) (const_int)) in the insn. How should I do that, do I need to implement LEGITIMATE_CONST_P () accordingly?
Try making CONSTANT_ADDRESS_P reject the value.
Though it still isn't clear why you are getting relocation errors. If addresses wrap around at segment boundaries, then this should just work fine. a-40 gets converted into a very large positive segment offset that then wraps around back to a when 40 is added to it. Perhaps the assembler/linker need some work to handle this correctly.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com