NetBSD Problem Report #57223

From martin@aprisoft.de  Thu Feb  9 12:37:46 2023
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 7360A1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  9 Feb 2023 12:37:46 +0000 (UTC)
Message-Id: <20230209123737.3797D5CC7B9@emmas.aprisoft.de>
Date: Thu,  9 Feb 2023 13:37:37 +0100 (CET)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: new binutils break evbarm kernels
X-Send-Pr-Version: 3.95

>Number:         57223
>Category:       toolchain
>Synopsis:       new binutils break evbarm kernels
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 09 12:40:01 +0000 2023
>Closed-Date:    Sat Feb 11 19:28:49 +0000 2023
>Last-Modified:  Sat Feb 11 22:45:01 +0000 2023
>Originator:     Martin Husemann
>Release:        NetBSD 10.99.2
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD zero2.aprisoft.de 9.99.100 NetBSD 9.99.100 (GENERIC) #85: Thu Feb 9 13:12:37 CET 2023 martin@martins.aprisoft.de:/home/martin/wifi/sys/arch/evbarm/compile/GENERIC evbarm
Architecture: earmv7hfeb
Machine: evbarm
>Description:

After switching to new binutils, evbarm kernels do not boot any more.
New kernel output (with VERBOSE_INIT_ARM enabled):

## Booting kernel from Legacy Image at 42000000 ...
   Image Name:   NetBSD/earmv7hfeb 10.99.2
   Image Type:   ARM Linux Kernel Image (no loading done) (uncompressed)
   Data Size:    11751264 Bytes = 11.2 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 4f000000
   Booting using the fdt blob at 0x4f000000
   XIP Kernel Image (no loading done) ... OK
   Loading Device Tree to 49ff6000, end 49fffc64 ... OK

Starting kernel ...


pc    : 0x42000090
off   : 0xbdffffc0
sp    : 0x42c88040
panic: vtop not L1_FRAME aligned (0xbdffffc0)

The ELF header of the new kernel shows an entry point of 0:

ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          13768996 (bytes into file)
  Flags:                             0x5800200, Version5 EABI, soft-float ABI, BE8
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         33
  Section header string table index: 32


while the old kernel showed 0x80000040 (i.e. KERNEL_BASE_virt):

ELF Header:
  Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x80000040
  Start of program headers:          52 (bytes into file)
  Start of section headers:          12950476 (bytes into file)
  Flags:                             0x5800200, Version5 EABI, soft-float ABI, BE8
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         2
  Size of section headers:           40 (bytes)
  Number of section headers:         31
  Section header string table index: 30


(which I do not quite understand, as the generated ldscript has

 ENTRY(KERNEL_BASE_phys)

which might be undefined at this point and only later is set to 0x00000040
(but I don't understand the ldscript language really).


>How-To-Repeat:

Boot some evbarm* kernel in -current (or check the b5 test runs:
https://releng.netbsd.org/b5reports/evbarm-earmv7hf/ )

>Fix:
n/a

>Release-Note:

>Audit-Trail:
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/57223: new binutils break evbarm kernels
Date: Sat, 11 Feb 2023 16:51:42 -0000 (UTC)

 martin@NetBSD.org writes:

 >(which I do not quite understand, as the generated ldscript has

 > ENTRY(KERNEL_BASE_phys)


 The linker script has two SECTIONS that both define .start and .text.
 I'm not sure how that is supposed to work, the GNU ld manual doesn't
 tell about multiple statements for the same section.

 Swapping both SECTIONS seems to create a binary with the correct
 load addresses, same as merging both SECTIONS and this results in
 a kernel that boots.

From: Martin Husemann <martin@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: toolchain/57223: new binutils break evbarm kernels
Date: Sat, 11 Feb 2023 17:29:34 +0000

 Merging the declarations sounds correct.
 This also should be done for the scripts for cats, epoc32 and zarurus.

 Martin

From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57223 CVS commit: src/sys/arch/evbarm/conf
Date: Sat, 11 Feb 2023 19:09:57 +0000

 Module Name:	src
 Committed By:	mlelstv
 Date:		Sat Feb 11 19:09:57 UTC 2023

 Modified Files:
 	src/sys/arch/evbarm/conf: ldscript.evbarm

 Log Message:
 Merge both SECTIONS declarations into one.
 Fixes PR 57223.

 cats, epoc32 and zaurus need a similar fix.


 To generate a diff of this commit:
 cvs rdiff -u -r1.14 -r1.15 src/sys/arch/evbarm/conf/ldscript.evbarm

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sat, 11 Feb 2023 19:28:49 +0000
State-Changed-Why:
Confirmed fixed


From: "Michael van Elst" <mlelstv@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57223 CVS commit: src/sys/arch
Date: Sat, 11 Feb 2023 22:42:21 +0000

 Module Name:	src
 Committed By:	mlelstv
 Date:		Sat Feb 11 22:42:21 UTC 2023

 Modified Files:
 	src/sys/arch/cats/conf: ldscript.elf
 	src/sys/arch/epoc32/conf: ldscript.epoc32
 	src/sys/arch/zaurus/conf: ldscript.zaurus

 Log Message:
 Apply ldscript fixes for binutils-2.39. See PR 57223.


 To generate a diff of this commit:
 cvs rdiff -u -r1.6 -r1.7 src/sys/arch/cats/conf/ldscript.elf
 cvs rdiff -u -r1.7 -r1.8 src/sys/arch/epoc32/conf/ldscript.epoc32
 cvs rdiff -u -r1.12 -r1.13 src/sys/arch/zaurus/conf/ldscript.zaurus

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.