Commit Graph

22 Commits

Author SHA1 Message Date
Dimitry Andric
05c312a339 Bump kldxref's MAXSEGS to 16, to stop complaints about the kernel
supposedly having too many segments, when lld 11 links it. Such kernels
should load just fine.

Note that we may still do some tweaking of our kernel linker scripts, to
lower the number of segments, although the exact benefit is not entirely
clear.
2020-08-20 18:50:46 +00:00
Ed Maste
b6274d1775 kldxref: use appropriate Elf_Off type for offsets
Submitted by:	Mitchell Horne <mhorne063@gmail.com>
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13957
2018-11-09 15:02:53 +00:00
Ed Maste
559d4a5216 kldxref: additional sytle(9) cleanup
Reported by:	kib (via comments in D13957)
Sponsored by:	The FreeBSD Foundation
2018-01-17 20:43:30 +00:00
Ed Maste
e2d0802c6b kldxref: improve style(9)
Address style issues including some previously raised in D13923.

- Use designated initializers for structs
- Always use bracketed return style
- No initialization in declarations
- Align function prototype names
- Remove old commented code/unused includes

Submitted by:	Mitchell Horne <mhorne063@gmail.com>
Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13943
2018-01-17 19:59:43 +00:00
Ed Maste
da67e6e62c kldxref: handle modules with md_cval at the end of allocated sections
Attempting to retrieve an md_cval string from a kernel module with
kldxref would throw a offset error for modules created using lld, since
this value would be placed at the end of all allocated sections.

Add an ef_read_seg_string method to the ef interface, to allow reading
strings of varying size without attempting to read beyond the segment's
bounds.

PR:		224875
Submitted by:	Mitchell Horne <mhorne063@gmail.com>
Reviewed by:	cem, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D13923
2018-01-16 18:20:12 +00:00
Ed Maste
f68e716ffe kldxref: correct function names in warning messages
Sponsored by:	The FreeBSD Foundation
2018-01-02 21:31:54 +00:00
Pedro F. Giffuni
df57947f08 spdx: initial adoption of licensing ID tags.
The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

Initially, only tag files that use BSD 4-Clause "Original" license.

RelNotes:	yes
Differential Revision:	https://reviews.freebsd.org/D13133
2017-11-18 14:26:50 +00:00
Ed Maste
b6c03f2122 kldxref: bump MAXSEGS to 3
ld.bfd generates two PT_LOAD segments, but certain linkers or linker
configurations generate three PT_LOAD segments (one additional for
RELRO).

PR:		216975
Reported by:	Shawn Webb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2017-02-10 19:17:10 +00:00
Ed Maste
d65b2f7ed6 kldxref: s/sections/segments/ in warning message
The message refers to program header segments, not sections.

PR:		216975
2017-02-10 19:11:33 +00:00
Ed Maste
2bd7b9e5cc kldxref: Clean up error reporting
Omit "too many sections" warnings if the ELF file is not dynamically
linked (and is therefore skipped anyway), and otherwise output it only
once.  An errant core file would previously cause kldxref to output a
number of warnings.

Also introduce a MAXSEGS #define and replace literal 2 with it, to make
comparisons clear.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
2014-04-30 18:11:53 +00:00
Xin LI
ac8e13960d Remove unneeded reference to link.h (sys/link_elf.h).
MFC after:	2 weeks
2013-06-05 21:55:20 +00:00
Tim Kientzle
5db4d6779f Clarify a warning message. 2012-10-29 03:31:22 +00:00
Eitan Adler
7e22d9ed96 Remove variables which are initialized but never used thereafter reported by gcc46 warning
Approved by:	cperciva
MFC After:	3 days
2012-06-19 06:10:34 +00:00
Marcel Moolenaar
757686b115 Make our ELF64 type definitions match standards. In particular this
means:
o  Remove Elf64_Quarter,
o  Redefine Elf64_Half to be 16-bit,
o  Redefine Elf64_Word to be 32-bit,
o  Add Elf64_Xword and Elf64_Sxword for 64-bit entities,
o  Use Elf_Size in MI code to abstract the difference between
   Elf32_Word and Elf64_Word.
o  Add Elf_Ssize as the signed counterpart of Elf_Size.

MFC after: 2 weeks
2005-12-18 04:52:37 +00:00
Ian Dowse
9dba198b0e Explicitly pass in the relocation base and data offset into ef_reloc()
rather than relying on a trick that happens to work for the current
relocation schemes. Also add some comments and improve variable
naming.
2004-08-28 19:31:10 +00:00
Ian Dowse
9772dc2aff Call the file format specific code through a table of function
pointers and remove knowledge of the file format from kldxref.c.
This will make it possible to support more than one file format.
2004-08-27 00:51:21 +00:00
Jake Burkholder
1eed250ad8 Fix kldxref on sparc64 by allowing non-trivial relocations to be performed
on variables read out of raw kld files.  Unlike other platforms the value
will be in an Elf_Rela, not in the data section of the elf file.

Submitted by:	Hartmut Brandt <brandt@fokus.gmd.de>
PR:		46730
Tested on:	alpha (obrien), i386, sparc64
2003-01-21 03:51:53 +00:00
Peter Wemm
754a3615a0 This is a userland tool, not a kernel component or libstand client. 2002-07-17 23:41:58 +00:00
Peter Wemm
f23aa297ee Make kldxref work for Elf64 (which has 32 bit hash tables) 2002-04-11 09:30:15 +00:00
John Baldwin
8c7911ebe2 Remove unnecessary machine/bootinfo.h includes.
Submitted by:	jake
2002-01-03 19:10:49 +00:00
Mike Heffner
87e5cd7c1a WARNS=2 cleanup.
PR:		bin/32567
MFC after:	2 weeks
2001-12-09 07:22:26 +00:00
Peter Wemm
9c6f92408c Add kldxref(8), for maintaining the linker.hints file for translating
module->pathname.ko.  It supports only ELF for now.

Submitted by:   bp  (with some minor tweaks)
2001-09-11 01:13:15 +00:00