NetBSD Problem Report #59564

From kardel@kardel.name  Tue Jul 29 19:40:20 2025
Return-Path: <kardel@kardel.name>
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)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 73C061A923C
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 29 Jul 2025 19:40:20 +0000 (UTC)
Message-Id: <20250729194015.4EA13AAAC2F7@pip.kardel.name>
Date: Tue, 29 Jul 2025 21:40:15 +0200 (CEST)
From: kardel@netbsd.org
Reply-To: kardel@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: ELF source code compatibility regression
X-Send-Pr-Version: 3.95

>Number:         59564
>Notify-List:    kim
>Category:       lib
>Synopsis:       ELF source code compatibility regression
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jkoshy
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 29 19:45:00 +0000 2025
>Closed-Date:    Fri Feb 20 10:22:58 +0000 2026
>Last-Modified:  Fri Feb 20 10:22:58 +0000 2026
>Originator:     Frank Kardel
>Release:        NetBSD 10.99.15
>Organization:

>Environment:


System: NetBSD Build-0 10.99.15 NetBSD 10.99.15 (GENERIC) #1: Tue Jul 29 12:42:32 CEST 2025 kardel@gaia:/src/NetBSD/current/src/obj.amd64/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
	In 10.99.15 following ELF include sequence fails
#include <elf.h>
#include <libelf.h>
#include <gelf.h>

int main() { return 0; }

errors are:
n file included from /usr/include/elfdefinitions.h:34,
                 from /usr/include/libelf.h:40,
                 from test.c:2:
/usr/include/sys/elfdefinitions.h:2586:3: error: conflicting types for 'Elf32_Cap'; have 'struct <anonymous>'
 2586 | } Elf32_Cap;
      |   ^~~~~~~~~
In file included from test.c:1:
/usr/include/elf.h:743:3: note: previous declaration of 'Elf32_Cap' with type 'Elf32_Cap'
  743 | } Elf32_Cap;
      |   ^~~~~~~~~
/usr/include/sys/elfdefinitions.h:2595:3: error: conflicting types for 'Elf64_Cap'; have 'struct <anonymous>'
 2595 | } Elf64_Cap;
      |   ^~~~~~~~~
/usr/include/elf.h:751:3: note: previous declaration of 'Elf64_Cap' with type 'Elf64_Cap'
  751 | } Elf64_Cap;
      |   ^~~~~~~~~
/usr/include/sys/elfdefinitions.h:2622:3: error: conflicting types for 'Elf32_Dyn'; have 'struct <anonymous>'
 2622 | } Elf32_Dyn;
      |   ^~~~~~~~~
/usr/include/elf.h:762:3: note: previous declaration of 'Elf32_Dyn' with type 'Elf32_Dyn'
  762 | } Elf32_Dyn;
      |   ^~~~~~~~~
... many more

when removing #include <elf.h> the compilation succeeds.

On NetBSD 10.1_STABLE and versions before that including elf.h is not leading to errors.
This looks like a source code compatibility regression. The include sequence also works on other operating Sytems (Linux, Solaris, ...)

>How-To-Repeat:
	attempt to compile in 10.99.15:
#include <elf.h>
#include <libelf.h>
#include <gelf.h>

int main() { return 0; }

>Fix:
	revisit and fix elf includes

>Release-Note:

>Audit-Trail:

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/external/bsd/elftoolchain/dist/common/sys
Date: Wed, 30 Jul 2025 18:26:04 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Wed Jul 30 22:26:03 UTC 2025

 Modified Files:
 	src/external/bsd/elftoolchain/dist/common/sys: elfdefinitions.m4

 Log Message:
 PR/59564: Frank Kardel: Allow elfdefinitions.h and elf.h to co-exist.
 Unfortunately c does not allow structure redefinitions, even if the structures
 are identical. So include <sys/exec_elf.h> from <sys/elfdefinitions.h> and
 protect all the typedefs that exec_elf.h already provides with the guard
 of the sys/exec_elf.h file.
 Also fix the order of the cap union fields so that the sys/sys_exec.h and
 sys/elfdefinitions.h are identical.


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 \
     src/external/bsd/elftoolchain/dist/common/sys/elfdefinitions.m4

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

