Commit graph

39 commits

Author SHA1 Message Date
Justine Tunney 12be6f12e8 Fix memory corruption in C++ demangler
The __cxa_demangle_gnu3() and cpp_demangle_gnu3() functions segfault on
various libcxxabi test cases due to a copy and paste error. This change
fixes that.

This is a subset of https://github.com/libcxxrt/libcxxrt/pull/34 which
fixes the immediate problem.

Reviewed by: imp, emaste (I think)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1222
2024-05-09 19:55:52 -06:00
Mitchell Horne 537c166b76 elftoolchain: update the list of riscv relocations
A few have been added, a couple removed.

Reviewed by:	jrtc27, imp, emaste
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38175
2023-01-31 14:32:40 -04:00
Dimitry Andric c2bffd0a97 Merge elftoolchain r3877 (by jkoshy):
Incorporate fixes from Dimitry Andric:

  - Use a BUFFER_GROW() macro to avoid rounding errors in capacity
    calculations.
  - Fix a bug introduced in [r3531].
  - Fix handling of nested template parameters.

  Ticket:	#581

This should fix a number of assertions on elftoolchain's cxxfilt, and
allow it to correctly demangle several names that it could not handle
before.

Obtained from:	https://sourceforge.net/p/elftoolchain/code/3877/
PR:		250702
MFC after:	3 days
2020-11-04 11:02:05 +00:00
Mark Johnston c364ccf9ce libelftc: Fix a memory leak in cpp_demangle_read_type().
CID:		1305425
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-03-20 16:25:06 +00:00
Ed Maste 57d7e4cc2c elfcopy: set ELF OS/ABI field when converting from binary
PR:		228934
Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
Reviewed by:	markj, jkoshy
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23504
2020-02-12 15:59:59 +00:00
Mark Johnston 334f09a65b libelftc: Add a missing check for an error from vector_str_init().
While here consistently use the same spelling for such checks.

CID:		1376769
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:16:16 +00:00
Mark Johnston a3c35da61b libelftc: Fix memory leaks in the C++ demanglers.
CID:		1262518, 1262519, 1262520, 1262529
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-04 21:15:52 +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
Alex Richardson b46517aa7b Allow bootstrapping elftoolchain on MacOS and Linux
This is required in order to build on non-FreeBSD systems without setting
all the XAR/XSTRINGS/etc. variables

Reviewed By:	emaste
Differential Revision: https://reviews.freebsd.org/D16771
2019-07-01 11:52:54 +00:00
Mitchell Horne e16ea34016 libelftc: add RISC-V bfd targets
This adds the following targets: elf32-riscv, elf64-riscv, elf64-riscv-freebsd

