[Bug 279137] FreeBSD fails to boot on IBM POWER8 systems (S814, S822L, S824)

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 20 May 2024 14:12:02 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279137

--- Comment #3 from Calvin Buckley <calvin@cmpct.info> ---
I have a suspicion it might be a problem with how the executable is built -
perhaps an issue with the linker script. I'm trying to figure out what might be
a problem, but some things I have noticed:

* The stack trace is well below the load address for the loader in addition to
triggering during load instead of boot, so this is why I think it's an issue
when loading the executable.
* grub and ye old yaboot have SysV branding, FreeBSD loader has FreeBSD
branding, AIX bootfile.exe has Monterey branding (lmao)
* The load address is kinda funny, not really a nice round number. Then again,
the AIX one is also a different weird number, and AIX boots fine on these
machines.
* Perhaps it's something with the sections. GRUB has very few, and AIX has none
(which is pretty weird - it's also ~32 MB...). Then again, yaboot presumably
had to boot on IBM systems and it has a ton of sections.

If it helps, LLVM objdump output on the FreeBSD 14.0 loader:

```
% objdump -x PPC_CHRP_LOADER 

PPC_CHRP_LOADER:        file format elf32-powerpc
architecture: powerpc
start address: 0x02c007ec

Program Header:
    LOAD off    0x00000060 vaddr 0x02c00060 paddr 0x02c00060 align 2**16
         filesz 0x0005c3c8 memsz 0x0085da9c flags rwx

Dynamic Section:

Sections:
Idx Name             Size     VMA      Type
  0                  00000000 00000000 
  1 .text            0004b7d0 02c00060 TEXT
  2 .rodata          000035b8 02c4b830 DATA
  3 .rodata.str1.1   000063c7 02c4ede8 DATA
  4 set_Xcommand_set 0000006c 02c551b0 DATA
  5 .eh_frame_hdr    0000001c 02c5521c DATA
  6 .eh_frame        00000040 02c55238 DATA
  7 .data.rel.ro     00000678 02c56000 DATA
  8 .data            00005da8 02c56680 DATA
  9 .bss             008016d4 02c5c428 BSS
 10 .comment         000000ac 00000000 
 11 .shstrtab        00000073 00000000 

SYMBOL TABLE:
```

On GRUB (this works):

```
% objdump -x core.elf       

core.elf:       file format elf32-powerpc
architecture: powerpc
start address: 0x00200000

Program Header:
    LOAD off    0x00000140 vaddr 0x00200000 paddr 0x00200000 align 2**4
         filesz 0x00011622 memsz 0x00018d9c flags rwx
   STACK off    0x00011762 vaddr 0x00000000 paddr 0x00000000 align 2**2
         filesz 0x00000000 memsz 0x00000000 flags rwx
    LOAD off    0x00011762 vaddr 0x00221000 paddr 0x00221000 align 2**2
         filesz 0x00084b18 memsz 0x00084b18 flags rwx

Dynamic Section:

Sections:
Idx Name          Size     VMA      Type
  0               00000000 00000000 
  1               0000000c 00000000 
  2 .text         00011622 00200000 
  3 mods          00084b18 00211622 

SYMBOL TABLE:
```

AIX (this works):

```
% objdump -x bootfile.exe 

bootfile.exe:   file format elf32-powerpc
architecture: powerpc
start address: 0x00006134

Program Header:
    NOTE off    0x000000d4 vaddr 0xffffffff paddr 0xffffffff align 2**64
         filesz 0x0000002c memsz 0x00000000 flags ---
    NOTE off    0x00000100 vaddr 0xffffffff paddr 0xffffffff align 2**64
         filesz 0x0000004c memsz 0x00000000 flags ---
    LOAD off    0x0000014c vaddr 0x0000414c paddr 0x0000414c align 2**12
         filesz 0x00000e98 memsz 0x00000e98 flags ---
    NOTE off    0x00000fe4 vaddr 0x00004fe4 paddr 0x00004fe4 align 2**12
         filesz 0x0000101c memsz 0x0000101c flags ---
    LOAD off    0x00002000 vaddr 0x00006000 paddr 0x00006000 align 2**12
         filesz 0x01f00000 memsz 0x01f00000 flags ---

Dynamic Section:

Sections:
Idx Name          Size     VMA      Type

SYMBOL TABLE:
```

yaboot (have not tested because it predates POWER8, but may be useful for
historical reference):

```
% objdump -x yaboot/usr/lib/yaboot/yaboot 

yaboot/usr/lib/yaboot/yaboot:   file format elf32-powerpc
architecture: powerpc
start address: 0x00200000

Program Header:
    LOAD off    0x00010000 vaddr 0x00200000 paddr 0x00200000 align 2**16
         filesz 0x0001d7c8 memsz 0x0001d7c8 flags r-x
    LOAD off    0x0002e000 vaddr 0x0022e000 paddr 0x0022e000 align 2**16
         filesz 0x0000043c memsz 0x00014a94 flags rw-
   STACK off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**2
         filesz 0x00000000 memsz 0x00000000 flags rwx

Dynamic Section:

Sections:
Idx Name            Size     VMA      Type
  0                 00000000 00000000 
  1 .text           0001b740 00200000 TEXT
  2 .rodata         00002004 0021b740 DATA
  3 .eh_frame       00000084 0021d744 DATA
  4 .data           0000042c 0022e000 DATA
  5 .sdata          00000010 0022e42c DATA
  6 .sbss           00000030 0022e440 BSS
  7 .bss            00014624 0022e470 BSS
  8 .gnu.attributes 00000014 00000000 
  9 .shstrtab       0000004b 00000000 

SYMBOL TABLE:
```

-- 
You are receiving this mail because:
You are the assignee for the bug.