aboutsummaryrefslogtreecommitdiff
path: root/contrib/elftoolchain/libdwarf
Commit message (Collapse)AuthorAgeFilesLines
* LoongArch: elftoolchain: add supportyu shan wei2025-06-122-0/+9
| | | | | | | | | | | According to the latest elftoolchain r4191, add support for Loongarch Co-authored-by: haowuge <gehaowu@bitmoe.com> Co-authored-by: xiaoqiang zhao <zxq_yx_007@163.com> Signed-off-by: yu shan wei <mpysw@vip.163.com> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1682 Closes: https://github.com/freebsd/freebsd-src/pull/1682
* elftoolchain: Consistently use item count as the first argument to callocJohn Baldwin2024-07-191-1/+1
| | | | | | Reported by: GCC 14 -Wcalloc-transposed-args Reviewed by: rlibby, emaste Differential Revision: https://reviews.freebsd.org/D46007
* libdwarf: Add some constants from DWARF 5Mark Johnston2023-02-075-2/+262
| | | | | | | | | | | | | | | This is not exhaustive - DWARF 5 has some new enumeration types not implemented here - but I think I caught all the ones that are extended in DWARF 5, plus the new compilation unit type (DW_UT_*), needed when parsing .debug_info headers. These were useful when extending libdwarf/ctfconvert/readelf to handle DWARF generated by gcc 12, which is version 5 by default. Reviewed by: emaste MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D38273
* libdwarf: Add a weak uncompress() symbolMark Johnston2021-12-131-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This works around brokenness in buildworld's bootstrapping logic: it uses the source tree's metadata to collect dependency info (such as, "libdwarf depends on libz") but links against static host libraries. If these two are out of sync, as is the case if one builds a commit prior to the introduction of the libz dependency, then the build fails when trying to statically link nm(1). Mitigate the problem by defining a weak uncompress() symbol which simply returns an error. This ensures that the build won't fail when statically linking libdwarf without zlib. The downside is that any tools using libdwarf without zlib will now hit a runtime error if they attempt to decode compressed sections, but at least they'll fail deterministically, and compressed debug info is only enabled by default in main. In particular, this fixes building of branches lacking commit dbf05458e3bd, such as releng branches, stable/12 and 13 and old revisions of main. Previously the nm(1) build would fail with: ld: error: undefined symbol: uncompress >>> referenced by libdwarf_elf_init.c:233 >>> (/usr/src/contrib/elftoolchain/libdwarf/libdwarf_elf_init.c:233) >>> libdwarf_elf_init.o:(_dwarf_elf_init) in archive >>> /usr/lib/libdwarf.a Reported by: dim, ler, krion Reviewed by: imp, emaste Fixes: dbf05458e3bd ("libdwarf: Support consumption of compressed ELF sections") MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33419
* libdwarf: Fix error handling in _dwarf_elf_init()Mark Johnston2021-12-131-4/+4
| | | | | | | | | | We were not setting "ret" before jumping to the error path, so the function returned success even when it had failed. Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33420
* libdwarf: Support consumption of compressed ELF sectionsMark Johnston2021-12-063-15/+78
| | | | | | | | | | | | | Automatically decompress zlib-compressed debug sections when loading them. This lets ctfcovert work on userland code after commit c910570e7573 ("Use compressed debug in standalone userland debug files by default"). Reported by: avg Reviewed by: avg, emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33139
* libdwarf: Hide SHT_NOBITS sections.Mark Johnston2020-07-201-0/+6
| | | | | | | | | | | | | | | | | | gnu_debuglink external debug files will contain an .eh_frame section of type SHT_NOBITS. libdwarf does not handle such sections (or rather, it expects all debug sections to not have type SHT_NOBITS). Avoid loading SHT_NOBITS sections, to be consistent with SGI libdwarf's handling of this case. PR: 239516 Diagnosed by: Paco Pascal <me@pacopascal.com> Reviewed by: emaste (previous version) Event: July 2020 Bugathon MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25626 Notes: svn path=/head/; revision=363375
* libdwarf: Make an out-pointer assignment unconditional.Mark Johnston2020-03-201-2/+1
| | | | | | | | | | | | There is no reason for diep to ever be NULL, since in that case we would simply be leaking memory. CID: 1418801 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=359172
* libdwarf: Fix a memory leak in _dwarf_frame_section_init().Mark Johnston2020-02-041-3/+3
| | | | | | | | | | | If frame length validation failed we would leak memory. CID: 1193366 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357534
* libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.Mark Johnston2020-02-041-3/+1
| | | | | | | | | | | | All callers pass a non-NULL pointer, and otherwise it was possible to leak memory if the abbrev was not added to a CU. CID: 1193365 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357533
* libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().Mark Johnston2020-02-041-1/+3
| | | | | | | | | CID: 1193364 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357532
* libdwarf: Remove unnecessary NULL checks.Mark Johnston2020-02-041-5/+5
| | | | | | | | | | | | | All callers of _dwarf_add_expr() and _dwarf_expr_into_block() pass a non-NULL expr pointer, and these functions assume that expr is non-NULL anyway. CID: 1193305, 1193306 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357531
* Update ELF Tool Chain to upstream r3769Ed Maste2019-12-054-5/+5
| | | | | | | | | This contains many small bugfixes and documentation improvements. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=355413
* libdwarf: Use the cached strtab pointer when reading string attributes.Mark Johnston2019-06-261-4/+1
| | | | | | | | | | | | | | | | Previously we would perform a linear search of the DWARF section list for ".debug_str". However, libdwarf always caches a pointer to the strtab image in its debug descriptor. Using it gives a modest performance improvement when iterating over the attributes of each DIE. Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20759 Notes: svn path=/head/; revision=349424
* Add missing powerpc64 relocation support to libdwarfJustin Hibbits2019-05-291-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Due to missing relocation support in libdwarf for powerpc64, handling of dwarf info on unlinked objects was bogus. Examining raw dwarf data on objects compiled on ppc64 with a modern compiler (in-tree gcc tends to hide the issue, since it only rarely generates relocations in .debug_info and uses DW_FORM_str instead of DW_FORM_strp for everything), you will find that the dwarf data appears corrupt, with repeated references to the compiler version where things like types and function names should appear. This happens because the 0 offset of .debug_str contains the compiler version, and without applying the relocations, *all* indirect strings in .dwarf_info will end up pointing to it. This corruption then propogates to the CTF data, as ctfconvert relies on libdwarf to read the dwarf info, for every compiled object (when building a kernel.) However, if you examine the dwarf data on a compiled executable, it will appear correct, because during final link the relocations get applied and baked in by the linker. Submitted by: Brandon Bergren Reviewed By: emaste Differential Revision: https://reviews.freebsd.org/D20367 Notes: svn path=/head/; revision=348347
* Prepend DW_AT_comp_dir to relative line number directory table entries.Mark Johnston2019-03-271-14/+28
| | | | | | | | | | | | | | | | | | | Relative directories may appear in the line number program for a CPU if files were included via a relative path, for instance with "-I.". Previously, dwarf_srclines(3) and dwarf_srcfiles(3) would return the relative path, so addr2line, for instance, would do the same. However, we can get an absolute path by prepending the compilation directory, so change libdwarf to do that to improve compatibility with GNU binutils and since it is more useful in general. Reviewed by: jhb Discussed with: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19705 Notes: svn path=/head/; revision=345593
* Update to ELF Tool Chain r3668Ed Maste2019-01-10126-768/+766
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=342918
* Add DW_LANG_* definitions from DWARF 4 and 5.Mark Johnston2018-06-092-0/+54
| | | | | | | | | Reviewed by: emaste MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D15712 Notes: svn path=/head/; revision=334881
* Update ELF Tool Chain to r3614Ed Maste2018-04-274-5/+7
| | | | | | | | | MFC after: 1 week Relnotes: Yes Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=333063
* Update ELF Tool Chain to upstream r3520Ed Maste2017-04-174-4/+60
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=317075
* Follow DW_AT_specification when looking up DW_AT_type attributes.Mark Johnston2016-12-282-14/+29
| | | | | | | | | | | | | | | | | dwarf_attrval_*() will search the parent DIE referenced by a DW_AT_abstract_origin attribute for the value of the DW_AT_type attribute. Do the same thing for the DW_AT_specification attributes in variable definitions emitted by GCC 6.2, and ensure that we return an error rather than crashing if neither DW_AT_abstract_origin or DW_AT_specification is found when looking for the value of the DW_AT_type attribute. PR: 215350, 215395 Reviewed by: emaste MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D8920 Notes: svn path=/head/; revision=310724
* libdwarf: Add definitions for Apple's DWARF extension attributes.Mark Johnston2016-09-202-0/+41
| | | | | | | | Reviewed by: emaste MFC after: 1 week Notes: svn path=/head/; revision=306008
* Use the in-tree sys/elf_common.h to build libelftc.Bryan Drewery2016-06-051-5/+0
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=301471
* Add relocation support for RISC-V.Ruslan Bukin2016-05-252-0/+9
| | | | | | | | | | Reviewed by: emaste Sponsored by: DARPA, AFRL Sponsored by: HEIF5 Differential Revision: https://reviews.freebsd.org/D6559 Notes: svn path=/head/; revision=300675
* elftoolchain: backwards compatability for EM_IAMCU definitionEd Maste2016-05-201-0/+5
| | | | | | | It is not provided by sys/elf_common.h on older stable/10. Notes: svn path=/head/; revision=300320
* Update to ELF Tool Chain r3475Ed Maste2016-05-202-41/+67
| | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=300311
* libdwarf: fix SHT_REL relocation processingEd Maste2016-03-111-3/+12
| | | | | | | | | | Relocation of type SHT_REL must use the current value as addend. PR: 204084 Obtained from: NetBSD libdwarf_elf_init.c v1.4 Notes: svn path=/head/; revision=296663
* Update ELF Tool Chain to upstream rev 3400Ed Maste2016-02-126-16/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=295577
* Update to ELF Tool Chain r3250Ed Maste2015-10-091-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=289071
* Fix endless recursion in dwarf_get_section_max_offsets(), found by clangDimitry Andric2015-06-231-2/+2
| | | | | | | | | 3.7.0. Reviewed by: emaste Notes: svn path=/head/; revision=284721
* Update to ELF Tool Chain r3223Ed Maste2015-05-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=283616
* Update to ELF Tool Chain r3197Ed Maste2015-05-1416-38/+39
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=282918
* Update elftoolchain to upstream revision 3179Ed Maste2015-04-013-5/+12
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=280932
* Update elftoolchain to upstream revision 3163Ed Maste2015-02-1713-15/+15
| | | | | | | | | | Most of our changes have now been committed upstream, so this change is largely bookkeeping. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=278904
* libdwarf: Handle .rel relocationsEd Maste2015-02-125-33/+50
| | | | | | | | | | | | | | | | Some architectures use .rel relocations (for debug data), so they must be handled. This was discovered from ctfconvert on ARM object files. The lack of relocation handling caused all string lookups to return the string at offset 0 in .debug_str, typically "FreeBSD clang version ..." Reviewed by: gnn, imp, rpaulo (earlier version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D1819 Notes: svn path=/head/; revision=278611
* libdwarf: Add symbol value when processing .rela relocationsEd Maste2015-02-111-2/+6
| | | | | | | | | Reviewed by: kib, rpaulo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D1826 Notes: svn path=/head/; revision=278593
* libdwarf: Add aarch64 relocation supportEd Maste2015-02-112-0/+9
| | | | | | | | | Reviewed by: andrew, rpaulo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D1817 Notes: svn path=/head/; revision=278580
* libdwarf: add missing breakEd Maste2015-01-131-0/+1
| | | | | | | | | | Reported by: Coverity CID: 1193315 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=277133
* Update elftoolchain to upstream rev 3136Ed Maste2014-12-303-11/+9
| | | | | | | | | | | | | | | This fixes two strip(1) issues found during ports exp-run and adds a string hash implementation which significantly speeds up certain operations on objects with large numbers of symbols. This also improves libdwarf handling for stripped objects with .eh_frame or .debug_frame (but not other debug) sections. PR: 196107 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=276398
* Update elftoolchain to upstream rev 3130Ed Maste2014-12-2939-502/+1829
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes a number of libdwarf improvements (particularly DWARF4 related) and updates to elftoolchain tools such as strip(1). It also includes a large number of miscellaneous fixes (memory leaks, sign and cast warnings, integer overflow and underflow, etc.). This is a merge of r276167,276170-276172 from the projects/elftoolchain-update-r3130 branch. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=276371
| * Update elftoolchain to upstream rev 3130Ed Maste2014-12-2439-502/+1829
| | | | | | | | | | | | | | | | | | This brings a number of fixes to elfcopy/strip and DWARF4 improvements. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/elftoolchain-update-r3130/; revision=276167
* | mdoc fixesBaptiste Daroussin2014-12-264-0/+4
|/ | | | Notes: svn path=/head/; revision=276251
* Remove trailing whitespace.Kai Wang2014-01-211-1/+1
| | | | Notes: svn path=/projects/elftoolchain/; revision=260989
* * Allow API dwarf_loclist_n() and dwarf_loclist() to be called withKai Wang2014-01-191-2/+27
| | | | | | | | | | attributes that have form DW_FORM_sec_offset. * If the .debug_info section conforms to DWARF4, do not allow the value of attributes with form DW_FORM_data[48] to be used as section offset. Notes: svn path=/projects/elftoolchain/; revision=260879
* Add a sanity check: The provided offset for the desired location listKai Wang2014-01-191-0/+5
| | | | | | | should not exceed the size of the .debug_loc section. Notes: svn path=/projects/elftoolchain/; revision=260878
* API dwarf_attrval_flag() should properly handle an attribute withKai Wang2014-01-182-7/+23
| | | | | | | | | | | (DWARF4) form DW_FORM_flag_present which implicitly indicates the presence of the attribute. Manual page is updated to reflect this change. Note that this was previously fixed in the old libdwarf. Notes: svn path=/projects/elftoolchain/; revision=260855
* Fix typo: the public API dwarf_child() should return DW_DLV_NO_ENTRYKai Wang2014-01-181-1/+1
| | | | | | | instead of DW_DLE_NO_ENTRY when a child DIE is not found. Notes: svn path=/projects/elftoolchain/; revision=260854
* Fix a warning in libdwarf found by -Wmissing-variable-declarations.Kai Wang2014-01-181-1/+1
| | | | Notes: svn path=/projects/elftoolchain/; revision=260853
* Copy libelf, libdwarf and common files from vendor/ to contrib/.Kai Wang2014-01-15192-0/+34871
Notes: svn path=/projects/elftoolchain/; revision=260697