On Wed, 5 Jul 2017 12:11:32 +0200
Martin Pieuchot <[email protected]> wrote:

> Exporting <sys/types.h> hurts, I don't think that Solaris includes it.
> With it programs will compile on OpenBSD with <elf.h> but might require
> <sys/types.h> on other OSes.

fortunately OpenBSD base neither requires sys/types.h.

> > > What would it take to convert base programs to <elf.h>?
> > 
> > Base is quite clean except few exceptions. I used ELF_OPENBSD_EXTENSION for 
> > those. Anyway, both toolchains (bintils+gcc/llvm+clang) seem to live their 
> > own ELF lifes without even attempting to include system elf.h/elf_abi.h so 
> > they are clean and not touched.
> 
> So we should maybe just replace <elf_abi.h> by <elf.h>, and change
> programs including <sys/exec_elf.h> to include <elf.h>.  That implies
> updating elf(5).

Programs in base include elf_abi.h. I changed that to elf.h. elf(5) may be done 
once real work is done on sys/exec_elf.h

> > > If base starts to provide <elf.h> you also need to make sure it doesn't
> > > break any port.
> > 
> > Both elf.h/elf_abi.h so far points to the exactly same definitions, hence 
> > if there is port which is broken, then it'll be broken at compile time. 
> > Quite easily discoverable by building all ports. Not yet done on my side 
> > though.
> 
> That would be a nice thing to do or ask something to do it for you once you
> have a final diff.

The problem is that with your recommendation to remove elf_abi.h, now I'm 
afraid quite some ports may fail. At least I know about GHC which includes 
elf_abi.h and which was the motivation for this thread. The question is if not 
to keep it for some time with for example #warning "include 'elf.h' instead of 
'elf_abi.h'" or so and even later with #error? The point is to make transition 
more smooth and perhaps spread over release or two? I'm certainly not in 
possition to fix any port includes of elf_abi.h unfortunately...

Patch against current included. Sorry for git format of rename...

Thanks,
Karel

diff --git a/distrib/sets/lists/comp/mi b/distrib/sets/lists/comp/mi
index 3777a4cb179..e7cec7f19cc 100644
--- a/distrib/sets/lists/comp/mi
+++ b/distrib/sets/lists/comp/mi
@@ -822,7 +822,7 @@
 ./usr/include/dirent.h
 ./usr/include/disktab.h
 ./usr/include/dlfcn.h
-./usr/include/elf_abi.h
+./usr/include/elf.h
 ./usr/include/endian.h
 ./usr/include/err.h
 ./usr/include/errno.h
diff --git a/games/hangman/ksyms.c b/games/hangman/ksyms.c
index 18ce231fd22..047b867caca 100644
--- a/games/hangman/ksyms.c
+++ b/games/hangman/ksyms.c
@@ -18,7 +18,7 @@
 
 #include <ctype.h>
 #include <curses.h>
-#include <elf_abi.h>
+#include <elf.h>
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/include/Makefile b/include/Makefile
index 1d7f894b595..f5a0b3bbf3a 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -11,7 +11,7 @@
 
 FILES= a.out.h ar.h asr.h assert.h bitstring.h blf.h bsd_auth.h \
        complex.h cpio.h ctype.h curses.h db.h dirent.h disktab.h \
-       dlfcn.h elf_abi.h err.h errno.h fenv.h float.h fnmatch.h fstab.h fts.h \
+       dlfcn.h elf.h err.h errno.h fenv.h float.h fnmatch.h fstab.h fts.h \
        ftw.h getopt.h glob.h grp.h icdb.h ieeefp.h ifaddrs.h inttypes.h \
        iso646.h kvm.h langinfo.h libgen.h limits.h link.h link_elf.h \
        locale.h login_cap.h math.h md5.h memory.h ndbm.h netdb.h netgroup.h \
