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 <waddlesplash@gmail.com>
This commit is contained in:
PulkoMandy 2020-12-30 19:01:02 +01:00 committed by waddlesplash
parent 2ef7fd7186
commit 9a8463437d

View File

@ -296,10 +296,14 @@ ELFLoader<Class>::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