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<IE.ITS>
        .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
This commit is contained in:
Olaf Seibert 2015-05-21 23:21:19 +02:00
parent b8a15a89b5
commit 8433503792

View File

@ -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) */