On 04/07/17(Tue) 22:12, Karel Gardas wrote: > > I think that moving towards <elf.h> is a good thing. However are you > > sure that <sys/exec_elf.h> provides all the definitions required by > > <elf.h>? > > Not yet. At least a lot of machine related definitions are missing, but > they are not required if neither base nor ports need them.
They are required because third party software will see,"Oh OpenBSD has <elf.h>" and assume it contains such define. > > Are you sure it doesn't provide any other definition that > > would make code written on OpenBSD non portable? > > PT_OPENBSD_* and NT_OPENBSD_* are there. The first I moved to ifdef > ELF_OPENBSD_EXTENSION. The second is used only by kernel hence _KERNEL. > Otherwise a lot of <type>_DEFINED_ from sys/types.h leak in, but the question > is if this hurts or not. Defines with OPENBSD in them do not hurt, since they are specific to OpenBSD. The #ifdef _KERNEL makes sense. 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. > > 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). > > 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. > > I would welcome such move since it would make easier to port programs > > from OpenBSD to other platforms. However it's not as easy as including > > a header in another. Are you ready to tackle the above mentioned > > issues? > > Don't know about complexity of this. Anyway, below is another step which > fixes machine definition (obvious issues), adds mentioned EM_PPC64 and > _KERNEL ifdefs NT_OPENBSD and also uses ELF_OPENBSD_EXTENSION to filter out > PT_OPENBSD. However later is questionable since PT_GNU is there without any > #ifdef. So I can see several ways how to improve on this. For example: > > - move #define ELF_OPENBSD_EXTENSION to elf_abi.h and remove from base > progs/libs. This way elf.h will be portable and elf_abi.h OBSD specific with > an option to rename to elf_obsd.h or so in the future. > - if you don't like ELF_OPENBSD_EXTENSION I'm free to rename to whatever is > preferred. I'd leave it as it is for now, I don't think it makes sense to keep <elf_abi.h>. And we generally don't use conditionals for headers, so just drop ELF_OPENBSD_EXTENSION. Martin