From 9a8463437dd8bb9358e74663aa7cbdf8e26f299d Mon Sep 17 00:00:00 2001 From: PulkoMandy Date: Wed, 30 Dec 2020 19:01:02 +0100 Subject: [PATCH] bootloader elf: fix misaligned access The elf region structure is packed. So it's not possible to use a pointer to one of its fields on sparc. Use a temporary variable that's properly aligned. Change-Id: I9dd9b9f2b1d14821e34bc2f5b3da661086ef3fef Reviewed-on: https://review.haiku-os.org/c/haiku/+/3567 Reviewed-by: waddlesplash --- src/system/boot/loader/elf.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp index b0e3e58be7..fd4655d2a9 100644 --- a/src/system/boot/loader/elf.cpp +++ b/src/system/boot/loader/elf.cpp @@ -296,10 +296,14 @@ ELFLoader::Load(int fd, preloaded_image* _image) // can automatically allocate an address, but shall prefer the specified // base address. totalSize = secondRegion->start + secondRegion->size - firstRegion->start; - if (Class::AllocateRegion(&firstRegion->start, totalSize, - B_READ_AREA | B_WRITE_AREA, &mappedRegion) != B_OK) { - status = B_NO_MEMORY; - goto error1; + { + AddrType address = firstRegion->start; + if (Class::AllocateRegion(&address, totalSize, + B_READ_AREA | B_WRITE_AREA, &mappedRegion) != B_OK) { + status = B_NO_MEMORY; + goto error1; + } + firstRegion->start = address; } // initialize the region pointers to the allocated region