Re: 32-bit powerpc kernel builds (head -r356187): old ld (works) vs. devel/binutils@powerpc based (fails to boot): DYNAMIC vs. EXEC_P (powerpc64 lld too)

Mark Millard via freebsd-toolchain <[email protected]>
Newsgroups gmane.os.freebsd.devel.toolchain,gmane.os.freebsd.devel.ppc
Message-ID <[email protected]>

On 2019-Dec-31, at 16:44, Mark Millard <marklmi at yahoo.com> wrote:

> On 2019-Dec-31, at 14:52, Mark Millard <marklmi at yahoo.com> wrote:
> 
>> My attempt to buildkernel via devel/binutils@powerpc
>> produces a kernel that gets a very early crash.
>> 
>> Looking at the normal and alternate kernels a little
>> shows. . .
>> 
>> 
>> 
>> Old ld (and such):
>> 
>> /boot/kernel/kernel:     file format elf32-powerpc-freebsd
>> /boot/kernel/kernel
>> architecture: powerpc:common, flags 0x00000150:
>> HAS_SYMS, DYNAMIC, D_PAGED
>> start address 0x001001e0
>> . . .
>> 00e7a034 l     O *ABS*  00000000 .hidden _DYNAMIC
>> 
>> Produced via (from kernel.full.meta):
>> 
>> CMD @ld -m elf32ppc_fbsd -Bdynamic -T /usr/src/sys/conf/ldscript.powerpc --secure-plt -pie  --no-warn-mismatch --warn-common --export-dynamic  --dynamic-linker /red/herring -X -o kernel.full locore.o . . .
>> 
>> 
>> devel/binutils@powerpc based:
>> 
>> /boot/kerbad/kernel:     file format elf32-powerpc-freebsd
>> /boot/kerbad/kernel
>> architecture: powerpc:common, flags 0x00000112:
>> EXEC_P, HAS_SYMS, D_PAGED
>> start address 0x00100200
>> 
>> 00e7a034 l     O .dynamic       00000000 _DYNAMIC
>> 
>> Produced via (from kernel.full.meta):
>> 
>> CMD @/usr/local/powerpc-unknown-freebsd13.0/bin/ld -m elf32ppc_fbsd -Bdynamic -T /usr/src/sys/conf/ldscript.powerpc --secure-plt --build-id=sha1 -pie  --no-warn-mismatch --warn-common --export-dynamic
>> --dynamic-linker /red/herring -X -o kernel.full locore.o . . .
> 

I see the same sort of thing for powerpc64
kernels, based on system lld and such vs. based
on devel/binutils@powerpc64 .

(The old 2 socket/2-cores-per PowerMac is
rebuilding the 435 ports on head -r356187 .)

