linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] symaddr: give a type to OP_SYMADDR
@ 2020-11-22 17:50 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-11-22 17:50 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

Currently, OP_SYMADDRs are given a size but not a type.
But the type is needed for several things, the idea being
that for each instruction producing a pseudo (PSEUDO_REG)
it's possible to:
* retrieve its defining instruction
* retrieve its type via this defining instruction

Fix this by giving to OP_SYMADDRs the type of their symbol.

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

diff --git a/linearize.c b/linearize.c
index 8a3cf09bfae2..9fecb4b57e43 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1128,13 +1128,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;
 }
@@ -1914,7 +1914,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);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-22 17:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-22 17:50 [PATCH] symaddr: give a type to OP_SYMADDR Luc Van Oostenryck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).