diff --git a/include/elf_abi.h b/include/elf.h
similarity index 91%
rename from include/elf_abi.h
rename to include/elf.h
index 489869b1654..c1bc247cc3c 100644
--- a/include/elf_abi.h
+++ b/include/elf.h
@@ -1,4 +1,4 @@
-/*     $OpenBSD: elf_abi.h,v 1.4 1996/05/22 07:46:22 etheisen Exp $    */
+/*     $OpenBSD: elf.h,v 1.4 1996/05/22 07:46:22 etheisen Exp $        */
 /*
  * Copyright (c) 1996 Erik Theisen
  * All rights reserved.
@@ -25,9 +25,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#ifndef _ELF_ABI_H_
-#define _ELF_ABI_H_
+#ifndef _ELF_H_
+#define _ELF_H_
 
 #include <sys/exec_elf.h>
 
-#endif /* _ELF_ABI_H_ */
+#endif /* _ELF_H_ */
diff --git a/include/link_elf.h b/include/link_elf.h
index 45fc1b9e0b9..137e64744aa 100644
--- a/include/link_elf.h
+++ b/include/link_elf.h
@@ -7,7 +7,7 @@
 #ifndef _LINK_ELF_H
 #define _LINK_ELF_H
 
-#include <elf_abi.h>
+#include <elf.h>
 
 #ifndef DT_PROCNUM
 #define DT_PROCNUM 0
diff --git a/lib/libc/gen/elf_hash.c b/lib/libc/gen/elf_hash.c
index 5fdc2815457..5c98f401395 100644
--- a/lib/libc/gen/elf_hash.c
+++ b/lib/libc/gen/elf_hash.c
@@ -37,7 +37,7 @@
 #include <unistd.h>
 #include <sys/exec.h>
 
-#include <elf_abi.h>
+#include <elf.h>
 
 /*
  * Standard ELF ABI hash function.
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index f4dae6eb32c..9a5b497b91e 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -40,7 +40,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <a.out.h>             /* pulls in nlist.h */
-#include <elf_abi.h>
+#include <elf.h>
 
 #define MINIMUM(a, b)  (((a) < (b)) ? (a) : (b))
 
diff --git a/libexec/ld.so/amd64/archdep.h b/libexec/ld.so/amd64/archdep.h
index 0b1f8e3fd05..a025b5c46a3 100644
--- a/libexec/ld.so/amd64/archdep.h
+++ b/libexec/ld.so/amd64/archdep.h
@@ -33,7 +33,7 @@
 
 #define        MACHID  EM_AMD64        /* ELF e_machine ID value checked */
 
-#include <elf_abi.h>
+#include <elf.h>
 #include <machine/reloc.h>
 #include "syscall.h"
 #include "util.h"
diff --git a/libexec/ld.so/ldd/ldd.c b/libexec/ld.so/ldd/ldd.c
index 5ebbe62cce3..e8aa5f2572a 100644
--- a/libexec/ld.so/ldd/ldd.c
+++ b/libexec/ld.so/ldd/ldd.c
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <elf_abi.h>
+#include <elf.h>
 #include <err.h>
 #include <fcntl.h>
 #include <string.h>
diff --git a/sys/ddb/db_dwarf.c b/sys/ddb/db_dwarf.c
index 5956d602664..f10900ce037 100644
--- a/sys/ddb/db_dwarf.c
+++ b/sys/ddb/db_dwarf.c
@@ -397,7 +397,7 @@ next:
 #include <sys/endian.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
-#include <elf_abi.h>
+#include <elf.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/sys/sys/exec_elf.h b/sys/sys/exec_elf.h
index 77c13a0372c..8a1c8e0e85e 100644
--- a/sys/sys/exec_elf.h
+++ b/sys/sys/exec_elf.h
@@ -33,7 +33,6 @@
 #ifndef _SYS_EXEC_ELF_H_
 #define _SYS_EXEC_ELF_H_
 
-#include <sys/types.h>
 #include <machine/exec.h>
 
 typedef __uint8_t      Elf_Byte;
