From 8433503792b925141a925f567c664af38740e887 Mon Sep 17 00:00:00 2001 From: Olaf Seibert Date: Thu, 21 May 2015 23:21:19 +0200 Subject: [PATCH] Make sure that undefined global symbols don't get reduced to 0 when negated Test case: ; test complex relocations ; .globl IE.ITS,IE.MON ; implicit mov #-IE.ITS, space space: .word IE.ITS ; the only simple relocation .word -IE.ITS ; all others are complex relocations .word ^C .word IE.ITS + IE.MON .word IE.ITS - IE.MON .word IE.ITS * IE.MON .word IE.ITS / IE.MON .word IE.ITS & IE.MON .word IE.ITS ! IE.MON --- extree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extree.c b/extree.c index e42d256..061b319 100644 --- a/extree.c +++ b/extree.c @@ -352,7 +352,9 @@ EX_TREE *evaluate( /* negate literal */ res = new_ex_lit((unsigned) -(int) tp->data.lit); free_tree(tp); - } else if (tp->type == EX_SYM || tp->type == EX_TEMP_SYM) { + } else if (tp->type == EX_TEMP_SYM || + (tp->type == EX_SYM && + (tp->data.symbol->flags & SYMBOLFLAG_DEFINITION))) { /* Make a temp sym with the negative value of the given sym (this works for symbols within relocatable sections too) */