On Thu, Jan 5, 2023 at 3:20 AM Petr Mladek <pmladek@xxxxxxxx> wrote: [...] > > The ideal solution would be to add checks into apply_relocated_add(). > It would make it more robust. In that case, clear_relocated_add() > would need to clear everything. > > But this is not the case on powerpc and s390 at the moment. > In this case, I suggest to clear only relocations that > are checked in apply_relocated_add(). > > But it should be done without duplicating the code. > > It would actually make sense to compute the value that was > used in apply_relocated_add() and check that we are clearing > the value. If we try to clear some other value than we > probably do something wrong. > > This might actually be a solution. We could compute > the value in both situations. Then we could have > a common function for writing. > > This write function would check that it replaces zero > with the value in apply_relocate_add() and that it replaces > the value with zero in clear_relocate_add(). I like this idea. But I am not quite sure whether we can do it for all those complicated cases. Btw: I am confused with this one: case R_PPC64_REL16_HA: /* Subtract location pointer */ value -= (unsigned long)location; value = ((value + 0x8000) >> 16); *((uint16_t *) location) = (*((uint16_t *) location) & ~0xffff) | (value & 0xffff); break; (*((uint16_t *) location) & ~0xffff) should always be zero, no? Thanks, Song