svn commit: r293724 - in head/sys/boot: arm64/libarm64 common efi/boot1 efi/fdt efi/include efi/include/arm64 efi/libefi efi/loader efi/loader/arch/amd64 efi/loader/arch/arm efi/loader/arch/arm64 i...

Conrad Meyer cem at FreeBSD.org
Wed Jan 13 01:48:21 UTC 2016


On Tue, Jan 12, 2016 at 5:32 PM, Ian Lepore <ian at freebsd.org> wrote:
> Yep, but then I had to do this because ef->off is 64 bits even on 32
> bit arches, so I got a pointer/int size mismatch warning...
>
> Index: common/load_elf.c
> ===================================================================
> --- common/load_elf.c   (revision 293796)
> +++ common/load_elf.c   (working copy)
> @@ -886,7 +886,7 @@ __elfN(parse_modmetadata)(struct preloaded_file *f
>         error = __elfN(reloc_ptr)(fp, ef, v, &md, sizeof(md));
>         if (error == EOPNOTSUPP) {
>             md.md_cval += ef->off;
> -           md.md_data = (void *)((uintptr_t)md.md_data + ef->off);
> +           md.md_data = (void *)(uintptr_t)((uintptr_t)md.md_data +
> ef->off);
>         } else if (error != 0)
>             return (error);
>  #endif
>
>
> That is just some special kind of ugly.

Yes.  You could maybe do:

md.md_data = (c_caddr_t)md.md_data + (ptrdiff_t)ef->off;

Instead.  Yes, the ptrdiff_t will truncate uint64_t on 32-bit pointer
platforms, but the result is truncated regardless when it is stored in
the md_data pointer.  And the result under modulus is equivalent.

(You could even change the type of md_data to c_caddr_t from 'const
void *' to make it easier to do math on.  Then this could just be:
md.md_data += (ptrdiff_t)ef->off;)

Best,
Conrad


More information about the svn-src-all mailing list