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: analyzed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Jul 29 19:45:00 +0000 2025
>Closed-Date:
>Last-Modified: Thu Dec 04 21:55:02 +0000 2025
>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.
>Unformatted:
(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-2025
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.