From 2c569953d074d9e82905b15c353d242bd1329bdd Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 13 Dec 2021 11:07:56 +0100 Subject: [PATCH] base: replace ELF flags bitfield with booleans Instead of using a bitfield for storing rwx and skip boolean value, take a boolean instead. This fixes a note giv]en by GCC 9.1 about changes semantics of bitfields given as parameter by value on ARM. Ref #4344 --- repos/base/src/include/base/internal/elf.h | 8 ++++---- repos/base/src/lib/base/elf_binary.cc | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/repos/base/src/include/base/internal/elf.h b/repos/base/src/include/base/internal/elf.h index f982c03c92..869f6b626d 100644 --- a/repos/base/src/include/base/internal/elf.h +++ b/repos/base/src/include/base/internal/elf.h @@ -42,10 +42,10 @@ class Genode::Elf_binary /* special types */ struct Flags { - unsigned r:1; - unsigned w:1; - unsigned x:1; - unsigned skip:1; + bool r { false }; + bool w { false }; + bool x { false }; + bool skip { false }; }; /** diff --git a/repos/base/src/lib/base/elf_binary.cc b/repos/base/src/lib/base/elf_binary.cc index 4eed8790bd..d2f6f9a0db 100644 --- a/repos/base/src/lib/base/elf_binary.cc +++ b/repos/base/src/lib/base/elf_binary.cc @@ -78,7 +78,7 @@ Elf_segment Elf_binary::get_segment(unsigned num) { void *start; size_t offset, filesz, memsz; - Elf_binary::Flags flags = { 0, 0, 0, 0 }; + Elf_binary::Flags flags; if (!valid()) return Elf_segment(); @@ -91,16 +91,16 @@ Elf_segment Elf_binary::get_segment(unsigned num) filesz = phdr->p_filesz; memsz = phdr->p_memsz; - flags.r = (phdr->p_flags & PF_R) ? 1 : 0; - flags.w = (phdr->p_flags & PF_W) ? 1 : 0; - flags.x = (phdr->p_flags & PF_X) ? 1 : 0; + flags.r = (phdr->p_flags & PF_R) ? true : false; + flags.w = (phdr->p_flags & PF_W) ? true : false; + flags.x = (phdr->p_flags & PF_X) ? true : false; /* * Skip loading of ELF segments that are not PT_LOAD or have no memory * size. */ if (phdr->p_type != PT_LOAD || !memsz) - flags.skip = 1; + flags.skip = true; return Elf_segment(this, start, offset, filesz, memsz, flags); }