From: Kimmo Suominen <kim@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/59564 CVS commit: src/external/bsd/elftoolchain/dist/common/sys
Date: Thu, 31 Jul 2025 09:40:19 +0300

 ----- Forwarded message from Robert Elz <kre@netbsd.org> -----

 From: Robert Elz <kre@netbsd.org>
 To: source-changes@NetBSD.org
 Date: Thu, 31 Jul 2025 02:21:13 +0000
 Message-Id: <20250731022113.EF159FA40@cvs.NetBSD.org>
 Subject: CVS commit: src/external/bsd/elftoolchain/dist/common/sys
 Approved: for-source-only
 Reply-To: kre@netbsd.org

 Module Name:	src
 Committed By:	kre
 Date:		Thu Jul 31 02:21:13 UTC 2025

 Modified Files:
 	src/external/bsd/elftoolchain/dist/common/sys: elfdefinitions.m4

 Log Message:
 Revert this to rev 1.7 (reverse the previous 3 commits).

 This is a total mess - it simply cannot be done that way.


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 \
     src/external/bsd/elftoolchain/dist/common/sys/elfdefinitions.m4

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


 ----- End forwarded message -----

Responsible-Changed-From-To: lib-bug-people->jkoshy
Responsible-Changed-By: jkoshy@NetBSD.org
Responsible-Changed-When: Tue, 14 Oct 2025 16:15:23 +0000
Responsible-Changed-Why:


