[haiku-commits] Change in haiku[master]: bootloader elf: fix misaligned access

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 30 Dec 2020 18:07:01 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxx>:

Adrien Destugues has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/3567 ;)


Change subject: bootloader elf: fix misaligned access
......................................................................

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.
---
M src/system/boot/loader/elf.cpp
1 file changed, 8 insertions(+), 4 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/67/3567/1

diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp
index b0e3e58..fd4655d 100644
--- a/src/system/boot/loader/elf.cpp
+++ b/src/system/boot/loader/elf.cpp
@@ -296,10 +296,14 @@
        // 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

--
To view, visit https://review.haiku-os.org/c/haiku/+/3567
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I9dd9b9f2b1d14821e34bc2f5b3da661086ef3fef
Gerrit-Change-Number: 3567
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: bootloader elf: fix misaligned access - Gerrit