Opened 6 years ago

Last modified 3 years ago

#14366 new bug

haiku_loader / BIOS: Unaligned pointer from packed class or structure

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System/Boot Loader/BIOS Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

/home/kallisti5/Code/haiku/src/system/boot/platform/bios_ia32/mmu.cpp:729:7: warning: taking address of packed member 'num_physical_memory_ranges' of class or structure 'kernel_args' may result in an unaligned
      pointer value [-Waddress-of-packed-member]
                                        &gKernelArgs.num_physical_memory_ranges,
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



/home/kallisti5/Code/haiku/src/system/boot/platform/bios_ia32/long.cpp:98:37: warning: taking address of packed member 'phys_pgdir' of class or structure 'arch_kernel_args' may result in an unaligned pointer
      value [-Waddress-of-packed-member]
        pml4 = (uint64*)mmu_allocate_page(&gKernelArgs.arch_args.phys_pgdir);
                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


C++ /home/kallisti5/Code/haiku/generated.clang.x86_64/objects/haiku/x86_64/release/system/boot/loader/bios_ia32/elf.o 
/home/kallisti5/Code/haiku/src/system/boot/loader/elf.cpp:302:29: warning: taking address of packed member 'start' of class or structure 'elf64_region' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (Class::AllocateRegion(&firstRegion->start, totalSize,
                                   ^~~~~~~~~~~~~~~~~~
/home/kallisti5/Code/haiku/src/system/boot/loader/elf.cpp:662:24: note: in instantiation of member function 'ELFLoader<ELF64Class>::Load' requested here
                        return ELF64Loader::Load(fd, *_image);
                                            ^
/home/kallisti5/Code/haiku/src/system/boot/loader/elf.cpp:302:29: warning: taking address of packed member 'start' of class or structure 'elf32_region' may result in an unaligned pointer value
      [-Waddress-of-packed-member]
        if (Class::AllocateRegion(&firstRegion->start, totalSize,
                                   ^~~~~~~~~~~~~~~~~~
/home/kallisti5/Code/haiku/src/system/boot/loader/elf.cpp:672:24: note: in instantiation of member function 'ELFLoader<ELF32Class>::Load' requested here
                        return ELF32Loader::Load(fd, *_image);
                                            ^
2 warnings generated.




C++ /home/kallisti5/Code/haiku/generated.clang.x86_64/objects/haiku/x86_64/release/system/boot/loader/bios_ia32/kernel_args.o 
/home/kallisti5/Code/haiku/src/system/boot/loader/kernel_args.cpp:33:4: warning: taking address of packed member 'num_kernel_args_ranges' of class or structure 'kernel_args' may result in an unaligned pointer
      value [-Waddress-of-packed-member]
                &gKernelArgs.num_kernel_args_ranges, MAX_KERNEL_ARGS_RANGE,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kallisti5/Code/haiku/src/system/boot/loader/kernel_args.cpp:279:4: warning: taking address of packed member 'num_physical_memory_ranges' of class or structure 'kernel_args' may result in an unaligned
      pointer value [-Waddress-of-packed-member]
                &gKernelArgs.num_physical_memory_ranges, MAX_PHYSICAL_MEMORY_RANGE,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kallisti5/Code/haiku/src/system/boot/loader/kernel_args.cpp:288:4: warning: taking address of packed member 'num_physical_allocated_ranges' of class or structure 'kernel_args' may result in an unaligned
      pointer value [-Waddress-of-packed-member]
                &gKernelArgs.num_physical_allocated_ranges,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/kallisti5/Code/haiku/src/system/boot/loader/kernel_args.cpp:297:4: warning: taking address of packed member 'num_virtual_allocated_ranges' of class or structure 'kernel_args' may result in an unaligned
      pointer value [-Waddress-of-packed-member]
                &gKernelArgs.num_virtual_allocated_ranges, MAX_VIRTUAL_ALLOCATED_RANGE,
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.

clang warning us about these... could be an issue.

Change History (5)

comment:1 by korli, 6 years ago

Summary: haiku_loader / BIOS: Unaligned porinter from packed class or structurehaiku_loader / BIOS: Unaligned pointer from packed class or structure

comment:2 by pulkomandy, 5 years ago

Component: System/Boot LoaderSystem/Boot Loader/BIOS

comment:3 by miqlas, 4 years ago

Happens with GCC11.1 buildtools :

C++ objects/haiku/x86_64/release/system/boot/platform/bios_ia32/bios_ia32/long.o 
../src/system/boot/platform/bios_ia32/long.cpp: In function 'void long_mmu_init()':
../src/system/boot/platform/bios_ia32/long.cpp:95:45: error: taking address of packed member of 'arch_kernel_args' may result in an unaligned pointer value [-Werror=address-of-packed-member]
   95 |         pmlTop = (uint64*)mmu_allocate_page(&gKernelArgs.arch_args.phys_pgdir);
      |                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

comment:4 by X512, 3 years ago

Unaligned memory access is fine for x86.

comment:5 by korli, 3 years ago

Version 0, edited 3 years ago by korli (next)
Note: See TracTickets for help on using tickets.