base: ELF segment types are not bitfields.
authorGabe Black <gabeblack@google.com>
Wed, 2 Oct 2019 02:26:12 +0000 (19:26 -0700)
committerGabe Black <gabeblack@google.com>
Sat, 5 Oct 2019 04:17:23 +0000 (04:17 +0000)
The ELF segment type had been checked by bitwise &-ing it with the
PT_LOAD constant to check if it was loadable. This is incorrect. The
value is a flat integer, with different values selecting different
types of segments.

Change-Id: I644dd985bda4ad2d992557c90ffe8048c0ae6aac
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21460
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com>
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>

src/base/loader/elf_object.cc

index 654cb33d5db9401bf4774f477a76405374db666f..2a8fb04ea30b7b3421d6ca4f468328fd8b689b8f 100644 (file)
@@ -342,7 +342,7 @@ ElfObject::ElfObject(const std::string &_filename, size_t _len,
         }
 
         // for now we don't care about non-loadable segments
-        if (!(phdr.p_type & PT_LOAD))
+        if (phdr.p_type != PT_LOAD)
             continue;
 
         ldMin = std::min(ldMin, phdr.p_vaddr);