aboutsummaryrefslogtreecommitdiff
path: root/contrib/elftoolchain
Commit message (Collapse)AuthorAgeFilesLines
* readelf: simplify Xen string note printingEd Maste2020-03-211-39/+32
| | | | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D24140 Notes: svn path=/head/; revision=359189
* libelftc: Fix a memory leak in cpp_demangle_read_type().Mark Johnston2020-03-201-1/+1
| | | | | | | | | CID: 1305425 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=359176
* readelf: Fix another instance of the leak mentioned in r357542.Mark Johnston2020-03-201-0/+1
| | | | | | | | | CID: 1292493 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=359175
* readelf: Avoid leaking ELF descriptors for archive entries.Mark Johnston2020-03-201-0/+1
| | | | | | | | | CID: 1292494 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=359174
* libpe: Avoid a potential use-after-free in pe_update_symtab().Mark Johnston2020-03-201-2/+2
| | | | | | | | | | | This function appears to be unused within FreeBSD and ELFToolChain. CID: 1418982 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=359173
* 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
* objcopy: add new sections also when there is no .shstrtabEd Maste2020-03-201-0/+11
| | | | | | | | | | | | | | | | | Previously objcopy (elfcopy) --add-sections inserted new sections before .shstrtab, but omitted them if there was no .shstrtab. Now, after processing existing sections add new sections if they were not yet added. PR: 241437 Reported by: arrowd Submitted by: Tiger Gao <tig@FreeBSDFoundation.org> Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23571 Notes: svn path=/head/; revision=359166
* readelf: print GNU Build-IDEd Maste2020-03-061-0/+6
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358713
* readelf: decode and print Xen ELF note stringsEd Maste2020-03-061-0/+51
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358708
* readelf: add XEN_ELFNOTE_PHYS32_ENTRY noteEd Maste2020-03-061-0/+1
| | | | | | | | | See r336469 for details. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358706
* libelf: rationalize error handling in ELF note conversionEd Maste2020-03-051-1/+1
| | | | | | | | | | | Previously _libelf_cvt_NOTE_tom (to host) returned false if a note's namesz + descsz exceeded the buffer size, while _libelf_cvt_NOTE_tof (to file) silently truncated. Return false in the latter case too. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358685
* readelf: simplify namesz / descsz checksEd Maste2020-03-041-9/+9
| | | | | | | | MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358639
* readelf: check note namesz and descszEd Maste2020-03-041-0/+8
| | | | | | | | | | | | | | Previously corrupt note namesz or descsz (perhaps caused by readelf's current lack of endian support for notes) resulted in a crash. Check that namesz and descsz do not extend beyond the end of the buffer before trying to access name and desc data. Reported by: jhb MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358637
* Reserve WXNEEDED ELF feature control flagEd Maste2020-03-041-0/+1
| | | | | | | | | | | | | | | This will be used to tag binaries that require W+X mappings, in advance of the ability to prevent W^X in mmap/mprotect. There is still some discussion about the flag's name, but the ABI won't change even if the name does (as kib pointed out in the review). Reviewed by: csjp, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D23909 Notes: svn path=/head/; revision=358631
* readelf: add PROTMAX_DISABLE and STKGAP_DISABLEEd Maste2020-03-011-0/+2
| | | | | | | | | | From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE). Commited upstream (in a slightly different form) as r3831. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=358499
* addr2line: use stdbool.h header for boolEd Maste2020-02-131-0/+1
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=357862
* addr2line: Handle DW_AT_ranges in compile unitsEd Maste2020-02-121-41/+106
| | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=357844
* elfcopy: set ELF OS/ABI field when converting from binaryEd Maste2020-02-125-2/+15
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=357826
* readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.Mark Johnston2020-02-041-0/+1
| | | | | | | | | CID: 1292493 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357542
* readelf: Fix the check for an error from realloc().Mark Johnston2020-02-041-2/+2
| | | | | | | | | | | Use err() instead of errx() while here, since realloc() sets errno. CID: 1401326 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357541
* readelf: Fix a double close of the input file.Mark Johnston2020-02-041-1/+0
| | | | | | | | | | | | The caller of dump_object() is responsible for opening the file, let it be responsible for closing too. CID: 1411588 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357540
* size: Avoid returning a stack pointer from xlatetom().Mark Johnston2020-02-041-12/+13
| | | | | | | | | | | | | The callers only check whether the returned pointer is non-NULL, so this was harmless in practice, but change the return value to guard against the issue. CID: 1411597 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357539
* elfcopy: Avoid leaking dst's fd when we fail to copy a file.Mark Johnston2020-02-041-2/+6
| | | | | | | | | | | | | We should really create the output file in the same directory as the destination file so that rename() works. This will be done in a future change as part of some work to run in capability mode. CID: 1262523 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357538
* elfcopy: Handle multiple data descriptors properly.Mark Johnston2020-02-041-1/+1
| | | | | | | | | | | | | | | The code clearly meant to resize the buffer in the case where a section was backed by multiple data descriptors. In practice this shouldn't have been a problem since libelf would return a single data descriptor for each section in a newly opened file. CID: 1262522 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357537
* libelftc: Add a missing check for an error from vector_str_init().Mark Johnston2020-02-043-8/+7
| | | | | | | | | | | While here consistently use the same spelling for such checks. CID: 1376769 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357536
* libelftc: Fix memory leaks in the C++ demanglers.Mark Johnston2020-02-042-5/+9
| | | | | | | | | CID: 1262518, 1262519, 1262520, 1262529 MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=357535
* 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
* addr2line: Avoid a name collision.Mark Johnston2020-02-031-5/+5
| | | | | | | | | | The RB_ macros define functions with a parameter named head, and gcc warns about this. MFC with: r357450 Notes: svn path=/head/; revision=357462
* addr2line: Cache CU DIEs upon a successful address lookup.Mark Johnston2020-02-031-32/+69
| | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=357450
* Update ELF Tool Chain to upstream r3769Ed Maste2019-12-0570-288/+554
| | | | | | | | | This contains many small bugfixes and documentation improvements. Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=355413
* ELF toolchain: Add PowerPC VMX and VSX note decode to readelfJustin Hibbits2019-11-191-0/+2
| | | | | | | | | | | | | Summary: A follow-on to r276634, which added the VMX note to userland cores, and r334538 for VSX notes. Copied from note_type_linux_core(). Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D22404 Notes: svn path=/head/; revision=354842
* elfcopy/strip: Ensure sections have required alignment on outputEd Maste2019-11-081-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | Object files may specify insufficient alignment on certain sections, for example due to a bug in NASM[1]. When we detect that case in elfcopy or strip, emit a warning and increase the alignment to the minimum required. The NASM bug was fixed in 2015[2], but we might as well have this fixup (and warning) in elfcopy in case we encounter such a file for any other reason. This might be reworked somewhat upstream - see ELF Tool Chain ticket 485[3]. [1] https://bugzilla.nasm.us/show_bug.cgi?id=3392307 [2] https://repo.or.cz/w/nasm.git/commit/1f0cb0f2c1ba632c0fab02424928cfb756a9160c [3] https://sourceforge.net/p/elftoolchain/tickets/485/ PR: 198611 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D2292 Notes: svn path=/head/; revision=354544
* Capsicumize nm(1).Mark Johnston2019-09-301-1/+40
| | | | | | | | | Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21107 Notes: svn path=/head/; revision=352909
* nm: Adjust argc and argv in get_opt().Mark Johnston2019-09-301-7/+9
| | | | | | | | | | | This refactoring makes it slightly easier to capsicumize nm(1). Discussed with: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=352908
* Capsicumize c++filt(1).Mark Johnston2019-09-301-0/+7
| | | | | | | | | | Reviewed by: emaste Discussed with: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21106 Notes: svn path=/head/; revision=352907
* Initialize baseaddr to suppres warning.Aleksandr Rybalko2019-09-291-0/+1
| | | | | | | Pointy hat to: ray Notes: svn path=/head/; revision=352878
* ections into expected offset in binary format.Aleksandr Rybalko2019-09-291-9/+12
| | | | | | | | | | | | | Calculate binary file offset using address field, bacause software know only offset to known data, not where to load segment. With that patch, kernel .data section can have any alignment/offset - kernel boor fine. PR: 235391 Reviewed by: markj MFC after: 1 month Differential Revision: D21827 Notes: svn path=/head/; revision=352875
* Merge r3780 from elftoolchain.Mark Johnston2019-08-071-9/+18
| | | | | | | | | | | | Adjust argc and argv by optind before using them. This slightly simplifies the code. No functional change intended. MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21079 Notes: svn path=/head/; revision=350679
* readelf: Close input files when done with them.Mark Johnston2019-08-071-2/+4
| | | | | | | | | | | | | | | The low fd limit used by poudriere exposed an odd failure mode in cap_fileargs (used by readelf as of r350516). In particular, when the limit was hit, both the main process and casper service would block on their shared socket, waiting forever for the other to send a message. Reported by: zeising MFC after: 3 days Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=350671
* Capsicumize size(1).Mark Johnston2019-08-011-20/+43
| | | | | | | | | Reviewed by: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21105 Notes: svn path=/head/; revision=350517
* Capsicumize readelf(1).Mark Johnston2019-08-011-10/+29
| | | | | | | | | Reviewed by: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21108 Notes: svn path=/head/; revision=350516
* Capsicumize addr2line(1).Mark Johnston2019-08-011-0/+13
| | | | | | | | | Reviewed by: oshogbo Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21104 Notes: svn path=/head/; revision=350515
* readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_ANDEd Maste2019-08-011-4/+69
| | | | | | | | | | | These bits are used for Intel CET IBT/Shadow Stack. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20516 Notes: svn path=/head/; revision=350511
* Merge r3778 and r3779 from ELFToolchain.Mark Johnston2019-07-292-4/+19
| | | | | | | | | | | | Modify strip(1) to not accept multiple input files when an output file is specified. There is no good way to handle this combination, and the change is compatible with binutils. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=350432
* strings: extends rightsMariusz Zaborski2019-07-161-1/+1
| | | | | | | | | The libelf is using mmap if it can, if not it was fall backing to read. Reported by: markj Notes: svn path=/head/; revision=350024
* strings: fix entering to the capability modeMariusz Zaborski2019-07-161-1/+1
| | | | | | | Reported by: markj Notes: svn path=/head/; revision=350022
* elfcopy: Clear errors after fetching the shstrtab index.Mark Johnston2019-07-041-1/+3
| | | | | | | | | | | | | | | | | | | Otherwise a future call to elf_errno() will return a non-zero value. update_shdr(), for example, treats any errors associated with the ELF descriptor as fatal. Clear the error per the first example in elf_errmsg.3. Convert to elf_getshdrstrndx() while here since elf_getshstrndx() is apparently deprecated. Reported by: royger Reviewed by: emaste MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20852 Notes: svn path=/head/; revision=349730