ASH: why ash_ptr_to_globals_misc is declared as const pointer

Xabier Oneca -- xOneca xoneca at gmail.com
Sat Jan 20 11:18:26 UTC 2018


Hi Mike,

>> My question is.
>>    the  ash_ptr_to_globals_misc, ash_ptr_to_globals_memstack
>> and ash_ptr_to_globals_var
>> are defined in ash_ptr_hack.c as normal pointers. But in ash.c, they are
>> declared as const
>> pointers. What is the benefit of doing that?
>
> the pointer itself is the thing that is const, not the memory it points to.
> this lets the compiler optimize the loads by generating relocations via the
> pointer ... there's the fixup at the initial load time, but after that, it's
> just offsets to a constant memory location.  but removing the const markings,
> the compiler has to reload the pointer everytime.

Then why is "cheating" in the header file defining it non-const?

Cheers,
Xabier Oneca_,,_


More information about the busybox mailing list