> _GLOBAL_OFFSET_TABLE_ has a similar status.
> 
> In fact, there is a big difference in the two
> context's ABS lists:  devel/binutils@powerpc
> produces a very short list:
> 
> # readelf -a /boot/kerbad/kernel | grep "\<ABS\>" | more
>     2: 0000000000000070     0 NOTYPE  GLOBAL DEFAULT  ABS dlmisssize
>   569: 0000000000100100     0 NOTYPE  GLOBAL DEFAULT  ABS kernbase
>  5103: 0000000000000020     0 NOTYPE  GLOBAL DEFAULT  ABS testppc64size
>  8156: 0000000000000018     0 NOTYPE  GLOBAL DEFAULT  ABS restorebridgesize
>  9078: 00000000000000b0     0 NOTYPE  GLOBAL DEFAULT  ABS imisssize
> 12351: 00000000000000f0     0 NOTYPE  GLOBAL DEFAULT  ABS dsmisssize
> 25923: 0000000000000070     0 NOTYPE  GLOBAL DEFAULT  ABS dlmisssize
> 26490: 0000000000100100     0 NOTYPE  GLOBAL DEFAULT  ABS kernbase
> 31024: 0000000000000020     0 NOTYPE  GLOBAL DEFAULT  ABS testppc64size
> 34077: 0000000000000018     0 NOTYPE  GLOBAL DEFAULT  ABS restorebridgesize
> 34999: 00000000000000b0     0 NOTYPE  GLOBAL DEFAULT  ABS imisssize
> 38272: 00000000000000f0     0 NOTYPE  GLOBAL DEFAULT  ABS dsmisssize
> 
> but the old ld produces a much longer list:
> 
> # readelf -a /boot/kernel/kernel | grep "\<ABS\>" | more
>     2: 0000000000000070     0 NOTYPE  GLOBAL DEFAULT  ABS dlmisssize
>   212: 0000000000e793dc     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_gfb_set
>   462: 0000000000e793c8     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_mmu_set
>   569: 0000000000100100     0 NOTYPE  GLOBAL DEFAULT  ABS kernbase
>  1334: 0000000000dd5728     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_sdt_probes_set
>  1395: 0000000000e5e608     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_vnet
>  1765: 0000000001183648     0 NOTYPE  GLOBAL DEFAULT  ABS end
>  1798: 0000000000dd36d0     0 NOTYPE  GLOBAL DEFAULT  ABS __stop_set_sysinit_set
>  1857: 0000000000dd4e34     0 NOTYPE  GLOBAL DEFAULT  ABS __stop_set_modmetadata_set
. . . (detail dropped) . . .
> 35963: 0000000000dd5674     0 NOTYPE  GLOBAL DEFAULT  ABS __stop_set_kbddriver_set
> 35987: 0000000000dd5728     0 NOTYPE  GLOBAL DEFAULT  ABS __stop_set_sdt_providers_set
> 36015: 0000000001183648     0 NOTYPE  GLOBAL DEFAULT  ABS _end
> 36625: 0000000000e793d4     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_videodriver_set
> 36828: 0000000000dd7954     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_scterm_set
> 37429: 0000000000e9786c     0 NOTYPE  GLOBAL DEFAULT  ABS _edata
> 37854: 0000000000dd7988     0 NOTYPE  GLOBAL DEFAULT  ABS __start_set_vt_drv_set
> 38049: 0000000000dc2240     0 NOTYPE  GLOBAL DEFAULT  ABS __stop_set_sysctl_set
> 38270: 00000000000000f0     0 NOTYPE  GLOBAL DEFAULT  ABS dsmisssize
> 
> So what do the __start_set_* and __stop_set_* symbols
> show up as in /boot/kerbad/kernel generally? PROTECTED
> visibility as a GLOBAL as it turns out:
> 
> # readelf -a /boot/kerbad/kernel | egrep "__(start|stop)_set_" | more
> 00e83680 002c0701 R_PPC_ADDR32        00000000 __stop_set_uart_fdt_class_set + 0
> 00e83684 0021a801 R_PPC_ADDR32        00000000 __start_set_uart_fdt_class_set + 0
>   212: 0000000000e793dc     0 NOTYPE  GLOBAL PROTECTED  48 __start_set_gfb_set
>   462: 0000000000e793c8     0 NOTYPE  GLOBAL PROTECTED  45 __start_set_mmu_set
. . . (detail dropped) . . .
> 35681: 0000000000dd565c     0 NOTYPE  GLOBAL PROTECTED  29 __start_set_kdb_dbbe_set
> 35695: 0000000000dd5668     0 NOTYPE  GLOBAL PROTECTED  30 __start_set_kbddriver_set
> 35965: 0000000000dd5674     0 NOTYPE  GLOBAL PROTECTED  30 __stop_set_kbddriver_set
> 35989: 0000000000dd5728     0 NOTYPE  GLOBAL PROTECTED  33 __stop_set_sdt_providers_set
> 36627: 0000000000e793d4     0 NOTYPE  GLOBAL PROTECTED  46 __start_set_videodriver_set
> 36830: 0000000000dd7954     0 NOTYPE  GLOBAL PROTECTED  36 __start_set_scterm_set
> 37192: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __stop_set_uart_fdt_class_set
> 37856: 0000000000dd7988     0 NOTYPE  GLOBAL PROTECTED  40 __start_set_vt_drv_set
> 38051: 0000000000dd2468     0 NOTYPE  GLOBAL PROTECTED  22 __stop_set_sysctl_set
> 
> 
> 
> (Note: the "bad" in "/boot/kerbad/" is just a
> reference to the boot failure, a relationship
> of the link results and code handling the loaded
> kernel code. Which style of linker output for the
> kernel is "more correct" for the linker options
> supplied is not part of my claims. I am noting
> the mismatches, however.)
> 



===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.