diff mbox

[2/2] symaddr: give a type to OP_SYMADDR

Message ID 20180618210140.69467-3-luc.vanoostenryck@gmail.com (mailing list archive)
State Rejected, archived
Headers show

Commit Message

Luc Van Oostenryck June 18, 2018, 9:01 p.m. UTC
Currently, OP_SYMADDR are given a size but not a type.
But the type is needed for several things.

Fix this by giving them the type of the pointer.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 linearize.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/linearize.c b/linearize.c
index e9354e437..ed49931ce 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1018,13 +1018,13 @@  static pseudo_t add_setfval(struct entrypoint *ep, struct symbol *ctype, long do
 	return target;
 }
 
-static pseudo_t add_symbol_address(struct entrypoint *ep, struct symbol *sym)
+static pseudo_t add_symbol_address(struct entrypoint *ep, struct expression *expr)
 {
-	struct instruction *insn = alloc_instruction(OP_SYMADDR, bits_in_pointer);
+	struct instruction *insn = alloc_typed_instruction(OP_SYMADDR, expr->ctype);
 	pseudo_t target = alloc_pseudo(insn);
 
 	insn->target = target;
-	use_pseudo(insn, symbol_pseudo(ep, sym), &insn->src);
+	use_pseudo(insn, symbol_pseudo(ep, expr->symbol), &insn->src);
 	add_one_insn(ep, insn);
 	return target;
 }
@@ -1616,7 +1616,7 @@  static pseudo_t linearize_expression(struct entrypoint *ep, struct expression *e
 	switch (expr->type) {
 	case EXPR_SYMBOL:
 		linearize_one_symbol(ep, expr->symbol);
-		return add_symbol_address(ep, expr->symbol);
+		return add_symbol_address(ep, expr);
 
 	case EXPR_VALUE:
 		return value_pseudo(expr->value);