From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src
Date: Tue, 18 Nov 2025 13:02:13 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Tue Nov 18 13:02:13 UTC 2025

 Modified Files:
 	src/external/bsd/elftoolchain/dist/common/sys: elfdefinitions.m4
 	src/external/cddl/osnet/dist/lib/libdtrace/common: drti.c
 	src/sys/sys: exec_elf.h
 	src/tests/lib/libc/sys: t_ptrace_wait.c
 	src/usr.bin/kdump: Makefile.ioctl-c

 Log Message:
 Allow code to include either (or both) of <sys/elfdefinitions.h> and
 <sys/exec_elf.h>, in any order.

 This is a work-around to address PR lib/59564 (build breakage when
 both of these files are #included).

 With this changeset, whichever file gets included first 'wins'.
 Prior changes in NetBSD and upstream at Elftoolchain have aligned the
 'generic' ELF definitions in NetBSD's <sys/exec_elf.h> with those
 in Elftoolchain's <sys/elfdefinitions.h>, so that either file can
 be used interchangeably when building NetBSD.

 This changeset also removes prior workarounds in the source tree
 for this issue.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.14 \
     src/external/bsd/elftoolchain/dist/common/sys/elfdefinitions.m4
 cvs rdiff -u -r1.9 -r1.10 \
     src/external/cddl/osnet/dist/lib/libdtrace/common/drti.c
 cvs rdiff -u -r1.182 -r1.183 src/sys/sys/exec_elf.h
 cvs rdiff -u -r1.195 -r1.196 src/tests/lib/libc/sys/t_ptrace_wait.c
 cvs rdiff -u -r1.40 -r1.41 src/usr.bin/kdump/Makefile.ioctl-c

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

State-Changed-From-To: open->feedback
State-Changed-By: jkoshy@NetBSD.org
State-Changed-When: Tue, 18 Nov 2025 18:31:49 +0000
State-Changed-Why:
Should be addressed by commit XItXoYD3TNDeg2jG.


State-Changed-From-To: feedback->analyzed
State-Changed-By: jkoshy@NetBSD.org
State-Changed-When: Wed, 26 Nov 2025 22:13:43 +0000
State-Changed-Why:
I may have spoken too soon - I need to check the fix on all supported architectures.


From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/arm/include
Date: Fri, 28 Nov 2025 19:11:27 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Fri Nov 28 19:11:27 UTC 2025

 Modified Files:
 	src/sys/arch/arm/include: elf_machdep.h

 Log Message:
 arm/elf_machdep.h: Permit usage alongside <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/aarch64/include
Date: Fri, 28 Nov 2025 19:12:58 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Fri Nov 28 19:12:58 UTC 2025

 Modified Files:
 	src/sys/arch/aarch64/include: elf_machdep.h

 Log Message:
 aarch64/elf_machdep.h: Permit usage alongside <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/sys/arch/aarch64/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/amd64/include
Date: Sat, 29 Nov 2025 21:32:29 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Sat Nov 29 21:32:29 UTC 2025

 Modified Files:
 	src/sys/arch/amd64/include: elf_machdep.h

 Log Message:
 amd64/elf_machdep.h: Organize symbols into local and psABI groups.

 Permit this file to be used alongside <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.6 -r1.7 src/sys/arch/amd64/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/alpha/include
Date: Sat, 29 Nov 2025 22:03:17 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Sat Nov 29 22:03:17 UTC 2025

 Modified Files:
 	src/sys/arch/alpha/include: elf_machdep.h

 Log Message:
 alpha/elf_machdep.h: Organize symbols into local and ABI groups.

 Permit this file to be used alongside <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.17 src/sys/arch/alpha/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/powerpc/include
Date: Mon, 1 Dec 2025 16:39:57 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Mon Dec  1 16:39:57 UTC 2025

 Modified Files:
 	src/sys/arch/powerpc/include: elf_machdep.h

 Log Message:
 powerpc/elf_machdep.h: Use psABI spellings and group symbols into psABI/local groups.

 The prior spellings have been kept around for backward compatibility.

 Permit this file to be used alongside <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.16 -r1.17 src/sys/arch/powerpc/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/i386/include
Date: Mon, 1 Dec 2025 17:48:01 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Mon Dec  1 17:48:01 UTC 2025

 Modified Files:
 	src/sys/arch/i386/include: elf_machdep.h

 Log Message:
 i386/elf_machdep.h: Organise symbols into psABI and local groups.

 Permit this file to be used alongside <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/sh3/include
Date: Tue, 2 Dec 2025 22:50:16 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Tue Dec  2 22:50:16 UTC 2025

 Modified Files:
 	src/sys/arch/sh3/include: elf_machdep.h

 Log Message:
 sh3/elf_machdep.h: organize symbols into toolchain & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sh3/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/hppa/include
Date: Wed, 3 Dec 2025 21:17:46 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Wed Dec  3 21:17:46 UTC 2025

 Modified Files:
 	src/sys/arch/hppa/include: elf_machdep.h

 Log Message:
 hppa/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/vax/include
Date: Wed, 3 Dec 2025 21:36:15 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Wed Dec  3 21:36:14 UTC 2025

 Modified Files:
 	src/sys/arch/vax/include: elf_machdep.h

 Log Message:
 vax/elf_machdep.h: permit usage with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.6 -r1.7 src/sys/arch/vax/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/riscv/include
Date: Thu, 4 Dec 2025 21:51:10 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Thu Dec  4 21:51:10 UTC 2025

 Modified Files:
 	src/sys/arch/riscv/include: elf_machdep.h

 Log Message:
 riscv/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 src/sys/arch/riscv/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/mips/include
Date: Thu, 4 Dec 2025 21:53:01 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Thu Dec  4 21:53:01 UTC 2025

 Modified Files:
 	src/sys/arch/mips/include: elf_machdep.h

 Log Message:
 mips/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.21 -r1.22 src/sys/arch/mips/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/sparc64/include
Date: Fri, 5 Dec 2025 16:29:13 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Fri Dec  5 16:29:13 UTC 2025

 Modified Files:
 	src/sys/arch/sparc64/include: elf_machdep.h

 Log Message:
 sparc64/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc64/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/sparc/include
Date: Fri, 5 Dec 2025 16:30:22 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Fri Dec  5 16:30:22 UTC 2025

 Modified Files:
 	src/sys/arch/sparc/include: elf_machdep.h

 Log Message:
 sparc/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/ia64/include
Date: Fri, 5 Dec 2025 16:32:31 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Fri Dec  5 16:32:31 UTC 2025

 Modified Files:
 	src/sys/arch/ia64/include: elf_machdep.h

 Log Message:
 ia64/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.6 src/sys/arch/ia64/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/or1k/include
Date: Fri, 5 Dec 2025 20:56:46 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Fri Dec  5 20:56:46 UTC 2025

 Modified Files:
 	src/sys/arch/or1k/include: elf_machdep.h

 Log Message:
 or1k/elf_machdep.h: Group symbols into psABI and local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/sys/arch/or1k/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/arch/m68k/include
Date: Sat, 6 Dec 2025 12:19:13 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Sat Dec  6 12:19:13 UTC 2025

 Modified Files:
 	src/sys/arch/m68k/include: elf_machdep.h

 Log Message:
 m68k/elf_machdep.h: organize symbols into psABI & local groups.

 Allow this file to be used with <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.9 -r1.10 src/sys/arch/m68k/include/elf_machdep.h

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

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/sys
Date: Tue, 9 Dec 2025 12:11:49 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Tue Dec  9 12:11:49 UTC 2025

 Modified Files:
 	src/sys/sys: exec_elf.h

 Log Message:
 sys/exec_elf.h: Apply local fixups for <sys/elfdefinitions.h>.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.183 -r1.184 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.

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src/sys/sys
Date: Wed, 10 Dec 2025 14:30:33 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Wed Dec 10 14:30:33 UTC 2025

 Modified Files:
 	src/sys/sys: exec_elf.h

 Log Message:
 sys/exec_elf.h: Move local definitions to the NetBSD-local section.

 While here, document these local definitions.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.185 -r1.186 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.

From: "Joseph Koshy" <jkoshy@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59564 CVS commit: src
Date: Thu, 11 Dec 2025 21:03:29 +0000

 Module Name:	src
 Committed By:	jkoshy
 Date:		Thu Dec 11 21:03:29 UTC 2025

 Modified Files:
 	src/include: Makefile
 	src/sys/sys: Makefile
 Added Files:
 	src/include: elf.h

 Log Message:
 Implement an up to date and cross-platform <elf.h> for userland use.

 With this change:

 - Elftoolchain's <sys/elfdefinitions.h> is used for the definitions
   that make up the ELF gABI and its processor-specific ABI
   supplements.

 - Existing NetBSD-local definitions are brought in via
   the kernel header <sys/exec_elf.h>, for continuity.

 This changeset prepares the ground for migrating userland-only
 definitions out of the kernel header, for better separation
 of concerns.

 This changeset also eases the development of cross-architecture
 ELF tools since <elf.h> now offers ELF-related constants for all
 of the architectures that NetBSD currently supports.

 PR lib/59564


 To generate a diff of this commit:
 cvs rdiff -u -r1.150 -r1.151 src/include/Makefile
 cvs rdiff -u -r0 -r1.1 src/include/elf.h
 cvs rdiff -u -r1.185 -r1.186 src/sys/sys/Makefile

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

From: "David H. Gutteridge" <david@gutteridge.ca>
To: Gnats Bugs <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: lib/59564: ELF source code compatibility regression
Date: Mon, 15 Dec 2025 09:49:01 -0500

 These changes seem to have broken builds of some software. With HEAD
 sources as of yesterday, for example, pkgsrc's www/firefox140 breaks:

 gmake[3]: Entering directory 
 '/tmp/pkgsrc_work/www/firefox140/work/build/third_party/abseil-cpp/absl/debugging/debugging_internal_gn'
 /tmp/pkgsrc_work/www/firefox140/work/.cwrapper/bin/c++ -o 
 Unified_cpp_ebugging_internal_gn0.o -c  
 -I/tmp/pkgsrc_work/www/firefox140/work/build/dist/stl_wrappers 
 -I/tmp/pkgsrc_work/www/firefox140/work/build/dist/system_wrappers 
 -include 
 /tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/config/gcc_hidden.h 
 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong 
 -fstrict-flex-arrays=1 -DNDEBUG -DTRIMMED=1 -DABSL_ALLOCATOR_NOTHROW=1 
 -DDYNAMIC_ANNOTATIONS_ENABLED=0 -DNVALGRIND -DUSE_AURA=1 -DUSE_GLIB=1 
 -DUSE_NSS_CERTS=1 -DUSE_OZONE=1 -DUSE_UDEV -D_FILE_OFFSET_BITS=64 
 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DUSE_X11=1 -D_GNU_SOURCE 
 -DMOZ_HAS_MOZGLUE -DMOZILLA_INTERNAL_API -DIMPL_LIBXUL 
 -DMOZ_SUPPORT_LEAKCHECKING -DSTATIC_EXPORTABLE_JS_API 
 -I/tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/third_party/abseil-cpp/absl/debugging/debugging_internal_gn 
 -I/tmp/pkgsrc_work/www/firefox140/work/build/third_party/abseil-cpp/absl/debugging/debugging_internal_gn 
 -I/tmp/pkgsrc_work/www/firefox140/work/build/ipcgmake[3]: Entering 
 directory 
 '/tmp/pkgsrc_work/www/firefox140/work/build/third_party/abseil-cpp/absl/debugging/failure_signal_handler_gn'
 /ipdl/_ipdlheaders 
 -I/tmp/pkgsrc_work/www/firefox140/work/build/third_party/abseil-cpp/gen 
 -I/tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/ipc/chromium/src 
 -I/tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/third_party/abseil-cpp 
 -I/tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/tools/profiler/public 
 -I/tmp/pkgsrc_work/www/firefox140/work/build/dist/include 
 -DMOZILLA_CLIENT -include 
 /tmp/pkgsrc_work/www/firefox140/work/build/mozilla-config.h 
 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/nspr 
 -I/usr/X11R7/include -I/usr/X11R7/include/libdrm 
 -I/usr/pkg/include/libxml2 -I/usr/pkg/include/glib-2.0 
 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include 
 -I/usr/pkg/include/ffmpeg7 -I/usr/pkg/include/freetype2 
 -I/usr/pkg/include/harfbuzz -fno-rtti -pthread -fno-sized-deallocation 
 -fno-aligned-new -ffunction-sections -fdata-sections -fno-math-errno 
 -fno-exceptions -pipe -fPIC -O2 -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS -msse2 
 -D__LOCALE_C_ONLY -I/usr/pkg/include -I/usr/include 
 -I/usr/pkg/include/nspr -I/usr/X11R7/include -I/usr/X11R7/include/libdrm 
 -I/usr/pkg/include/libxml2 -I/usr/pkg/include/glib-2.0 
 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include 
 -I/usr/pkg/include/ffmpeg7 -I/usr/pkg/include/freetype2 
 -I/usr/pkg/include/harfbuzz -O2 -fomit-frame-pointer -funwind-tables 
 -Wall -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wsign-compare 
 -Wtype-limits -Wunreachable-code -Wno-invalid-offsetof -Wcomma-subscript 
 -Wvolatile -Wno-deprecated-enum-enum-conversion -Wduplicated-cond 
 -Wimplicit-fallthrough -Wlogical-op -Wno-error=maybe-uninitialized 
 -Wno-error=deprecated-declarations -Wno-error=array-bounds 
 -Wno-error=free-nonheap-object -Wno-multistatement-macros 
 -Wno-error=class-memaccess -Wformat -Wformat-overflow=2 -Wno-psabi 
 -Wno-error=builtin-macro-redefined -fno-strict-aliasing 
 -ffp-contract=off  -MD -MP -MF 
 .deps/Unified_cpp_ebugging_internal_gn0.o.pp   
 Unified_cpp_ebugging_internal_gn0.cpp
 In file included from Unified_cpp_ebugging_internal_gn0.cpp:11:
 /tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc: 
 In member function 'void 
 absl::debugging_internal::ElfMemImage::SymbolIterator::Update(uint32_t)':
 /tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc:385:45: 
 error: request for member 'vs_vers' in '* version_symbol', which is of 
 non-class type 'const Elf64_Versym' {aka 'const short unsigned int'}
    385 |   const int version_index = version_symbol->vs_vers & 
 VERSYM_VERSION;
        |                                             ^~~~~~~

 I haven't bisected/analyzed/anything else, just noting this here.

 Dave

From: "Joseph Koshy" <netbsd@jkoshy.net>
To: gnats-bugs@netbsd.org, "Joseph Koshy" <jkoshy@netbsd.org>,
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, kardel@netbsd.org
Cc: "Kimmo Suominen" <kim@netbsd.org>
Subject: Re: lib/59564: ELF source code compatibility regression
Date: Mon, 15 Dec 2025 16:57:10 +0000

 On 2025-12-15 14:50 David H. Gutteridge via gnats <gnats-admin@netbsd.org> wrote:

 > /tmp/pkgsrc_work/www/firefox140/work/firefox-140.6.0/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc:385:45: 
 >  error: request for member 'vs_vers' in '* version_symbol', which is of 
 >  non-class type 'const Elf64_Versym' {aka 'const short unsigned int'}
 >     385 |   const int version_index = version_symbol->vs_vers & 
 >  VERSYM_VERSION;
 >         |                                             ^~~~~~~
 > 
 >  I haven't bisected/analyzed/anything else, just noting this here.

 Apologies for the breakage.

 The definition of Elf{32,64}_Versym was changed in -CURRENT ([1])
 to align its definition with other ELF toolkits (and with the
 file format).

 There are two compile-time guards that could be used to compile
 around this change:

  a) a bump of __NetBSD_version__ ([2]),
  b) increment to an inclusion guard ([3]).

  [1]: https://freshbsd.org/netbsd/src/commit/tQg9ppOQUqMIebiG
  [2]: https://freshbsd.org/netbsd/src/commit/oRTT2fQq7NfhgjiG
  [3]: https://freshbsd.org/netbsd/src/commit/q8SBQRaMqO28zPiG

 --
 Joseph Koshy | jkoshy@NetBSD.org