Reviewed by:	emaste, markj, jkoshy@users.sourceforge.net
Approved by:	markj (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D20768
2019-06-28 00:14:12 +00:00
Mark Johnston 9810827a3a libelftc: Fix the documented prototype for elftc_string_table_destroy().
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2019-06-26 16:32:41 +00:00
Mark Johnston b90eaf941f libelftc: Consistently use size_t for string table offsets and sizes.
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20702
2019-06-26 16:31:50 +00:00
Mark Johnston 70b0aff9a1 libelftc: Micro-optimize string table insertion.
The string's length is already known, so use memcpy() instead of
strcpy() to add it to the string table image.

Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20760
2019-06-26 16:30:14 +00:00
Mark Johnston 0d951ba85c libelftc: Fix some minor style bugs.
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D20472
2019-06-04 18:31:08 +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 e37480d938 readelf: decode R_MIPS_HIGHER and R_MIPS_HIGHEST relocation types
Sponsored by:	The FreeBSD Foundation
2018-11-02 18:40:01 +00:00
Ed Maste 715d1396d6 Update ELF Tool Chain to r3614
MFC after:	1 week
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
2018-04-27 13:59:24 +00:00
Ed Maste 18f4c9db68 Update to ELF Tool Chain snapshot at r3561
This update is primarily bug fixes in C++ symbol demangling, including:

- rvalue reference
- builtin type auto and decltype(auto)
- revamped support for function return types
- formatting fixes
- omit void when its the only param
- ref-qualifiers and others in function types
- type qualifiers in pointer-to-member function types
- incorrect handling regarding CV-qualifiers in function types
- ref-qualifier found in nested-name
- properly handle <name> ::= <substitute><template-args>
- make sure that nested function name is not a substitute candidate
- correctly handle expression in template args
- skip unknown substitution abbreviations

MFC after:	4 days
2017-06-25 22:39:28 +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
Justin Hibbits 9569e13dce Add elf*-powerpc-freebsd targets to the elftoolchain target list
FreeBSD uses the full target triple when generating embedded rootfs images
(MFS_IMAGE= make option).  Without this change objcopy errors out with:

objcopy: elf64-poewrpc-freebsd: invalid target name

MFC after:	2 weeks
2017-02-08 03:21:29 +00:00
Ed Maste c83bcfbd2e readelf: add S390 relocation types
From https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries.html

Reviewed by:	bz
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9149
2017-01-11 22:54:04 +00:00
Ed Maste 0fbbe5bf87 readelf: add more PPC64 relocation types found in LLVM
MFC after:	2 weeks
MFC with:	r311941
Sponsored by:	The FreeBSD Foundation
2017-01-11 21:28:22 +00:00
Ed Maste dd9d62b416 readelf: add PPC64 relocation types
Reported by:	Mark Millard
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D9146
2017-01-11 21:18:14 +00:00
Ed Maste 3ca2845d13 libelftc: add elf{32,64}-tradlittlemips target emulation names
Sponsored by:	The FreeBSD Foundation
2016-12-10 01:40:10 +00:00
Ed Maste adb25d1e1a libelftc: add elf{32,64}-tradbigmips target emulation names
Reported by:	theraven
Sponsored by:	The FreeBSD Foundation
2016-11-07 22:41:52 +00:00
Ed Maste b6d812d2dd Update to ELF Tool Chain r3490
Improvements include:
 * readelf: report all relocation types in rel/rela for MIPS N64
 * readelf: add ELFOSABI_ARM_AEABI
 * elfdump: add ELFOSABI_ARM_AEABI and ELFOSABI_ARM
 * Add recent RISC-V relocations
 * elfcopy: use elftc_timestamp, to support SOURCE_DATE_EPOCH

Sponsored by:	The FreeBSD Foundation
2016-08-31 15:05:04 +00:00
Ed Maste e85c2b0b12 elfcopy: add elf64-littleaarch64 output target support
Sponsored by:	The FreeBSD Foundation
2016-08-15 14:28:08 +00:00
Ed Maste 4e359ce1a0 libelftc: fix demangling of wchar_t
"wchar_t" is 7 characters long, not 6.

PR:		208661
Submitted by:	Daniel McRobb
Obtained from:	ELF Tool Chain r3480
MFC after:	3 days
2016-07-24 23:40:33 +00:00
Bryan Drewery 94bb24b387 Use the in-tree sys/elf_common.h to build libelftc.
This fixes build failures on older releases that lack various
definitions such as EM_AARCH64 (which was unfixed before this).

Revert all of the recent compatibility changes that worked around this
problem.

This uses the same method of using the in-tree header as lib/libelf,
lib/libdwarf and usr.bin/readelf.

Reviewed by:	emaste
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D6734
2016-06-05 23:05:14 +00:00
Ed Maste bdef86c693 elftoolchain: backwards compatability for EM_RISCV definition
It is not provided by sys/elf_common.h on older releases

Reported by:	Jenkins
2016-05-20 20:27:30 +00:00
Ed Maste d28b40c8d9 elftoolchain: backwards compatability for EM_IAMCU definition
It is not provided by sys/elf_common.h on older stable/10.
2016-05-20 18:54:42 +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 3ef90571c1 Update to ELF Tool Chain r3223
Highlights (upstream revisions):
 - Fix SHT_GROUP handling in elfcopy/strip (3206 3220 3221)
 - Misc elfcopy / strip bug fixes (3215 3216 3217)
 - Many C++ demangler improvements (3199 3200 3201 3202 3203 3204 3205
   3208 3210 3211 3212)
 - Improve GNU binutils compatibility in elfcopy / strip (3213 3214)
 - Add -g option to readelf(1): dump contents of section groups (3219)
 - Add EM_IAMCU 32-bit Intel MCU (3198)

Also add a compat #define for building with older FreeBSD ELF headers.
The GRP_COMDAT flag was added to elf_common.h in r283110, but it's not
available during the bootstrap build.  It is also convenient to be able
to build on older hosts.

Thanks to antoine@ for tracking down issues through multiple exp-runs
and to kaiw@ for fixing.

PR:		198611 (exp-run), 200350
Sponsored by:	The FreeBSD Foundation
2015-05-27 14:28:19 +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 cf781b2e16 Update elftoolchain to upstream rev 3130
This brings a number of fixes to elfcopy/strip and DWARF4 improvements.

Sponsored by:	The FreeBSD Foundation
2014-12-24 03:13:16 +00:00
Ed Maste 50f69bfbd6 Fix elftoolchain tools in-tree build
* make variables static
 * add header for uint*_t typedefs
2014-12-01 16:07:31 +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