NetBSD Problem Report #51926

From www@NetBSD.org  Sun Jan 29 21:38:30 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E34977A280
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 29 Jan 2017 21:38:29 +0000 (UTC)
Message-Id: <20170129213828.B296D7A2A7@mollari.NetBSD.org>
Date: Sun, 29 Jan 2017 21:38:28 +0000 (UTC)
From: guillem@debian.org
Reply-To: guillem@debian.org
To: gnats-bugs@NetBSD.org
Subject: The alpha EM_ALPHA and EM_ALPHA_EXP machine type handling seems out-of-date
X-Send-Pr-Version: www-1.0

>Number:         51926
>Category:       port-alpha
>Synopsis:       The alpha EM_ALPHA and EM_ALPHA_EXP machine type handling seems out-of-date
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    thorpej
>State:          closed
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jan 29 21:40:00 +0000 2017
>Closed-Date:    Sat Oct 10 21:26:30 +0000 2020
>Last-Modified:  Sat Oct 10 21:30:01 +0000 2020
>Originator:     Guillem Jover
>Release:        HEAD
>Organization:
Debian
>Environment:
>Description:
While going over various ELF implementations I noticed that NetBSD considers EM_ALPHA (41), and EM_ALPHA_EXP (0x9026) in reverse to what pretty much every other implementation thinks is the old and the current ID. Those would include at least Linux, FreeBSD, OpenBSD, GNU binutils and LLVM.

The common usage indicates that 0x9026 is the current value for EM_ALPHA, and that 41 is considered the old one.

Even NetBSD considers it so in the code, but not in the macro names or the code comments.

Relevant are:

  <http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/exec_elf.h?rev=1.156&content-type=text/x-cvsweb-markup>
  <http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/alpha/include/elf_machdep.h?rev=1.12&content-type=text/x-cvsweb-markup>

where the code comments and the macro names do not match current conventions.
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-alpha/51926: The alpha EM_ALPHA and EM_ALPHA_EXP machine
 type handling seems out-of-date
Date: Tue, 31 Jan 2017 17:43:23 +0100

 I have slight trouble parsing your PR.
 NetBSD uses the "old" machine ID, mostly for historic reasons.

 This does not matter a lot, since both IDs are accepted when analyzing or
 executing binaries and AFAICT the only place where there is an actual 
 difference is when creating core dumps.

 So are you suggesting a concrete change? What comment do you think is wrong
 exactly?

 Martin

From: Guillem Jover <guillem@debian.org>
To: gnats-bugs@NetBSD.org
Cc: port-alpha-maintainer@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: port-alpha/51926: The alpha EM_ALPHA and EM_ALPHA_EXP machine
 type handling seems out-of-date
Date: Thu, 2 Feb 2017 04:40:49 +0100

 Hi!

 On Tue, 2017-01-31 at 16:45:00 +0000, Martin Husemann wrote:
 >  I have slight trouble parsing your PR.
 >  NetBSD uses the "old" machine ID, mostly for historic reasons.
 >  
 >  This does not matter a lot, since both IDs are accepted when analyzing or
 >  executing binaries and AFAICT the only place where there is an actual 
 >  difference is when creating core dumps.
 >  
 >  So are you suggesting a concrete change? What comment do you think is wrong
 >  exactly?

 Yes, sorry, I see the report can be confusing, so let me clarify. There
 is this now in sys/sys/exec_elf.h (and other elf.h across the codebase):

   #define EM_ALPHA	41	/* DIGITAL Alpha */
   #define EM_ALPHA_EXP	36902	/* used by NetBSD/alpha; obsolete */

 The machine iD 36902 (0x9026), is what pretty much everyone else is
 using as the current ID, but as this:

   #define EM_ALPHA	0x9026

 and the other one as:

   #define EM_OLD_ALPHA	41

 Also in sys/arch/alpha/include/elf_machdep.h ther is this:

   #define      ELF64_MACHDEP_ID        EM_ALPHA_EXP    /* XXX */

 So I think at last the code comments should be updated, first to
 remove the "obslete" notes all over the place, and to remove the XXX,
 because that's the right ID.

 And ideally the EM_ALPHA macros would be switched to what other
 implementations use EM_ALPHA (0x9026), EM_OLD_ALPHA (0x9026) or similar,
 along with all other relevant references to those in the codebase, to
 avoid further confusion?

 Thanks,
 Guillem

Responsible-Changed-From-To: port-alpha-maintainer->thorpej
Responsible-Changed-By: thorpej@NetBSD.org
Responsible-Changed-When: Sat, 10 Oct 2020 20:15:45 +0000
Responsible-Changed-Why:
Take.


State-Changed-From-To: open->closed
State-Changed-By: thorpej@NetBSD.org
State-Changed-When: Sat, 10 Oct 2020 21:26:30 +0000
State-Changed-Why:
Fixed, thanks!


From: "Jason R Thorpe" <thorpej@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51926 CVS commit: src/sys
Date: Sat, 10 Oct 2020 21:25:51 +0000

 Module Name:	src
 Committed By:	thorpej
 Date:		Sat Oct 10 21:25:51 UTC 2020

 Modified Files:
 	src/sys/arch/alpha/include: elf_machdep.h
 	src/sys/arch/atari/stand/tostools/libtos: exec_elf.h
 	src/sys/arch/epoc32/stand/e32boot/include: elf.h
 	src/sys/sys: exec_elf.h

 Log Message:
 Rename:
 - EM_ALPHA (41) -> EM_OLD_ALPHA
 - EM_ALPHA_EXP (36902) -> EM_ALPHA

 36902 has been the value in common usage for a long time, and this naming
 aligns with binutils, etc.

 PR port-alpha/51926


 To generate a diff of this commit:
 cvs rdiff -u -r1.14 -r1.15 src/sys/arch/alpha/include/elf_machdep.h
 cvs rdiff -u -r1.7 -r1.8 src/sys/arch/atari/stand/tostools/libtos/exec_elf.h
 cvs rdiff -u -r1.4 -r1.5 src/sys/arch/epoc32/stand/e32boot/include/elf.h
 cvs rdiff -u -r1.166 -r1.167 src/sys/sys/exec_elf.h

 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.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.