From: Thomas Klausner <wiz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: lib/59564: ELF source code compatibility regression
Date: Mon, 15 Dec 2025 21:56:22 +0100

 On Mon, Dec 15, 2025 at 02:50:02PM +0100, David H. Gutteridge via gnats wrote:
 >  These changes seem to have broken builds of some software. With HEAD
 >  sources as of yesterday, for example, pkgsrc's www/firefox140 breaks:

 I don't know if the latest change has broken something else, but we
 have a couple copies of integrated abseil copies in pkgsrc that we
 have fixed with versions of
 devel/abseil/patches/patch-absl_debugging_internal_elf__mem__image.cc
 - perhaps firefox140 needs that too?
  Thomas

From: "David H. Gutteridge" <david@gutteridge.ca>
To: gnats-bugs@netbsd.org, wiz@netbsd.org
Cc: 
Subject: Re: lib/59564: ELF source code compatibility regression
Date: Mon, 15 Dec 2025 16:32:58 -0500

 On Mon, 15 Dec 2025 at 21:00:02 +0000, Thomas Klausner wrote:
 > I don't know if the latest change has broken something else, but we
 >  have a couple copies of integrated abseil copies in pkgsrc that we
 >  have fixed with versions of
 >  devel/abseil/patches/patch-absl_debugging_internal_elf__mem__image.cc
 >  - perhaps firefox140 needs that too?
 >   Thomas

 Yes, I discovered that, too, and have fixed firefox140 now as well.

 Thanks,

 Dave

State-Changed-From-To: analyzed->feedback
State-Changed-By: jkoshy@NetBSD.org
State-Changed-When: Tue, 30 Dec 2025 21:54:55 +0000
State-Changed-Why:
Awaiting further feedback.


State-Changed-From-To: feedback->closed
State-Changed-By: jkoshy@NetBSD.org
State-Changed-When: Fri, 20 Feb 2026 10:22:58 +0000
State-Changed-Why:
Closing after TIME_WAIT.


>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-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.