@@ -177,16 +176,12 @@ typedef struct {
 #define EM_486         6               /* Intel 80486 - unused? */
 #define EM_860         7               /* Intel 80860 */
 #define EM_MIPS                8               /* MIPS R3000 Big-Endian only */
-/*
- * Don't know if EM_MIPS_RS4_BE,
- * EM_SPARC64, EM_PARISC,
- * or EM_PPC are ABI compliant
- */
-#define EM_MIPS_RS4_BE 10              /* MIPS R4000 Big-Endian */
-#define EM_SPARC64     11              /* SPARC v9 64-bit unofficial */
+#define EM_MIPS_RS3_LE 10              /* MIPS R3000 Little-Endian */
+       /* 11 - 14 reserved for future use */
 #define EM_PARISC      15              /* HPPA */
 #define EM_SPARC32PLUS 18              /* Enhanced instruction set SPARC */
 #define EM_PPC         20              /* PowerPC */
+#define EM_PPC64       21              /* PowerPC 64 */
 #define EM_ARM         40              /* Advanced RISC Machines ARM */
 #define EM_ALPHA       41              /* DEC ALPHA */
 #define        EM_SH           42              /* Hitachi/Renesas Super-H */
@@ -587,6 +582,8 @@ typedef struct {
  * bump the version.
  */
 
+#if defined(_KERNEL)
+
 #define NT_OPENBSD_PROCINFO    10
 #define NT_OPENBSD_AUXV                11
 
@@ -619,6 +616,8 @@ struct elfcore_procinfo {
        int8_t          cpi_name[32];   /* copy of pr->ps_comm */
 };
 
+#endif
+
 /*
  * XXX - these _KERNEL items aren't part of the ABI!
  */
diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c
index 2c7676b1b13..a29cee02216 100644
--- a/usr.bin/nm/elf.c
+++ b/usr.bin/nm/elf.c
@@ -29,7 +29,7 @@
 #include <sys/mman.h>
 #include <unistd.h>
 #include <a.out.h>
-#include <elf_abi.h>
+#include <elf.h>
 #include <errno.h>
 #include <err.h>
 #include <stdint.h>
diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c
index 5d2a1bfeb61..72f1f0b4cc7 100644
--- a/usr.bin/nm/nm.c
+++ b/usr.bin/nm/nm.c
@@ -36,7 +36,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <a.out.h>
-#include <elf_abi.h>
+#include <elf.h>
 #include <ar.h>
 #include <ranlib.h>
 #include <unistd.h>
diff --git a/usr.bin/rdist/isexec.c b/usr.bin/rdist/isexec.c
index e6d125a61f2..a69677d65e4 100644
--- a/usr.bin/rdist/isexec.c
+++ b/usr.bin/rdist/isexec.c
@@ -30,7 +30,7 @@
  */
 
 #include <sys/types.h>
-#include <elf_abi.h>
+#include <elf.h>
 #include <fcntl.h>
 #include <unistd.h>
 
diff --git a/usr.sbin/installboot/i386_installboot.c 
b/usr.sbin/installboot/i386_installboot.c
index 10acf8bef32..7af82463308 100644
--- a/usr.sbin/installboot/i386_installboot.c
+++ b/usr.sbin/installboot/i386_installboot.c
@@ -54,7 +54,7 @@
 #include <machine/cpu.h>
 #include <machine/biosvar.h>
 
-#include <elf_abi.h>
+#include <elf.h>
 #include <err.h>
 #include <errno.h>
 #include <fcntl.h>
diff --git a/usr.sbin/installboot/i386_nlist.c 
b/usr.sbin/installboot/i386_nlist.c
index f508d74d94e..6d6d93e3e57 100644
--- a/usr.sbin/installboot/i386_nlist.c
+++ b/usr.sbin/installboot/i386_nlist.c
@@ -34,7 +34,7 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 
-#include <elf_abi.h>
+#include <elf.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <nlist.h>
diff --git a/usr.sbin/kvm_mkdb/nlist.c b/usr.sbin/kvm_mkdb/nlist.c
index 18f895a97b0..3e5a11bbb49 100644
--- a/usr.sbin/kvm_mkdb/nlist.c
+++ b/usr.sbin/kvm_mkdb/nlist.c
@@ -50,7 +50,7 @@
 #include <sys/file.h>
 #include <sys/sysctl.h>
 
-#include <elf_abi.h>
+#include <elf.h>
 
 typedef struct nlist NLIST;
 #define        _strx   n_un.n_strx

Reply via email to