NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/59564: ELF source code compatibility regression



>Number:         59564
>Category:       lib
>Synopsis:       ELF source code compatibility regression
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 29 19:45:00 +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

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index