Commit a932eec4 authored by Alex Bennée's avatar Alex Bennée Committed by Thomas Huth
Browse files

linux-user: limit check to HOST_LONG_BITS < TARGET_ABI_BITS



Newer clangs rightly spot that you can never exceed the full address
space of 64 bit hosts with:

  linux-user/elfload.c:2076:41: error: result of comparison 'unsigned
  long' > 18446744073709551615 is always false
  [-Werror,-Wtautological-type-limit-compare]
  4685         if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) {
  4686             ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~
  4687 1 error generated.

So lets limit the check to 32 bit hosts only.

Fixes: ee947430
Reported-by: default avatarThomas Huth <thuth@redhat.com>
Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
Message-Id: <20200525131823.715-8-thuth@redhat.com>
[thuth: Use HOST_LONG_BITS < TARGET_ABI_BITS instead of HOST_LONG_BITS == 32]
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent 06539ebc
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2073,12 +2073,14 @@ static void pgb_have_guest_base(const char *image_name, abi_ulong guest_loaddr,
            exit(EXIT_FAILURE);
        }
    } else {
#if HOST_LONG_BITS < TARGET_ABI_BITS
        if ((guest_hiaddr - guest_base) > ~(uintptr_t)0) {
            error_report("%s: requires more virtual address space "
                         "than the host can provide (0x%" PRIx64 ")",
                         image_name, (uint64_t)guest_hiaddr - guest_base);
            exit(EXIT_FAILURE);
        }
#endif
    }

    /*