union {
long IVal; /* If this is a int value */
struct SymEntry* Sym; /* If this is a symbol */
- unsigned SegNum; /* If this is a segment */
- struct Import* Imp; /* If this is an import */
+ unsigned SecNum; /* If this is a section and Obj != 0 */
+ unsigned ImpNum; /* If this is an import and Obj != 0 */
+ struct Import* Imp; /* If this is an import and Obj == 0 */
struct MemoryArea* Mem; /* If this is a memory area */
struct Segment* Seg; /* If this is a segment */
- struct Section* Sec; /* If section and Obj is NULL */
+ struct Section* Sec; /* If this is a section and Obj == 0 */
} V;
};
case EXPR_MEMAREA:
/* A memory area is const if it is not relocatable and placed */
- return !Root->V.Mem->Relocatable &&
+ return !Root->V.Mem->Relocatable &&
(Root->V.Mem->Flags & MF_PLACED);
default:
/* Check that this is really a symbol */
PRECONDITION (Expr->Op == EXPR_SYMBOL);
- /* Return the import */
- return Expr->V.Imp;
+ /* If we have an object file, get the import from it, otherwise
+ * (internally generated expressions), get the import from the
+ * import pointer.
+ */
+ if (Expr->Obj) {
+ /* Return the export */
+ return CollAt (&Expr->Obj->Imports, Expr->V.ImpNum);
+ } else {
+ return Expr->V.Imp;
+ }
}
*/
if (Expr->Obj) {
/* Return the export */
- return CollAt (&Expr->Obj->Sections, Expr->V.SegNum);
+ return CollAt (&Expr->Obj->Sections, Expr->V.SecNum);
} else {
return Expr->V.Sec;
}
/* Read an expression from the given file */
{
ExprNode* Expr;
- unsigned ImpNum;
/* Read the node tag and handle NULL nodes */
unsigned char Op = Read8 (F);
case EXPR_SYMBOL:
/* Read the import number */
- ImpNum = ReadVar (F);
- Expr->V.Imp = CollAt (&O->Imports, ImpNum);
+ Expr->V.ImpNum = ReadVar (F);
break;
case EXPR_SECTION:
/* Read the segment number */
- Expr->V.SegNum = Read8 (F);
+ Expr->V.SecNum = Read8 (F);
break;
default:
case EXPR_SYMBOL:
/* Import must be identical */
- return (E1->V.Imp == E2->V.Imp);
+ return (GetExprImport (E1) == GetExprImport (E2));
case EXPR_SECTION:
/* Section must be identical */