Skip to content

Allow to make global variables unwritable #5272

@Rot127

Description

@Rot127

Is your feature request related to a problem? Please describe.

Some architectures have zero registers. They always hold the value zero and if they are written too don't change.
The only way to represent this in our uplifted archs is by checking for them and generating different RzIL.

Like this:

RZ_IPI RzILOpEffect *set_g(const char *gname, RzILOpPure *gval) {
	if (RZ_STR_EQ(gname, "g0")) {
		rz_il_op_pure_free(gval);
		return EMPTY();
	}
	return SETG(gname, gval);
}

#define SSETG(gname, gval) set_g(gname, gval)

// Use SSETG from here on.

These extra paths in an IL op take a lot of allocations and will be rarely used.

With the method above it doesn't take any allocations.
But still would not prevent to write or ignore writes to the immutable register during runtime.

Describe the solution you'd like

Being able to define a callback in RzAnalysisILConfig to check for global variable names which are immutable would be nice. As long as the checks are constant time it shouldn't matter.

Describe alternatives you've considered

Adding extra checks in the uplifting, as described above.

Additional context

none

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions