Commit graph

23 commits

Author SHA1 Message Date
Ed Maste 67b94fc58e addr2line: fix allocation leak in error path
CID:		1437677
Reported by:	Coverity Scan
Sponsored by:	The FreeBSD Foundation
2020-12-03 14:41:11 +00:00
Ed Maste f4d6ed9a5c addr2line: rework check_range conditions
Simplify logic and reduce indentation for DW_AT_low_pc case.

Reviewed by:	Tiger Gao, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D27426
2020-12-02 17:22:29 +00:00
Ed Maste a36179937e addr2line: add label checks when DW_AT_range and DW_AT_low_pc cannot be used
Check label's ranges for address we want to translate if a CU doesn't
have usable DW_AT_range or DW_AT_low_pc.

Use more appropriate names: "struct CU" -> "struct range"

Developed as part of upstream ELF Tool Chain bug report
https://sourceforge.net/p/elftoolchain/tickets/552/ although this does
not address the specific case reported there.

Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23782
2020-11-27 21:38:03 +00:00
Ed Maste 65c207758a addr2line: swap if conditions for diff reduction in upcoming change
No functional change intended.
2020-11-19 21:10:36 +00:00
Ed Maste fe91dd0138 addr2line: use stdbool.h header for bool
Presumably a bool definition is obtained via header contamination on
FreeBSD-CURRENT.  Found while trying to upstream FreeBSD addr2line
changes - the FreeBSD 11.2 CI build failed there.

Reported by:	Cirrus-CI, upstream ELF Tool Chain
MFC with:	r357844
Sponsored by:	The FreeBSD Foundation
2020-02-13 16:17:05 +00:00
Ed Maste 6c4a4f1bc2 addr2line: Handle DW_AT_ranges in compile units
Based on original submission by Marat Radchenko in ELF Tool Chain
ticket #545, rebased and updated by Tiger Gao.

PR:		217736
Submitted by:	Marat Radchenko <marat@slonopotamus.org>
Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23501
2020-02-12 21:52:10 +00:00
Mark Johnston 35beedae40 addr2line: Avoid a name collision.
The RB_ macros define functions with a parameter named head, and gcc
warns about this.

MFC with:	r357450
2020-02-03 19:08:35 +00:00
Mark Johnston af84329100 addr2line: Cache CU DIEs upon a successful address lookup.
Previously, addr2line would sequentially search all CUs for each input
address.  For some uses, notably syzkaller's code coverage map generator,
this was extremely slow.  Add a CU cache into which entries are added
following a successful lookup, and search the cache before falling back
to a scan.  When translating a large number of addresses this yields
slightly better performance than GNU addr2line.

Garbage-collect an unused hash table which appears to have been intended
for the same purpose.  A hash table doesn't seem particularly suitable
since each CU spans a range of addresses.

Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23418
2020-02-03 16:41:40 +00:00
Ed Maste d003e0d7fe Update ELF Tool Chain to upstream r3769
This contains many small bugfixes and documentation improvements.

Sponsored by:	The FreeBSD Foundation
2019-12-05 13:20:15 +00:00
Mark Johnston 1d954fed61 Capsicumize addr2line(1).
Reviewed by:	oshogbo
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D21104
2019-08-01 18:56:32 +00:00
Ed Maste ae500c1ff8 Update to ELF Tool Chain r3668
Highlights:
- Make sure that only TLS sections are sorted into TLS segment.
- Fixed multiple errors in "Section to Segment mapping".
- Man page updates
- ar improvements
- elfcopy: avoid filter_reloc uninitialized variable for rela
- elfcopy: avoid stripping relocations from static binaries
- readelf: avoid printing directory in front of absolute path
- readelf: add NT_FREEBSD_FEATURE_CTL FreeBSD note type
- test improvements

NOTES:

Some of these changes originated in FreeBSD and simply reduce diffs
between contrib and vendor.

ELF Tool Chain ar is not (currently) used in FreeBSD, and there are
improvements in both FreeBSD and ELF Tool Chain ar that are not in
the other.

Sponsored by:	The FreeBSD Foundation
2019-01-10 14:35:23 +00:00
Ed Maste bee2765cc1 Update ELF Tool Chain to upstream r3520
Highlights of changes between r3490 and r3520:

- Improve C++ demangling
- Improve compatibility with Binutils tools wrt. error messages
- Handle additional types/sections/etc. in readelf and elfdump
- addr2line, cxxfilt: use setvbuf to set line buffering for filter use

PR:		218395
MFC after:	2 weeks
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2017-04-17 23:56:48 +00:00
Ed Maste b6b6f9cc7c Update to ELF Tool Chain r3475
Improvements include:

 * Add support for reporting and handling a number of new constants in
   various tools, including:
    * CloudABI OSABI
    * DT_TLSDESC_*
    * i386, MIPS, SPARC and amd64 relocations

 * C++ demangler bug fixes

 * Man page updates

 * Improved input validation in several tools

This update also reduces diffs against upstream as a number of fixes
included in upstream were previously cherry-picked into FreeBSD.

Sponsored by:	The FreeBSD Foundation
2016-05-20 17:24:34 +00:00
Ed Maste 839529caa9 Update ELF Tool Chain to upstream rev 3400
Some notable improvements include:

readelf:
- Add AArch64 relocation definitions.
- Report value of unknown relocation types.

elfcopy:
- Consider symbols with STB_GNU_UNIQUE binding as global symbols.
- Fixed support for VMA adjustment for loadable sections found
  in relocatable objects.
- Handle nameless global symbols.
- Improve wildcard matching for !-prefixed symbols.
- Add PE/COFF support.

elfdump:
- Improve section type reporting.
- Add MIPS-specific section types.

This update also includes a significant number of bug fixes.

PR:		207091 [exp-run]
Sponsored by:	The FreeBSD Foundation
2016-02-12 20:54:02 +00:00
Ed Maste 95fd7f2615 Update to ELF Tool Chain r3272
Highlights (not already in the FreeBSD tree):
 - addr2line: Speed up and support searching inlined functions
 - addr2line: Support -i, -a, -p options
 - readelf: Add some ARM relocation types
 - readelf, libelf: Avoid reading beyond end of buffer/file

Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2015-12-11 20:28:27 +00:00
Ed Maste 7a2e729ba2 addr2line: initialize die to NULL
GCC on MIPS produced a 'may be used uninitialized' warning after
r289071.

Reported by:	sbruno
Pointy hat to:	emaste
2015-10-09 18:26:24 +00:00
Ed Maste 656f49f8e2 Update to ELF Tool Chain r3250
Highlights (not already in the FreeBSD tree):
  - addr2line: Fixed multiple memory leaks related to DIE allocation
  - readelf: improve sh_link validation
  - various man page improvements

Sponsored by:	The FreeBSD Foundation
2015-10-09 17:46:05 +00:00
Ed Maste c9dbb1cc52 addr2line: skip CUs lacking debug info instead of bailing out
Some binaries (such as the FreeBSD kernel) contain a mixture of CUs
with and without debug information. Previously translate() exited upon
encountering a CU without debug information. Instead, just move on to
the next CU.

Reported by:	royger
Reviewed by:	royger
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3712
2015-09-22 16:51:40 +00:00
Ed Maste b00fe64f4a Update to ELF Tool Chain r3197
Highlights:
 - Fix man page markup, whitespace, and typos
 - Fix sh_info of SHT_GROUP section to point to the correct string
 - Improve validation in readelf and elfcopy/strip
 - Handle DWARF 4's DW_AT_high_pc in addr2line

Sponsored by:	The FreeBSD Foundation
2015-05-14 19:48:15 +00:00
Ed Maste 67d97fe724 Update elftoolchain to upstream revision 3179
Some notable changes:
- libdwarf: Fixed DWARF4 line section
- elfcopy: Implement --localize-hidden
- nm: handle object name referenced by DW_AT_specification
- elfcopy: Add --strip-dwo and --extract-dwo options for split DWARF
- readelf: add remaining arm64 dynamic relocation names
- nm: Avoid integer overflow in value comparison

Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2015-04-01 01:08:01 +00:00
Ed Maste 71a0c925ce Update elftoolchain to upstream revision 3163
Most of our changes have now been committed upstream, so this change is
largely bookkeeping.

Sponsored by:	The FreeBSD Foundation
2015-02-17 15:19:58 +00:00
Ed Maste a726543364 addr2line: fflush output after each address lookup
Certain tools spawn addr2line and pass addresses one at a time for
resolution.

PR:		195561
Reported by:	antoine
Sponsored by:	The FreeBSD Foundation
2015-01-05 04:56:38 +00:00
Ed Maste a85fe12e36 Copy elftoolchain binutils replacements from vendor branch
Sponsored by:	The FreeBSD Foundation
2014-11-27 20:12:13 +00:00