On 02/04/2016 04:46 PM, Edward Nevill wrote:
The webrev ensures this by using bits 32..47 from the PC and bits 0..31 from the destination address. The fact that we use the XXXX bits from the PC ensures the requirement that the address is reachable and using only the bottom 32 bits of the dest ensures we only get the bits we actually want the adrp instruction to construct and not any extraneous bits in bits 48 etc.
The code that does this is
unsigned long adrp_target = (target & 0xffffffffUL) | (source & 0xffff00000000UL);
and this is also reflected in pd_patch_instruction to calculate the adrp target there.
Much better, but this still is confusing. Surely you can do unsigned long target = (unsigned long)dest.target(); unsigned long adrp_target = (target & 0xffffffffUL) | ((unsigned long)pc() & 0xffff00000000UL); _adrp(reg1, (address)adrp_target); movk(reg1, target >> 32, 32); } "source" doesn't really mean anything here. OK with that change. Andrew.