head 1.7; access; symbols netbsd-11-0-RELEASE:1.7 netbsd-11-0-RC7:1.7 netbsd-11-0-RC6:1.7 netbsd-11-0-RC5:1.7 netbsd-11-0-RC4:1.7 netbsd-11-0-RC3:1.7 netbsd-11-0-RC2:1.7 netbsd-11-0-RC1:1.7 perseant-exfatfs-base-20250801:1.7 netbsd-11:1.7.0.4 netbsd-11-base:1.7 netbsd-10-1-RELEASE:1.2 perseant-exfatfs-base-20240630:1.7 perseant-exfatfs:1.7.0.2 perseant-exfatfs-base:1.7 netbsd-10-0-RELEASE:1.2 netbsd-10-0-RC6:1.2 netbsd-10-0-RC5:1.2 netbsd-10-0-RC4:1.2 netbsd-10-0-RC3:1.2 netbsd-10-0-RC2:1.2 netbsd-10-0-RC1:1.2 netbsd-10:1.2.0.2 netbsd-10-base:1.2; locks; strict; comment @# @; 1.7 date 2024.04.01.18.33.23; author riastradh; state Exp; branches; next 1.6; commitid vyJKod7VBuSCgt4F; 1.6 date 2024.03.30.22.39.53; author riastradh; state Exp; branches; next 1.5; commitid 8MhmzQBQIUvbHe4F; 1.5 date 2024.03.27.21.54.43; author christos; state Exp; branches; next 1.4; commitid jbC4hnpKaEMrxQ3F; 1.4 date 2024.03.26.16.48.34; author christos; state Exp; branches; next 1.3; commitid d6CL3kTlAn6ZRG3F; 1.3 date 2024.03.03.17.37.58; author christos; state Exp; branches; next 1.2; commitid LHVVWcCAVOrmTJ0F; 1.2 date 2022.05.01.17.25.19; author jkoshy; state Exp; branches; next 1.1; commitid GF6OLOzYFXFdqnCD; 1.1 date 2022.04.18.14.11.43; author jkoshy; state Exp; branches; next ; commitid k1mZJ8U3UoPVKGAD; desc @@ 1.7 log @elftoolchain: Be consistent about which ELF header files we use. 1. For tools that use elftoolchain: always use elftoolchain's elfdefinitions.h. Don't even think about looking at the host's sys/exec_elf.h, which makes no sense and should never happen. (ELF tools that don't use elftoolchain, like m68k-elf2coff, continue to use nbincludes/sys/exec_elf.h. But no more nbincludes hacks in elftoolchain.) 2. For kernel components (solaris, zfs, dtrace): always use sys/exec_elf.h, even in Solaris components via sys/elf.h. elfdefinitions.h is not wired up in the kernel build at all. 3. For most userland components that involve libelf: use elfdefinitions.h via libelf header files (libelf.h, gelf.h). libdtrace in particular requires _all_ R_* reloc type definitions, but sys/exec_elf.h brings in only the _current machine's_ R_* reloc type definitions. (While here: Use uintptr_t instead of Elf_Addr for pointer-to-integer cast, since Elf_Addr is MD and provided only by sys/exec_elf.h, not by elfdefinitions.h.) And most userland components using libelf don't rely on any properties of the current machine from sys/exec_elf.h, so they can use libelf's elfdefinition.h. Exceptions: - dtrace drti.c relies on link.h -> link_elf.h -> sys/exec_elf.h, but it also relies on sys/dtrace.h -> sys/elf.h -> elfdefinitions.h like other userland components using sys/elf.h. - kdump-ioctl.c uses sys/exec_elf.h directly and sys/dtrace.h -> sys/elf.h -> elfdefinitions like other userland components using sys/elf.h. - t_ptrace_wait.c (via t_ptrace_core_wait.h) uses libelf to parse core files, but relies on sys/exec_elf.h for struct netbsd_elfcore_procinfo. None of these exceptions needs all R_* reloc type definitions, so as a workaround, we can just suppress libelf's elfdefinitions.h by defining _SYS_ELFDEFINITIONS_H_ and use sys/exec_elf.h in these exceptions. And undo the whole BUILTIN_ELF_HEADERS mistake. This was: - half bogus workarounds for missing build_install dependencies in tools/Makefile, which are no longer missing now, and - half futile attempt to use src/sys/sys/exec_elf.h via nbincludes in tools involving libelf instead of libelf's elfdefinitions.h, which collides. Longer-term, we may wish to unify sys/exec_elf.h and libelf's elfdefinitions.h, so we don't have to play these games. But at least now the games are limited to three .c files (one of which is generated by Makefile.ioctl-c), rather than haphazardly applied tree-wide by monstrous kludges in widely used .h files with broken hackarounds to get the tools build lurching to completion. @ text @# $NetBSD: Makefile,v 1.6 2024/03/30 22:39:53 riastradh Exp $ HOSTLIB=dwarf .include SRCS= \ dwarf_abbrev.c \ dwarf_arange.c \ dwarf_attr.c \ dwarf_attrval.c \ dwarf_cu.c \ dwarf_dealloc.c \ dwarf_die.c \ dwarf_dump.c \ dwarf_errmsg.c \ dwarf_finish.c \ dwarf_form.c \ dwarf_frame.c \ dwarf_init.c \ dwarf_lineno.c \ dwarf_loclist.c \ dwarf_macinfo.c \ dwarf_pro_arange.c \ dwarf_pro_attr.c \ dwarf_pro_die.c \ dwarf_pro_expr.c \ dwarf_pro_finish.c \ dwarf_pro_frame.c \ dwarf_pro_init.c \ dwarf_pro_lineno.c \ dwarf_pro_macinfo.c \ dwarf_pro_reloc.c \ dwarf_pro_sections.c \ dwarf_ranges.c \ dwarf_reloc.c \ dwarf_seterror.c \ dwarf_str.c \ libdwarf.c \ libdwarf_abbrev.c \ libdwarf_arange.c \ libdwarf_attr.c \ libdwarf_die.c \ libdwarf_elf_access.c \ libdwarf_elf_init.c \ libdwarf_error.c \ libdwarf_frame.c \ libdwarf_info.c \ libdwarf_init.c \ libdwarf_lineno.c \ libdwarf_loc.c \ libdwarf_loclist.c \ libdwarf_macinfo.c \ libdwarf_nametbl.c \ libdwarf_ranges.c \ libdwarf_reloc.c \ libdwarf_rw.c \ libdwarf_sections.c \ libdwarf_str.c ELFTOOLCHAIN_DIR=${.CURDIR}/../../../external/bsd/elftoolchain/dist LIBDWARF_DIR= ${ELFTOOLCHAIN_DIR}/libdwarf LIBELF_DIR= ${ELFTOOLCHAIN_DIR}/libelf COMMON_DIR= ${ELFTOOLCHAIN_DIR}/common INCS= dwarf.h libdwarf.h INCSDIR= /usr/include .ifndef NOCOMPATLIB COMPATLIB_NO_LIB= yes # only the include files, not the library .-include "${TOOLDIR}/share/compat/defs.mk" .endif LIBDWARF_OBJDIR!= cd ${.CURDIR} && ${PRINTOBJDIR} CPPFLAGS+= -I${.CURDIR}/../../compat CPPFLAGS+= -I${.CURDIR}/../../common CPPFLAGS+= -I${LIBDWARF_OBJDIR}/../common CPPFLAGS+= -I${LIBDWARF_DIR} -I${LIBELF_DIR} -I${COMMON_DIR} CPPFLAGS+= -I${TOOLDIR}/include BUILD_OSTYPE!= uname -s # Disable use of pre-compiled headers on Darwin. .if ${BUILD_OSTYPE} == "Darwin" CPPFLAGS+= -no-cpp-precomp .endif # -D_FILE_OFFSET_BITS=64 produces a much more amenable `struct stat', and # other file ops, on many systems, without changing function names. CPPFLAGS+= -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 .PATH: ${LIBDWARF_DIR} HOST_CPPFLAGS:= ${CPPFLAGS} ${HOST_CPPFLAGS} CPPFLAGS:= # empty .include @ 1.6 log @tools/elftoolchain: Build with BUILTIN_ELF_HEADERS again. The header file dependency that motivated disabling this should be resolved now. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.5 2024/03/27 21:54:43 christos Exp $ a75 1 CPPFLAGS+= -DBUILTIN_ELF_HEADERS d80 1 a80 1 CPPFLAGS+= -I${TOOLDIR}/include -I${TOOLDIR}/include/nbinclude @ 1.5 log @Remove dependency to elfdefinitions.h, this is a mess, since it needs ${TOOL_M4} which might not be available yet. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.4 2024/03/26 16:48:34 christos Exp $ d76 1 @ 1.4 log @- fix nbincludes so that it can be included from any level - add elftoolchain/common to the list of headers to be build before depend - make libdwarf build the includes since it needs which does not exist on non-netbsd systems. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.3 2024/03/03 17:37:58 christos Exp $ a75 1 CPPFLAGS+= -DBUILTIN_ELF_HEADERS a98 1 .include "../../Makefile.nbincludes" @ 1.3 log @changes for r4037 @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.2 2022/05/01 17:25:19 jkoshy Exp $ d100 1 @ 1.2 log @Make the generated file visible when compiling libdwarf. @ text @d1 1 a1 1 # $NetBSD: Makefile,v 1.1 2022/04/18 14:11:43 jkoshy Exp $ d76 1 @ 1.1 log @Build 'libelf' and 'libdwarf' under 'tools/elftoolchain', after 'tools/elftoolchain/common' has been built. This change aligns the 'tools' build with the regular build. Subsequent commits will change 'tools/libctf' and 'tools/cft{merge,convert}' to use the new build paths. @ text @d1 1 a1 1 # $NetBSD$ d74 2 d78 1 @