freebsd-skq/usr.sbin/kldxref
cem 156c41aa9b kldxref(8): Sort MDT_MODULE info first in linker.hints output
MDT_MODULE info is required to be ordered before any other MDT metadata for
a given kld because it serves as an implicit record boundary between
distinct klds for linker.hints consumers.  kldxref(8) has previously relied
on the assumption that MDT_MODULE was ordered relative to other module
metadata in kld objects by source code ordering.

However, C does not require implementations to emit file scope objects in
any particular order, and it seems that GCC 6.4.0 and/or binutils 2.32 ld
may reorder emitted objects with respect to source code ordering.

So: just take two passes over a given .ko's module metadata, scanning for
the MDT_MODULE on the first pass and the other metadata on subsequent
passes.  It's not super expensive and not exactly a performance-critical
piece of code.  This ensures MDT_MODULE is always ordered before
MDT_PNP_INFO and other MDTs, regardless of compiler/linker movement.  As a
fringe benefit, it removes the requirement that care be taken to always
order MODULE_PNP_INFO after DRIVER_MODULE in source code.

Reviewed by:	emaste, imp
Differential Revision:	https://reviews.freebsd.org/D20405
2019-05-27 17:33:20 +00:00
..
ef_aarch64.c kldxref: improve style(9) 2018-01-17 19:59:43 +00:00
ef_amd64.c various: general adoption of SPDX licensing ID tags. 2017-11-27 15:37:16 +00:00
ef_i386.c various: general adoption of SPDX licensing ID tags. 2017-11-27 15:37:16 +00:00
ef_mips.c Parse MIPS relocations to unbreak kldxref on MIPS. 2019-04-24 23:35:10 +00:00
ef_nop.c various: general adoption of SPDX licensing ID tags. 2017-11-27 15:37:16 +00:00
ef_obj.c kldxref: improve style(9) 2018-01-17 19:59:43 +00:00
ef_powerpc.c Fix kldxref on PowerPC64 2019-02-27 13:24:42 +00:00
ef_riscv.c Add support for relocations in RISC-V kernel modules to kldxref. 2018-10-08 19:15:58 +00:00
ef_sparc64.c various: general adoption of SPDX licensing ID tags. 2017-11-27 15:37:16 +00:00
ef.c kldxref: use appropriate Elf_Off type for offsets 2018-11-09 15:02:53 +00:00
ef.h kldxref: handle modules with md_cval at the end of allocated sections 2018-01-16 18:20:12 +00:00
fileformat
kldxref.8
kldxref.c kldxref(8): Sort MDT_MODULE info first in linker.hints output 2019-05-27 17:33:20 +00:00
Makefile Fix kldxref on PowerPC64 2019-02-27 13:24:42 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00