Bug 234949 - Strip is enormously slow when operating on Haskell binaries
Summary: Strip is enormously slow when operating on Haskell binaries
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Johnston
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2019-01-14 17:14 UTC by Gleb Popov
Modified: 2021-07-06 20:54 UTC (History)
5 users (show)

See Also:


Attachments
proposed patch (18.07 KB, patch)
2019-05-27 04:51 UTC, Mark Johnston
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Popov freebsd_committer freebsd_triage 2019-01-14 17:14:19 UTC
Somewhere since 12.0-CURRENT, strip started to take much longer when working on Haskell static libraries. This makes `install` stage of GHC take about 10 mins on my machine.

Steps to reproduce:

# fetch http://distcache.FreeBSD.org/local-distfiles/arrowd/stack-bindists/ghc-8.6.2-x86_64-portbld-freebsd.tar.xz
# tar -xzf ghc-8.6.2-x86_64-portbld-freebsd.tar.xz
# /usr/bin/time -h /usr/bin/strip ghc-8.6.2/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1.a
        1m12,41s real           1m12,24s user           0,14s sys
# /usr/bin/time -h /usr/bin/strip ghc-8.6.2/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1_p.a
        4m2,88s real            4m2,43s user            0,36s sys
Comment 1 Ed Maste freebsd_committer freebsd_triage 2019-01-14 18:21:38 UTC
I'm not quite sure what you mean by "Somewhere since 12.0-CURRENT"; could you describe the pre-slowdown FreeBSD version in more detail?

As a reference point my laptop has a -CURRENT kernel from end of April 2018 and with your first example strip took:

1m53.95s real           1m51.04s user           0.57s sys

GNU strip from binutils 2.30_7,1 took:

4.31s real              0.96s user              3.31s sys

(Note output was to /dev/null with our strip, and an actual tempfile with GNU strip as -o /dev/null failed.)
Comment 2 Gleb Popov freebsd_committer freebsd_triage 2019-01-14 18:43:48 UTC
(In reply to Ed Maste from comment #1)
I'm nut quite sure, maybe spring, maybe summer. Did we switch strip from some old implementation to elftoolchain one somewhere in this time span?
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-01-16 08:04:42 UTC
A commit references this bug:

Author: arrowd
Date: Wed Jan 16 08:04:04 UTC 2019
New revision: 490456
URL: https://svnweb.freebsd.org/changeset/ports/490456

Log:
  lang/ghc: Since we already depend on binutils on ARM, use their strip, because our strip is incredibly slow.

  PR:		234949
  Submitted by:	Mikael Urankar <mikael.urankar@gmail.com>
  Approved by:	tcberner (mentor)
  Differential Revision:	https://reviews.freebsd.org/D18842

Changes:
  head/lang/ghc/bsd.ghc.mk
Comment 4 Ed Maste freebsd_committer freebsd_triage 2019-01-16 15:17:42 UTC
(In reply to Gleb Popov from comment #2)
We've been using ELF Tool Chain's elfcopy as objcopy/strip since FreeBSD 11. An option existed to revert to GNU objcopy/strip (WITHOUT_ELFCOPY_AS_OBJCOPY) but it was removed in r306649. So if this started in spring/summer 2018 then it appears to be an ELF Tool Chain regression.
Comment 5 Gleb Popov freebsd_committer freebsd_triage 2019-05-19 18:10:05 UTC
I compiled strip from elftoolchain upstream and ran it under google-perftools.

Results are here:
http://arrowd.name/strip.prof.1.ps
http://arrowd.name/strip.prof.2.ps

Most of time (53%) is spent in elf_getscn() function.
Comment 6 Ed Maste freebsd_committer freebsd_triage 2019-05-20 20:26:28 UTC
in elf_getscn:

   151          STAILQ_FOREACH(s, &e->e_u.e_elf.e_scn, s_next)
   152                  if (s->s_ndx == index)
   153                          return (s);

Well, there's your problem... (or at least a big part of the problem)
Comment 7 Gleb Popov freebsd_committer freebsd_triage 2019-05-21 05:40:32 UTC
(In reply to Ed Maste from comment #6)
By saying "your problem", you mean that I should go report it upstream? Who should fix this?
Comment 8 Ed Maste freebsd_committer freebsd_triage 2019-05-21 15:40:09 UTC
(In reply to Gleb Popov from comment #7)
Sorry, "Well, there's your problem" is a quote originally from the Mythbusters TV show; here it is commentary on the linked list traversal in elf_getscn.  You could submit a ticket on https://sourceforge.net/p/elftoolchain/ but we could just make a change in FreeBSD under this PR 234949 and then upstream it.
Comment 9 Steve Wills freebsd_committer freebsd_triage 2019-05-26 21:06:22 UTC
I'm seeing this as well. What's the status of this issue? Waiting on a patch?
Comment 10 Mark Johnston freebsd_committer freebsd_triage 2019-05-26 22:10:12 UTC
(In reply to Ed Maste from comment #6)
I tried replacing the section list with a red-black tree, ordered by section index.  It reduced the runtime of "strip libHSCabal-2.4.0.1.a" from 1m20s to 52s, so this isn't the only problem.

From reading the elfcopy code, it looks like the strip implementation is just naive.  We copy each elf file in the archive into a temp archive, during which strip does its filtering, and finally rename the tempfile over the original.  So even if strip has nothing to do, it ends up doing a lot of work.
Comment 11 Mark Johnston freebsd_committer freebsd_triage 2019-05-26 22:35:02 UTC
(In reply to Mark Johnston from comment #10)
Hmm, GNU strip seems to do something similar, but manages to be much faster.

Some profiling points at nested loops in create_scn->is_remove_reloc_scn().  Changing is_remove_reloc_scn() to use elf_getscn() instead of searching the section list gets me down to 38s.

Profiling also points at insert_to_sec_list(), which would appear to benefit from a binary search tree as well.
Comment 12 Mark Johnston freebsd_committer freebsd_triage 2019-05-26 23:31:56 UTC
It looks like most of the rest of the slowdown comes from inefficient implementations in insert_to_strtab() and lookup_string().  The latter can be replaced with memmem(), which helps a bit.  In a lot of cases when we call lookup_string() we should in principle be able to reuse the shstrtab index from the old section and thus avoid the lookup entirely.  However, insert_to_strtab() may modify the table in place if it finds a string in the table that is a suffix of the string to be inserted.
Comment 13 Mark Johnston freebsd_committer freebsd_triage 2019-05-27 04:51:44 UTC
Created attachment 204641 [details]
proposed patch

It turns out that libelftc provides some ELF string table routines which are more efficient than what strip uses today.  With all of my diffs combined I get:

> time strip ghc-8.6.2/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1.a

real    0m6.817s
user    0m6.428s
sys     0m0.135s
> time strip ghc-8.6.2/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1_p.a

real    0m8.674s
user    0m8.185s
sys     0m0.155s

vs. GNU strip:

> time /usr/local/bin/strip ghc-8.6.2/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1.a

real    0m2.671s
user    0m2.334s
sys     0m0.245s

> time /usr/local/bin/strip ghc-8.6.2/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1_p.a

real    0m4.161s
user    0m3.599s
sys     0m0.351s

So there's clearly still room for improvement.

I did not test my changes extensively yet, but I attached a combined patch if anyone else is interested in testing them with ports builds.
Comment 14 Mark Johnston freebsd_committer freebsd_triage 2019-05-27 05:02:40 UTC
I should note that elftc_string_table does not do suffix matching, unlike the implementation in strip.  However in this case we're only dealing with the section name string table, where this kind of optimization is not important.
Comment 15 commit-hook freebsd_committer freebsd_triage 2019-05-30 15:29:42 UTC
A commit references this bug:

Author: markj
Date: Thu May 30 15:28:49 UTC 2019
New revision: 348431
URL: https://svnweb.freebsd.org/changeset/base/348431

Log:
  elfcopy: Optimize for insertions at the end of the section list.

  This is the common case when strip(1) is creating the output file.
  The change provides a significant speedup when running on ELF files with
  many sections.

  PR:		234949
  Reviewed by:	emaste
  MFC after:	1 week
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20444

Changes:
  head/contrib/elftoolchain/elfcopy/elfcopy.h
  head/contrib/elftoolchain/elfcopy/sections.c
Comment 16 Gleb Popov freebsd_committer freebsd_triage 2019-06-01 09:04:23 UTC
I can confirm that last commit improved things a bit:

# /usr/bin/time -h /usr/bin/strip ghc-8.6.4/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1.a
        59,70s real             59,53s user             0,16s sys
# /usr/bin/time -h /usr/bin/strip ghc-8.6.4/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1_p.a 
        3m17,14s real           3m16,82s user           0,29s sys
Comment 18 commit-hook freebsd_committer freebsd_triage 2019-06-04 18:27:01 UTC
A commit references this bug:

Author: markj
Date: Tue Jun  4 18:26:31 UTC 2019
New revision: 348652
URL: https://svnweb.freebsd.org/changeset/base/348652

Log:
  libelf: Use a red-black tree to manage the section list.

  The tree is indexed by section number.  This speeds up elf_getscn()
  and its callers, which previously had to traverse a linked list. In
  particular, since .shstrtab is often the last section in a file,
  elf_strptr() would have to traverse the entire list.

  PR:		234949
  Reviewed by:	emaste
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20443

Changes:
  head/contrib/elftoolchain/libelf/_libelf.h
  head/contrib/elftoolchain/libelf/elf_end.c
  head/contrib/elftoolchain/libelf/elf_scn.c
  head/contrib/elftoolchain/libelf/elf_update.c
  head/contrib/elftoolchain/libelf/libelf_allocate.c
  head/contrib/elftoolchain/libelf/libelf_ehdr.c
  head/contrib/elftoolchain/libelf/libelf_extended.c
Comment 19 commit-hook freebsd_committer freebsd_triage 2019-06-04 18:30:09 UTC
A commit references this bug:

Author: markj
Date: Tue Jun  4 18:29:09 UTC 2019
New revision: 348654
URL: https://svnweb.freebsd.org/changeset/base/348654

Log:
  elfcopy: Use elf_getscn() instead of iterating over all sections.

  When removing a section, we would loop over all sections looking for
  a corresponding relocation section.  With r348652 it is much faster
  to just use elf_getscn().

  PR:		234949
  Reviewed by:	emaste
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20471

Changes:
  head/contrib/elftoolchain/elfcopy/sections.c
Comment 20 commit-hook freebsd_committer freebsd_triage 2019-06-04 18:34:35 UTC
A commit references this bug:

Author: markj
Date: Tue Jun  4 18:34:06 UTC 2019
New revision: 348657
URL: https://svnweb.freebsd.org/changeset/base/348657

Log:
  elfcopy: Use libelftc's string table routines to build .shstrtab.

  This replaces some hand-rolled routines and is substantially faster
  since libelftc uses a hash table for lookups and insertions, whereas
  elfcopy would perform a linear scan of the table.

  PR:		234949
  Reviewed by:	emaste
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20473

Changes:
  head/contrib/elftoolchain/elfcopy/ascii.c
  head/contrib/elftoolchain/elfcopy/binary.c
  head/contrib/elftoolchain/elfcopy/elfcopy.h
  head/contrib/elftoolchain/elfcopy/main.c
  head/contrib/elftoolchain/elfcopy/sections.c
Comment 21 Ed Maste freebsd_committer freebsd_triage 2019-06-06 01:54:08 UTC
arrowd@, can you try again now that the changes have been committed?
Comment 22 commit-hook freebsd_committer freebsd_triage 2019-06-06 03:04:31 UTC
A commit references this bug:

Author: markj
Date: Thu Jun  6 03:03:55 UTC 2019
New revision: 348720
URL: https://svnweb.freebsd.org/changeset/base/348720

Log:
  MFC r348431:
  elfcopy: Optimize for insertions at the end of the section list.

  PR:	234949

Changes:
_U  stable/12/
  stable/12/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/12/contrib/elftoolchain/elfcopy/sections.c
Comment 23 Gleb Popov freebsd_committer freebsd_triage 2019-06-06 08:20:45 UTC
(In reply to Ed Maste from comment #21)


Much better:

# /usr/bin/time -h /usr/bin/strip ghc-8.6.5/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1.a
        37,35s real             37,11s user             0,23s sys
# /usr/bin/time -h /usr/bin/strip ghc-8.6.5/libraries/Cabal/Cabal/dist-install/build/libHSCabal-2.4.0.1_p.a
        2m12,54s real           2m12,21s user           0,32s sys
Comment 24 Mark Johnston freebsd_committer freebsd_triage 2019-06-06 14:46:59 UTC
(In reply to Gleb Popov from comment #23)
Err, it should be much better than that.  What revision are you running?
Comment 25 Gleb Popov freebsd_committer freebsd_triage 2019-06-06 14:57:05 UTC
(In reply to Mark Johnston from comment #24)

I've done svn update only for /contrib/elftoolchain:

# cd /usr/src
# svn info
Path: .
Working Copy Root Path: /usr/src
URL: svn+ssh://repo.freebsd.org/base/head
Relative URL: ^/head
Repository Root: svn+ssh://repo.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 346440
Node Kind: directory
Schedule: normal
Last Changed Author: markj
Last Changed Rev: 346440
Last Changed Date: 2019-04-20 15:34:53 +0400 (сб, 20 апр. 2019)

# cd contrib/elftoolchain/
# svn info
Path: .
Working Copy Root Path: /usr/src
URL: svn+ssh://repo.freebsd.org/base/head/contrib/elftoolchain
Relative URL: ^/head/contrib/elftoolchain
Repository Root: svn+ssh://repo.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 348728
Node Kind: directory
Schedule: normal
Last Changed Author: markj
Last Changed Rev: 348657
Last Changed Date: 2019-06-04 22:34:05 +0400 (вт, 04 июня 2019)
Comment 26 Mark Johnston freebsd_committer freebsd_triage 2019-06-06 15:00:19 UTC
(In reply to Gleb Popov from comment #25)
Did you rebuild both strip and libelf?
Comment 27 Gleb Popov freebsd_committer freebsd_triage 2019-06-06 15:01:36 UTC
(In reply to Mark Johnston from comment #26)
Ah, sorry. I only did

# make -C /usr/src/usr.bin/objcopy install

Do I need something else?
Comment 28 Mark Johnston freebsd_committer freebsd_triage 2019-06-06 15:02:05 UTC
(In reply to Gleb Popov from comment #27)
Try also rebuilding lib/libelf.
Comment 29 Gleb Popov freebsd_committer freebsd_triage 2019-06-06 15:04:02 UTC
Yep, that helped. Now stripping _p version of the library takes only

11,16s real             10,85s user             0,29s sys

Awesome! Thanks for fixing this.
Comment 30 Mark Johnston freebsd_committer freebsd_triage 2019-06-06 15:12:06 UTC
(In reply to Gleb Popov from comment #29)
Hmm, we can do even better.  In r348657 I did not specify a hint for the number of hash table entries: the elftc code automatically resizes the hash table.  I think it's a bit conservative in how it does that though; if I do

diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c
index 93dbf4422863..25f3c8c0bac8 100644
--- a/contrib/elftoolchain/elfcopy/sections.c
+++ b/contrib/elftoolchain/elfcopy/sections.c
@@ -1410,7 +1410,7 @@ init_shstrtab(struct elfcopy *ecp)
        s->loadable = 0;
        s->type = SHT_STRTAB;
        s->vma = 0;
-       s->strtab = elftc_string_table_create(0);
+       s->strtab = elftc_string_table_create(1024 * 1024);
 
        add_to_shstrtab(ecp, "");
        add_to_shstrtab(ecp, ".symtab");

then the runtime drops further.  (And we end up being slightly faster than GNU strip on the _p library.)
Comment 31 Mark Johnston freebsd_committer freebsd_triage 2019-06-06 21:23:00 UTC
https://reviews.freebsd.org/D20544
Comment 32 commit-hook freebsd_committer freebsd_triage 2019-06-18 16:29:57 UTC
A commit references this bug:

Author: markj
Date: Tue Jun 18 16:29:48 UTC 2019
New revision: 349171
URL: https://svnweb.freebsd.org/changeset/base/349171

Log:
  MFC r348652:
  libelf: Use a red-black tree to manage the section list.

  PR:	234949

Changes:
_U  stable/12/
  stable/12/contrib/elftoolchain/libelf/_libelf.h
  stable/12/contrib/elftoolchain/libelf/elf_end.c
  stable/12/contrib/elftoolchain/libelf/elf_scn.c
  stable/12/contrib/elftoolchain/libelf/elf_update.c
  stable/12/contrib/elftoolchain/libelf/libelf_allocate.c
  stable/12/contrib/elftoolchain/libelf/libelf_ehdr.c
  stable/12/contrib/elftoolchain/libelf/libelf_extended.c
Comment 33 commit-hook freebsd_committer freebsd_triage 2019-06-18 16:31:00 UTC
A commit references this bug:

Author: markj
Date: Tue Jun 18 16:30:35 UTC 2019
New revision: 349172
URL: https://svnweb.freebsd.org/changeset/base/349172

Log:
  MFC r348654:
  elfcopy: Use elf_getscn() instead of iterating over all sections.

  PR:	234949

Changes:
_U  stable/12/
  stable/12/contrib/elftoolchain/elfcopy/sections.c
Comment 34 commit-hook freebsd_committer freebsd_triage 2019-06-18 16:32:03 UTC
A commit references this bug:

Author: markj
Date: Tue Jun 18 16:31:07 UTC 2019
New revision: 349173
URL: https://svnweb.freebsd.org/changeset/base/349173

Log:
  MFC r348657:
  elfcopy: Use libelftc's string table routines to build .shstrtab.

  PR:	234949

Changes:
_U  stable/12/
  stable/12/contrib/elftoolchain/elfcopy/ascii.c
  stable/12/contrib/elftoolchain/elfcopy/binary.c
  stable/12/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/12/contrib/elftoolchain/elfcopy/main.c
  stable/12/contrib/elftoolchain/elfcopy/sections.c
Comment 35 Mark Johnston freebsd_committer freebsd_triage 2019-06-26 16:43:15 UTC
Closing since this seems to be sufficiently addressed by my testing, and I've merged the changes to stable/12.  Please reopen if you disagree.
Comment 36 commit-hook freebsd_committer freebsd_triage 2020-11-07 23:58:16 UTC
A commit references this bug:

Author: dim
Date: Sat Nov  7 23:58:00 UTC 2020
New revision: 367466
URL: https://svnweb.freebsd.org/changeset/base/367466

Log:
  Sync up elftoolchain with head, except for the capsicum-related commits,
  which are incompatible with stable/11.

  MFC r308465 (by emaste):

  c++filt: flush output after newline

  Some tools spawn c++filt and pass it a single line at a time for
  demangling. This is akin to r276689 for addr2line.

  Sponsored by:	The FreeBSD Foundation

  MFC r317626 (by emaste):

  revert r308465: c++filt: flush output after newline

  The ELF Tool Chain update to r3520 uses setvbuf to set line buffering.

  Sponsored by:	The FreeBSD Foundation

  MFC r340746 (by oshogbo):

  strings: fix style nits

  Reviewed by:	cem, emaste, Joseph Koshy <jkoshy@users.sourceforge.net>
  Differential Revision:	https://reviews.freebsd.org/D18036

  MFC r340750 (by mjg):

  strings: unbreak the build after r340746

  Discussed with:	oshogbo
  Sponsored by:	The FreeBSD Foundation

  MFC r342918 (by emaste):

  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

  MFC r343592 (by emaste):

  readelf: decode flag bits in DT_FLAGS/DT_FLAGS_1

  Decode d_val when the tag is DT_FLAGS or DT_FLAGS_1 based on the
  information at:

  https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html

  PR:		232983
  Submitted by:	Bora Ozarslan borako.ozarslan@gmail.com
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D18784

  MFC r343593 (by emaste):

  readelf: fix i386 build

  Use %jx and (uintmax_t) cast.

  PR:		232983
  Sponsored by:	The FreeBSD Foundation

  MFC r343614 (by emaste):

  readelf: dump elf note data

  Output format is compatible with GNU readelf's handling of unknown note
  types (modulo a GNU char signedness bug); future changes will add type-
  specific decoding.

  Reviewed by:	kib
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation

  MFC r343665 (by emaste):

  readelf: use table-based DT_FLAGS and DT_FLAGS_1 decoding

  Fewer lines of code and more maintainable.

  Reviewed by:	brooks, kib
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19053

  MFC r343669 (by emaste):

  readelf: decode FreeBSD note types

  Decode NT_FREEBSD_ABI_TAG, NT_FREEBSD_ARCH_TAG, and NT_FREEBSD_FEATURE_CTL.

  Reviewed by:	brooks, kib (earlier)
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19054

  MFC r345360 (by oshogbo):

  strings: do not depend on stdin

  Instead of depending on one stdin FILE structure and use freopen(3), pass to
  the functions appropriate FILE structure.

  Reviewed by:	cem
  Discussed with:	emaste
  Differential Revision:	https://reviews.freebsd.org/D18037

  MFC r345361 (by oshogbo):

  strings: do not continue if getc or getcharacter returns EOF

  Reported by:	cem

  MFC r345362 (by oshogbo):

  Fix powerpc and arm builds after r345361.

  Reported by:	jenkins

  MFC r345364 (by oshogbo):

  In case of ENCODING_8BIT the EOF code will be pass to putchar.
  EOF check should be done before (uint8_t)c > 127 test.

  Reported by:	cem

  MFC r345431 (by oshogbo):

  strings: return an error code and the char value separately

  If we returning 32 bits value it's hard to distinguish if the returned value
  is a valid one or if its an error (in case of EOF). For that reason separate
  exit code of the function from the returned character.

  Reported by:	cem, se

  MFC r345593 (by markj):

  Prepend DW_AT_comp_dir to relative line number directory table entries.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19705

  MFC r345646 (by emaste):

  readelf: add newline after dumping dynamic FLAGS / FLAGS_1

  All three dump_flags() callers need a newline after printing the flags.

  Sponsored by:	The FreeBSD Foundation

  MFC r346323 (by emaste):

  readelf: speed up readelf -wo

  Use an array instead of STAILQ, and sort at the end instead of while
  adding new elements.

  PR:		212539
  Submitted by:	Bora ?zarslan <borako.ozarslan@gmail.com>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation

  MFC r346327 (by emaste):

  readelf: use size_t for object counts

  PR:		212539
  Reported by:	cem
  Sponsored by:	The FreeBSD Foundation

  MFC r348347 (by jhibbits):

  Add missing powerpc64 relocation support to libdwarf

  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

  MFC r348430 (by markj):

  elfcopy: Remove an unneeded memset.

  Reviewed by:	emaste, trasz
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20445

  MFC r348431 (by markj):

  elfcopy: Optimize for insertions at the end of the section list.

  This is the common case when strip(1) is creating the output file.
  The change provides a significant speedup when running on ELF files with
  many sections.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20444

  MFC r348443 (by markj):

  readelf: Make -t imply -S, for compatibility with GNU binutils.

  Reported by:	jhb
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20475

  MFC r348444 (by markj):

  libelftc: Add MLINKS.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20474

  MFC r348652 (by markj):

  libelf: Use a red-black tree to manage the section list.

  The tree is indexed by section number.  This speeds up elf_getscn()
  and its callers, which previously had to traverse a linked list. In
  particular, since .shstrtab is often the last section in a file,
  elf_strptr() would have to traverse the entire list.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20443

  MFC r348654 (by markj):

  elfcopy: Use elf_getscn() instead of iterating over all sections.

  When removing a section, we would loop over all sections looking for
  a corresponding relocation section.  With r348652 it is much faster
  to just use elf_getscn().

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20471

  MFC r348655 (by markj):

  libelftc: Fix some minor style bugs.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20472

  MFC r348657 (by markj):

  elfcopy: Use libelftc's string table routines to build .shstrtab.

  This replaces some hand-rolled routines and is substantially faster
  since libelftc uses a hash table for lookups and insertions, whereas
  elfcopy would perform a linear scan of the table.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20473

  MFC r348776 (by csjp):

  Teach readelf about some OpenBSD ELF program headers

  - Add constants for OpenBSD wxneeded, bootdata and randomize to the
    FreeBSD elf_common.h file. This is the file that gets used by the
    elftoolchain library.
  - Update readelf and elfdump utilities to decode these program headers
    if they are encountered.

  Note: FreeBSD has it's own version of elfdump(1), which will be updated
  in a subsequent commit. I am adding it here anyway because this diff is
  going to be submitted upstream.

  Discussed with:	emaste
  Reviewed by:	imp
  Differential Revision:	https://reviews.freebsd.org/D20548

  MFC r349420 (by markj):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20760

  MFC r349421 (by markj):

  libelftc: Consistently use size_t for string table offsets and sizes.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20702

  MFC r349422 (by markj):

  libelftc: Fix the documented prototype for elftc_string_table_destroy().

  Sponsored by:	The FreeBSD Foundation

  MFC r349423 (by markj):

  elfcopy: Provide a size hint when creating the section string table.

  Use the input file's .shstrtab size as the hint if it exists.  This
  gives a small performance improvement when processing files with
  many sections.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20544

  MFC r349424 (by markj):

  libdwarf: Use the cached strtab pointer when reading string attributes.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20759

  MFC r349481 (by mhorne):

  Add some missing RISC-V ELF defines

  This adds defines for the RISC-V specific e_flags values, and some of
  the missing static relocations.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20766

  MFC r349482 (by mhorne):

  readelf: Add support for RISC-V specific e_flags

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20767

  MFC r349483 (by mhorne):

  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)
  Differential Revision:	https://reviews.freebsd.org/D20768

  MFC r349510 (by luporl):

  [PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)

  This prints out description text with the meaning of 'Flags' value in PowerPC64.

  Example:

  $ readelf -h ~/tmp/t1-Flag2
  ELF Header:

  Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           PowerPC 64-bit
  Version:                           0x1
  Entry point address:               0x10010000
  Start of program headers:          64 (bytes into file)
  Start of section headers:          209368 (bytes into file)
  Flags:                             0x2, OpenPOWER ELF V2 ABI
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         10
  Size of section headers:           64 (bytes)
  Number of section headers:         34
  Section header string table index: 31

  Submitted by:	 alfredo.junior_eldorado.org.br
  Reviewed by:	luporl
  Differential Revision:	https://reviews.freebsd.org/D20782

  MFC r349562 (by mhorne):

  elftoolchain: fix an incorrect e_flags description

  r349482 introduced the definitions and descriptions of the RISC-V
  specific e_flags values to elftoolchain. However, the description for
  the EF_RISCV_RVE flag was incorrectly duplicated from EF_RISCV_RVC. Fix
  this by providing the proper description for this flag.

  Reported by:	jhb
  Approved by:	markj (mentor)

  MFC r349563 (by mhorne):

  readelf: Add RISC-V DWARF register aliases

  This allows DWARF debugging output to use the common register
  mneumonics, such as ra, sp, or t0.

  DWARF registers 0-31 are mapped to the 32 general purpose registers,
  which are then followed by the 32 floating point registers.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20779

  MFC r349577 (by arichardson):

  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

  MFC r349730 (by markj):

  elfcopy: Clear errors after fetching the shstrtab index.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20852

  MFC r350432 (by markj):

  Merge r3778 and r3779 from ELFToolchain.

  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.

  Sponsored by:	The FreeBSD Foundation

  MFC r350511 (by emaste):

  readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND

  These bits are used for Intel CET IBT/Shadow Stack.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20516

  MFC r350679 (by markj):

  Merge r3780 from elftoolchain.

  Adjust argc and argv by optind before using them.  This slightly
  simplifies the code.  No functional change intended.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21079

  MFC r352875 (by ray):

  ections into expected offset in binary format.
  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
  Differential Revision:	D21827

  MFC r352878 (by ray):

  Initialize baseaddr to suppres warning.

  Pointy hat to:	ray

  MFC r352908 (by markj):

  nm: Adjust argc and argv in get_opt().

  This refactoring makes it slightly easier to capsicumize nm(1).

  Discussed with:	emaste
  Sponsored by:	The FreeBSD Foundation

  MFC r354544 (by emaste):

  elfcopy/strip: Ensure sections have required alignment on output

  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

  MFC r354842 (by jhibbits):

  ELF toolchain: Add PowerPC VMX and VSX note decode to readelf

  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

  MFC r355413 (by emaste):

  Update ELF Tool Chain to upstream r3769

  This contains many small bugfixes and documentation improvements.

  Sponsored by:	The FreeBSD Foundation

  MFC r357450 (by markj):

  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>
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23418

  MFC r357462 (by markj):

  addr2line: Avoid a name collision.

  The RB_ macros define functions with a parameter named head, and gcc
  warns about this.

  MFC r357531 (by markj):

  libdwarf: Remove unnecessary NULL checks.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357532 (by markj):

  libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().

  CID:		1193364
  Sponsored by:	The FreeBSD Foundation

  MFC r357533 (by markj):

  libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357534 (by markj):

  libdwarf: Fix a memory leak in _dwarf_frame_section_init().

  If frame length validation failed we would leak memory.

  CID:		1193366
  Sponsored by:	The FreeBSD Foundation

  MFC r357535 (by markj):

  libelftc: Fix memory leaks in the C++ demanglers.

  CID:		1262518, 1262519, 1262520, 1262529
  Sponsored by:	The FreeBSD Foundation

  MFC r357536 (by markj):

  libelftc: Add a missing check for an error from vector_str_init().

  While here consistently use the same spelling for such checks.

  CID:		1376769
  Sponsored by:	The FreeBSD Foundation

  MFC r357537 (by markj):

  elfcopy: Handle multiple data descriptors properly.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357538 (by markj):

  elfcopy: Avoid leaking dst's fd when we fail to copy a file.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357539 (by markj):

  size: Avoid returning a stack pointer from xlatetom().

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357540 (by markj):

  readelf: Fix a double close of the input file.

  The caller of dump_object() is responsible for opening the file, let it
  be responsible for closing too.

  CID:		1411588
  Sponsored by:	The FreeBSD Foundation

  MFC r357541 (by markj):

  readelf: Fix the check for an error from realloc().

  Use err() instead of errx() while here, since realloc() sets errno.

  CID:		1401326
  Sponsored by:	The FreeBSD Foundation

  MFC r357542 (by markj):

  readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r357826 (by emaste):

  elfcopy: set ELF OS/ABI field when converting from binary

  PR:		228934
  Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
  Reviewed by:	markj, jkoshy
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23504

  MFC r357844 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23501

  MFC r357862 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358499 (by emaste):

  readelf: add PROTMAX_DISABLE and STKGAP_DISABLE

  From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE).  Commited
  upstream (in a slightly different form) as r3831.

  Sponsored by:	The FreeBSD Foundation

  MFC r358631 (by emaste):

  Reserve WXNEEDED ELF feature control flag

  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

  MFC r358637 (by emaste):

  readelf: check note namesz and descsz

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358639 (by emaste):

  readelf: simplify namesz / descsz checks

  Sponsored by:	The FreeBSD Foundation

  MFC r358685 (by emaste):

  libelf: rationalize error handling in ELF note conversion

  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

  MFC r358706 (by emaste):

  readelf: add XEN_ELFNOTE_PHYS32_ENTRY note

  See r336469 for details.

  Sponsored by:	The FreeBSD Foundation

  MFC r358708 (by emaste):

  readelf: decode and print Xen ELF note strings

  Sponsored by:	The FreeBSD Foundation

  MFC r358713 (by emaste):

  readelf: print GNU Build-ID

  Sponsored by:	The FreeBSD Foundation

  MFC r358778 (by emaste):

  readelf: hoist file opening out of dump_object

  Diff reduction with HEAD to facilitate other MFCs.

  MFC r359166 (by emaste):

  objcopy: add new sections also when there is no .shstrtab

  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

  MFC r359172 (by markj):

  libdwarf: Make an out-pointer assignment unconditional.

  There is no reason for diep to ever be NULL, since in that case we would
  simply be leaking memory.

  CID:		1418801
  Sponsored by:	The FreeBSD Foundation

  MFC r359173 (by markj):

  libpe: Avoid a potential use-after-free in pe_update_symtab().

  This function appears to be unused within FreeBSD and ELFToolChain.

  CID:		1418982
  Sponsored by:	The FreeBSD Foundation

  MFC r359174 (by markj):

  readelf: Avoid leaking ELF descriptors for archive entries.

  CID:		1292494
  Sponsored by:	The FreeBSD Foundation

  MFC r359175 (by markj):

  readelf: Fix another instance of the leak mentioned in r357542.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r359176 (by markj):

  libelftc: Fix a memory leak in cpp_demangle_read_type().

  CID:		1305425
  Sponsored by:	The FreeBSD Foundation

  MFC r359189 (by emaste):

  readelf: simplify Xen string note printing

  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24140

  MFC r361104 (by jhibbits):

  elftoolchain: Add powerpc64 definition to elftoolchain config

  powerpc is already in place, but powerpc64 is needed separately.

  MFC r361662 (by emaste):

  readelf: add more DT_FLAGS_1 flags

  Reference:
  https://docs.oracle.com/cd/E36784_01/html/E36857/chapter6-42444.html

  > DF_1_SINGLETON  Singleton symbols exist.
  > DF_1_STUB       Object is a stub.
  > DF_1_PIE        Object is a position-independent executable.

  Sponsored by:	The FreeBSD Foundation

  MFC r365489 (by bdragon):

  [PowerPC64LE] PPC64LE support for libelf.

  Fix native detection when building on powerpc64le.

  I will be submitting this and r361104 upstream shortly.

  Sponsored by:	Tag1 Consulting, Inc.

  MFC r366977 (by emaste):

  libelf: add compression header support

  GNU and Oracle libelf implementations added support for section
  compression, intended to reduce the size of DWARF debug info (which
  might be an order of magnitude larger than the code).

  There are two compressed ELF section formats:

  1. Old GNU - sections are renmaed to start with 'z'.  Section contains
     a magic number, uncompressed size, and compressed data.

  2. Oracle and New GNU - compressed sections use the SHF_COMPRESSED flag.
     The compression header contains the compression type, uncompressed
     size, and uncompressed alignment.

  The second style is preferred and this change implements only that one.

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24566

  MFC r367209 (by emaste):

  readelf: Add -z decompression support

  Compatible with GNU readelf, -z decompresses sections displayed by
  -x or -p.

  ELF Tool Chain ticket #555
  https://sourceforge.net/p/elftoolchain/tickets/555/

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:    https://reviews.freebsd.org/D26909

  MFC r367238 (by bdragon):

  Fix 32-bit build after r367209

  Fix build on systems with a 32-bit size_t.

  Since it's being passed as a pointer, a 64-bit write to it will overflow.

  MFC r367322 (by dim):

  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

Changes:
_U  stable/11/
  stable/11/contrib/elftoolchain/.cirrus.yml
  stable/11/contrib/elftoolchain/README.rst
  stable/11/contrib/elftoolchain/addr2line/addr2line.1
  stable/11/contrib/elftoolchain/addr2line/addr2line.c
  stable/11/contrib/elftoolchain/ar/ar.1
  stable/11/contrib/elftoolchain/ar/ar.5
  stable/11/contrib/elftoolchain/ar/ar.c
  stable/11/contrib/elftoolchain/ar/ar.h
  stable/11/contrib/elftoolchain/ar/ranlib.1
  stable/11/contrib/elftoolchain/ar/read.c
  stable/11/contrib/elftoolchain/ar/write.c
  stable/11/contrib/elftoolchain/common/_elftc.h
  stable/11/contrib/elftoolchain/common/elfdefinitions.h
  stable/11/contrib/elftoolchain/common/native-elf-format
  stable/11/contrib/elftoolchain/cxxfilt/c++filt.1
  stable/11/contrib/elftoolchain/elfcopy/ascii.c
  stable/11/contrib/elftoolchain/elfcopy/binary.c
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.1
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/11/contrib/elftoolchain/elfcopy/main.c
  stable/11/contrib/elftoolchain/elfcopy/mcs.1
  stable/11/contrib/elftoolchain/elfcopy/sections.c
  stable/11/contrib/elftoolchain/elfcopy/segments.c
  stable/11/contrib/elftoolchain/elfcopy/strip.1
  stable/11/contrib/elftoolchain/elfdump/elfdump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf.h
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_producer.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_reference.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_directory_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_addr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_gen.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_fde_inst.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_file_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_cie.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_funcname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_pubname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_typename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_varname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_weakname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrlist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attroffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrval_signed.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_child.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dealloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_link.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_diename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dieoffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_end_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errmsg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_current_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_into_block.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_finish.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formaddr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formblock.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formexprloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formflag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formstring.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formudata.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_address_size.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_index.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_elf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_list.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_n.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_range.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_form_class.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_funcs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_globals.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_loclist_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_macro_details.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_pubtypes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_str.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_types.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_vars.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_weaks.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasform.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_highpc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lineno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_end_sequence.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_set_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist_from_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_die.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_types_section.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_object_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_set_isa.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_reset_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_reloc_application.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_seterrarg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srcfiles.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srclines.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_start_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_undef_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_vendor_ext.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_attr.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_die.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_frame.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_lineno.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
  stable/11/contrib/elftoolchain/libelf/Makefile
  stable/11/contrib/elftoolchain/libelf/Version.map
  stable/11/contrib/elftoolchain/libelf/_libelf.h
  stable/11/contrib/elftoolchain/libelf/_libelf_config.h
  stable/11/contrib/elftoolchain/libelf/elf.3
  stable/11/contrib/elftoolchain/libelf/elf_begin.3
  stable/11/contrib/elftoolchain/libelf/elf_cntl.3
  stable/11/contrib/elftoolchain/libelf/elf_data.c
  stable/11/contrib/elftoolchain/libelf/elf_end.3
  stable/11/contrib/elftoolchain/libelf/elf_end.c
  stable/11/contrib/elftoolchain/libelf/elf_errmsg.3
  stable/11/contrib/elftoolchain/libelf/elf_fill.3
  stable/11/contrib/elftoolchain/libelf/elf_flagdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getarhdr.3
  stable/11/contrib/elftoolchain/libelf/elf_getarsym.3
  stable/11/contrib/elftoolchain/libelf/elf_getbase.3
  stable/11/contrib/elftoolchain/libelf/elf_getdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.c
  stable/11/contrib/elftoolchain/libelf/elf_getphdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getphnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getscn.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_getshnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_hash.3
  stable/11/contrib/elftoolchain/libelf/elf_kind.3
  stable/11/contrib/elftoolchain/libelf/elf_memory.3
  stable/11/contrib/elftoolchain/libelf/elf_next.3
  stable/11/contrib/elftoolchain/libelf/elf_next.c
  stable/11/contrib/elftoolchain/libelf/elf_open.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.c
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.3
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.c
  stable/11/contrib/elftoolchain/libelf/elf_scn.c
  stable/11/contrib/elftoolchain/libelf/elf_strptr.3
  stable/11/contrib/elftoolchain/libelf/elf_update.3
  stable/11/contrib/elftoolchain/libelf/elf_update.c
  stable/11/contrib/elftoolchain/libelf/elf_version.3
  stable/11/contrib/elftoolchain/libelf/gelf.3
  stable/11/contrib/elftoolchain/libelf/gelf.h
  stable/11/contrib/elftoolchain/libelf/gelf_cap.c
  stable/11/contrib/elftoolchain/libelf/gelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/gelf_checksum.3
  stable/11/contrib/elftoolchain/libelf/gelf_dyn.c
  stable/11/contrib/elftoolchain/libelf/gelf_fsize.3
  stable/11/contrib/elftoolchain/libelf/gelf_getcap.3
  stable/11/contrib/elftoolchain/libelf/gelf_getchdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getclass.3
  stable/11/contrib/elftoolchain/libelf/gelf_getdyn.3
  stable/11/contrib/elftoolchain/libelf/gelf_getehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getmove.3
  stable/11/contrib/elftoolchain/libelf/gelf_getphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrel.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrela.3
  stable/11/contrib/elftoolchain/libelf/gelf_getshdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsym.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsyminfo.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsymshndx.3
  stable/11/contrib/elftoolchain/libelf/gelf_move.c
  stable/11/contrib/elftoolchain/libelf/gelf_newehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_newphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_rel.c
  stable/11/contrib/elftoolchain/libelf/gelf_rela.c
  stable/11/contrib/elftoolchain/libelf/gelf_sym.c
  stable/11/contrib/elftoolchain/libelf/gelf_syminfo.c
  stable/11/contrib/elftoolchain/libelf/gelf_symshndx.c
  stable/11/contrib/elftoolchain/libelf/gelf_update_ehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/gelf_xlatetof.3
  stable/11/contrib/elftoolchain/libelf/libelf.h
  stable/11/contrib/elftoolchain/libelf/libelf_allocate.c
  stable/11/contrib/elftoolchain/libelf/libelf_ar.c
  stable/11/contrib/elftoolchain/libelf/libelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_convert.m4
  stable/11/contrib/elftoolchain/libelf/libelf_data.c
  stable/11/contrib/elftoolchain/libelf/libelf_ehdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_elfmachine.c
  stable/11/contrib/elftoolchain/libelf/libelf_extended.c
  stable/11/contrib/elftoolchain/libelf/libelf_memory.c
  stable/11/contrib/elftoolchain/libelf/libelf_msize.m4
  stable/11/contrib/elftoolchain/libelf/libelf_phdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/os.Linux.mk
  stable/11/contrib/elftoolchain/libelftc/_libelftc.h
  stable/11/contrib/elftoolchain/libelftc/elftc.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/elftc_copyfile.3
  stable/11/contrib/elftoolchain/libelftc/elftc_demangle.3
  stable/11/contrib/elftoolchain/libelftc/elftc_reloc_type_str.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table_create.3
  stable/11/contrib/elftoolchain/libelftc/elftc_timestamp.3
  stable/11/contrib/elftoolchain/libelftc/elftc_version.3
  stable/11/contrib/elftoolchain/libelftc/libelftc.h
  stable/11/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_arm.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_vstr.c
  stable/11/contrib/elftoolchain/libelftc/make-toolchain-version
  stable/11/contrib/elftoolchain/libpe/pe_symtab.c
  stable/11/contrib/elftoolchain/nm/nm.1
  stable/11/contrib/elftoolchain/nm/nm.c
  stable/11/contrib/elftoolchain/readelf/readelf.1
  stable/11/contrib/elftoolchain/readelf/readelf.c
  stable/11/contrib/elftoolchain/size/size.c
  stable/11/contrib/elftoolchain/strings/strings.c
  stable/11/lib/libelf/Makefile
  stable/11/lib/libelftc/Makefile
  stable/11/lib/libelftc/elftc_version.c
  stable/11/sys/sys/elf_common.h
  stable/11/usr.bin/readelf/Makefile
Comment 37 commit-hook freebsd_committer freebsd_triage 2020-11-07 23:58:17 UTC
A commit references this bug:

Author: dim
Date: Sat Nov  7 23:58:00 UTC 2020
New revision: 367466
URL: https://svnweb.freebsd.org/changeset/base/367466

Log:
  Sync up elftoolchain with head, except for the capsicum-related commits,
  which are incompatible with stable/11.

  MFC r308465 (by emaste):

  c++filt: flush output after newline

  Some tools spawn c++filt and pass it a single line at a time for
  demangling. This is akin to r276689 for addr2line.

  Sponsored by:	The FreeBSD Foundation

  MFC r317626 (by emaste):

  revert r308465: c++filt: flush output after newline

  The ELF Tool Chain update to r3520 uses setvbuf to set line buffering.

  Sponsored by:	The FreeBSD Foundation

  MFC r340746 (by oshogbo):

  strings: fix style nits

  Reviewed by:	cem, emaste, Joseph Koshy <jkoshy@users.sourceforge.net>
  Differential Revision:	https://reviews.freebsd.org/D18036

  MFC r340750 (by mjg):

  strings: unbreak the build after r340746

  Discussed with:	oshogbo
  Sponsored by:	The FreeBSD Foundation

  MFC r342918 (by emaste):

  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

  MFC r343592 (by emaste):

  readelf: decode flag bits in DT_FLAGS/DT_FLAGS_1

  Decode d_val when the tag is DT_FLAGS or DT_FLAGS_1 based on the
  information at:

  https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html

  PR:		232983
  Submitted by:	Bora Ozarslan borako.ozarslan@gmail.com
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D18784

  MFC r343593 (by emaste):

  readelf: fix i386 build

  Use %jx and (uintmax_t) cast.

  PR:		232983
  Sponsored by:	The FreeBSD Foundation

  MFC r343614 (by emaste):

  readelf: dump elf note data

  Output format is compatible with GNU readelf's handling of unknown note
  types (modulo a GNU char signedness bug); future changes will add type-
  specific decoding.

  Reviewed by:	kib
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation

  MFC r343665 (by emaste):

  readelf: use table-based DT_FLAGS and DT_FLAGS_1 decoding

  Fewer lines of code and more maintainable.

  Reviewed by:	brooks, kib
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19053

  MFC r343669 (by emaste):

  readelf: decode FreeBSD note types

  Decode NT_FREEBSD_ABI_TAG, NT_FREEBSD_ARCH_TAG, and NT_FREEBSD_FEATURE_CTL.

  Reviewed by:	brooks, kib (earlier)
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19054

  MFC r345360 (by oshogbo):

  strings: do not depend on stdin

  Instead of depending on one stdin FILE structure and use freopen(3), pass to
  the functions appropriate FILE structure.

  Reviewed by:	cem
  Discussed with:	emaste
  Differential Revision:	https://reviews.freebsd.org/D18037

  MFC r345361 (by oshogbo):

  strings: do not continue if getc or getcharacter returns EOF

  Reported by:	cem

  MFC r345362 (by oshogbo):

  Fix powerpc and arm builds after r345361.

  Reported by:	jenkins

  MFC r345364 (by oshogbo):

  In case of ENCODING_8BIT the EOF code will be pass to putchar.
  EOF check should be done before (uint8_t)c > 127 test.

  Reported by:	cem

  MFC r345431 (by oshogbo):

  strings: return an error code and the char value separately

  If we returning 32 bits value it's hard to distinguish if the returned value
  is a valid one or if its an error (in case of EOF). For that reason separate
  exit code of the function from the returned character.

  Reported by:	cem, se

  MFC r345593 (by markj):

  Prepend DW_AT_comp_dir to relative line number directory table entries.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19705

  MFC r345646 (by emaste):

  readelf: add newline after dumping dynamic FLAGS / FLAGS_1

  All three dump_flags() callers need a newline after printing the flags.

  Sponsored by:	The FreeBSD Foundation

  MFC r346323 (by emaste):

  readelf: speed up readelf -wo

  Use an array instead of STAILQ, and sort at the end instead of while
  adding new elements.

  PR:		212539
  Submitted by:	Bora ?zarslan <borako.ozarslan@gmail.com>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation

  MFC r346327 (by emaste):

  readelf: use size_t for object counts

  PR:		212539
  Reported by:	cem
  Sponsored by:	The FreeBSD Foundation

  MFC r348347 (by jhibbits):

  Add missing powerpc64 relocation support to libdwarf

  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

  MFC r348430 (by markj):

  elfcopy: Remove an unneeded memset.

  Reviewed by:	emaste, trasz
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20445

  MFC r348431 (by markj):

  elfcopy: Optimize for insertions at the end of the section list.

  This is the common case when strip(1) is creating the output file.
  The change provides a significant speedup when running on ELF files with
  many sections.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20444

  MFC r348443 (by markj):

  readelf: Make -t imply -S, for compatibility with GNU binutils.

  Reported by:	jhb
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20475

  MFC r348444 (by markj):

  libelftc: Add MLINKS.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20474

  MFC r348652 (by markj):

  libelf: Use a red-black tree to manage the section list.

  The tree is indexed by section number.  This speeds up elf_getscn()
  and its callers, which previously had to traverse a linked list. In
  particular, since .shstrtab is often the last section in a file,
  elf_strptr() would have to traverse the entire list.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20443

  MFC r348654 (by markj):

  elfcopy: Use elf_getscn() instead of iterating over all sections.

  When removing a section, we would loop over all sections looking for
  a corresponding relocation section.  With r348652 it is much faster
  to just use elf_getscn().

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20471

  MFC r348655 (by markj):

  libelftc: Fix some minor style bugs.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20472

  MFC r348657 (by markj):

  elfcopy: Use libelftc's string table routines to build .shstrtab.

  This replaces some hand-rolled routines and is substantially faster
  since libelftc uses a hash table for lookups and insertions, whereas
  elfcopy would perform a linear scan of the table.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20473

  MFC r348776 (by csjp):

  Teach readelf about some OpenBSD ELF program headers

  - Add constants for OpenBSD wxneeded, bootdata and randomize to the
    FreeBSD elf_common.h file. This is the file that gets used by the
    elftoolchain library.
  - Update readelf and elfdump utilities to decode these program headers
    if they are encountered.

  Note: FreeBSD has it's own version of elfdump(1), which will be updated
  in a subsequent commit. I am adding it here anyway because this diff is
  going to be submitted upstream.

  Discussed with:	emaste
  Reviewed by:	imp
  Differential Revision:	https://reviews.freebsd.org/D20548

  MFC r349420 (by markj):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20760

  MFC r349421 (by markj):

  libelftc: Consistently use size_t for string table offsets and sizes.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20702

  MFC r349422 (by markj):

  libelftc: Fix the documented prototype for elftc_string_table_destroy().

  Sponsored by:	The FreeBSD Foundation

  MFC r349423 (by markj):

  elfcopy: Provide a size hint when creating the section string table.

  Use the input file's .shstrtab size as the hint if it exists.  This
  gives a small performance improvement when processing files with
  many sections.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20544

  MFC r349424 (by markj):

  libdwarf: Use the cached strtab pointer when reading string attributes.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20759

  MFC r349481 (by mhorne):

  Add some missing RISC-V ELF defines

  This adds defines for the RISC-V specific e_flags values, and some of
  the missing static relocations.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20766

  MFC r349482 (by mhorne):

  readelf: Add support for RISC-V specific e_flags

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20767

  MFC r349483 (by mhorne):

  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)
  Differential Revision:	https://reviews.freebsd.org/D20768

  MFC r349510 (by luporl):

  [PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)

  This prints out description text with the meaning of 'Flags' value in PowerPC64.

  Example:

  $ readelf -h ~/tmp/t1-Flag2
  ELF Header:

  Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           PowerPC 64-bit
  Version:                           0x1
  Entry point address:               0x10010000
  Start of program headers:          64 (bytes into file)
  Start of section headers:          209368 (bytes into file)
  Flags:                             0x2, OpenPOWER ELF V2 ABI
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         10
  Size of section headers:           64 (bytes)
  Number of section headers:         34
  Section header string table index: 31

  Submitted by:	 alfredo.junior_eldorado.org.br
  Reviewed by:	luporl
  Differential Revision:	https://reviews.freebsd.org/D20782

  MFC r349562 (by mhorne):

  elftoolchain: fix an incorrect e_flags description

  r349482 introduced the definitions and descriptions of the RISC-V
  specific e_flags values to elftoolchain. However, the description for
  the EF_RISCV_RVE flag was incorrectly duplicated from EF_RISCV_RVC. Fix
  this by providing the proper description for this flag.

  Reported by:	jhb
  Approved by:	markj (mentor)

  MFC r349563 (by mhorne):

  readelf: Add RISC-V DWARF register aliases

  This allows DWARF debugging output to use the common register
  mneumonics, such as ra, sp, or t0.

  DWARF registers 0-31 are mapped to the 32 general purpose registers,
  which are then followed by the 32 floating point registers.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20779

  MFC r349577 (by arichardson):

  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

  MFC r349730 (by markj):

  elfcopy: Clear errors after fetching the shstrtab index.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20852

  MFC r350432 (by markj):

  Merge r3778 and r3779 from ELFToolchain.

  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.

  Sponsored by:	The FreeBSD Foundation

  MFC r350511 (by emaste):

  readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND

  These bits are used for Intel CET IBT/Shadow Stack.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20516

  MFC r350679 (by markj):

  Merge r3780 from elftoolchain.

  Adjust argc and argv by optind before using them.  This slightly
  simplifies the code.  No functional change intended.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21079

  MFC r352875 (by ray):

  ections into expected offset in binary format.
  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
  Differential Revision:	D21827

  MFC r352878 (by ray):

  Initialize baseaddr to suppres warning.

  Pointy hat to:	ray

  MFC r352908 (by markj):

  nm: Adjust argc and argv in get_opt().

  This refactoring makes it slightly easier to capsicumize nm(1).

  Discussed with:	emaste
  Sponsored by:	The FreeBSD Foundation

  MFC r354544 (by emaste):

  elfcopy/strip: Ensure sections have required alignment on output

  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

  MFC r354842 (by jhibbits):

  ELF toolchain: Add PowerPC VMX and VSX note decode to readelf

  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

  MFC r355413 (by emaste):

  Update ELF Tool Chain to upstream r3769

  This contains many small bugfixes and documentation improvements.

  Sponsored by:	The FreeBSD Foundation

  MFC r357450 (by markj):

  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>
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23418

  MFC r357462 (by markj):

  addr2line: Avoid a name collision.

  The RB_ macros define functions with a parameter named head, and gcc
  warns about this.

  MFC r357531 (by markj):

  libdwarf: Remove unnecessary NULL checks.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357532 (by markj):

  libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().

  CID:		1193364
  Sponsored by:	The FreeBSD Foundation

  MFC r357533 (by markj):

  libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357534 (by markj):

  libdwarf: Fix a memory leak in _dwarf_frame_section_init().

  If frame length validation failed we would leak memory.

  CID:		1193366
  Sponsored by:	The FreeBSD Foundation

  MFC r357535 (by markj):

  libelftc: Fix memory leaks in the C++ demanglers.

  CID:		1262518, 1262519, 1262520, 1262529
  Sponsored by:	The FreeBSD Foundation

  MFC r357536 (by markj):

  libelftc: Add a missing check for an error from vector_str_init().

  While here consistently use the same spelling for such checks.

  CID:		1376769
  Sponsored by:	The FreeBSD Foundation

  MFC r357537 (by markj):

  elfcopy: Handle multiple data descriptors properly.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357538 (by markj):

  elfcopy: Avoid leaking dst's fd when we fail to copy a file.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357539 (by markj):

  size: Avoid returning a stack pointer from xlatetom().

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357540 (by markj):

  readelf: Fix a double close of the input file.

  The caller of dump_object() is responsible for opening the file, let it
  be responsible for closing too.

  CID:		1411588
  Sponsored by:	The FreeBSD Foundation

  MFC r357541 (by markj):

  readelf: Fix the check for an error from realloc().

  Use err() instead of errx() while here, since realloc() sets errno.

  CID:		1401326
  Sponsored by:	The FreeBSD Foundation

  MFC r357542 (by markj):

  readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r357826 (by emaste):

  elfcopy: set ELF OS/ABI field when converting from binary

  PR:		228934
  Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
  Reviewed by:	markj, jkoshy
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23504

  MFC r357844 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23501

  MFC r357862 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358499 (by emaste):

  readelf: add PROTMAX_DISABLE and STKGAP_DISABLE

  From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE).  Commited
  upstream (in a slightly different form) as r3831.

  Sponsored by:	The FreeBSD Foundation

  MFC r358631 (by emaste):

  Reserve WXNEEDED ELF feature control flag

  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

  MFC r358637 (by emaste):

  readelf: check note namesz and descsz

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358639 (by emaste):

  readelf: simplify namesz / descsz checks

  Sponsored by:	The FreeBSD Foundation

  MFC r358685 (by emaste):

  libelf: rationalize error handling in ELF note conversion

  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

  MFC r358706 (by emaste):

  readelf: add XEN_ELFNOTE_PHYS32_ENTRY note

  See r336469 for details.

  Sponsored by:	The FreeBSD Foundation

  MFC r358708 (by emaste):

  readelf: decode and print Xen ELF note strings

  Sponsored by:	The FreeBSD Foundation

  MFC r358713 (by emaste):

  readelf: print GNU Build-ID

  Sponsored by:	The FreeBSD Foundation

  MFC r358778 (by emaste):

  readelf: hoist file opening out of dump_object

  Diff reduction with HEAD to facilitate other MFCs.

  MFC r359166 (by emaste):

  objcopy: add new sections also when there is no .shstrtab

  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

  MFC r359172 (by markj):

  libdwarf: Make an out-pointer assignment unconditional.

  There is no reason for diep to ever be NULL, since in that case we would
  simply be leaking memory.

  CID:		1418801
  Sponsored by:	The FreeBSD Foundation

  MFC r359173 (by markj):

  libpe: Avoid a potential use-after-free in pe_update_symtab().

  This function appears to be unused within FreeBSD and ELFToolChain.

  CID:		1418982
  Sponsored by:	The FreeBSD Foundation

  MFC r359174 (by markj):

  readelf: Avoid leaking ELF descriptors for archive entries.

  CID:		1292494
  Sponsored by:	The FreeBSD Foundation

  MFC r359175 (by markj):

  readelf: Fix another instance of the leak mentioned in r357542.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r359176 (by markj):

  libelftc: Fix a memory leak in cpp_demangle_read_type().

  CID:		1305425
  Sponsored by:	The FreeBSD Foundation

  MFC r359189 (by emaste):

  readelf: simplify Xen string note printing

  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24140

  MFC r361104 (by jhibbits):

  elftoolchain: Add powerpc64 definition to elftoolchain config

  powerpc is already in place, but powerpc64 is needed separately.

  MFC r361662 (by emaste):

  readelf: add more DT_FLAGS_1 flags

  Reference:
  https://docs.oracle.com/cd/E36784_01/html/E36857/chapter6-42444.html

  > DF_1_SINGLETON  Singleton symbols exist.
  > DF_1_STUB       Object is a stub.
  > DF_1_PIE        Object is a position-independent executable.

  Sponsored by:	The FreeBSD Foundation

  MFC r365489 (by bdragon):

  [PowerPC64LE] PPC64LE support for libelf.

  Fix native detection when building on powerpc64le.

  I will be submitting this and r361104 upstream shortly.

  Sponsored by:	Tag1 Consulting, Inc.

  MFC r366977 (by emaste):

  libelf: add compression header support

  GNU and Oracle libelf implementations added support for section
  compression, intended to reduce the size of DWARF debug info (which
  might be an order of magnitude larger than the code).

  There are two compressed ELF section formats:

  1. Old GNU - sections are renmaed to start with 'z'.  Section contains
     a magic number, uncompressed size, and compressed data.

  2. Oracle and New GNU - compressed sections use the SHF_COMPRESSED flag.
     The compression header contains the compression type, uncompressed
     size, and uncompressed alignment.

  The second style is preferred and this change implements only that one.

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24566

  MFC r367209 (by emaste):

  readelf: Add -z decompression support

  Compatible with GNU readelf, -z decompresses sections displayed by
  -x or -p.

  ELF Tool Chain ticket #555
  https://sourceforge.net/p/elftoolchain/tickets/555/

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:    https://reviews.freebsd.org/D26909

  MFC r367238 (by bdragon):

  Fix 32-bit build after r367209

  Fix build on systems with a 32-bit size_t.

  Since it's being passed as a pointer, a 64-bit write to it will overflow.

  MFC r367322 (by dim):

  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

Changes:
_U  stable/11/
  stable/11/contrib/elftoolchain/.cirrus.yml
  stable/11/contrib/elftoolchain/README.rst
  stable/11/contrib/elftoolchain/addr2line/addr2line.1
  stable/11/contrib/elftoolchain/addr2line/addr2line.c
  stable/11/contrib/elftoolchain/ar/ar.1
  stable/11/contrib/elftoolchain/ar/ar.5
  stable/11/contrib/elftoolchain/ar/ar.c
  stable/11/contrib/elftoolchain/ar/ar.h
  stable/11/contrib/elftoolchain/ar/ranlib.1
  stable/11/contrib/elftoolchain/ar/read.c
  stable/11/contrib/elftoolchain/ar/write.c
  stable/11/contrib/elftoolchain/common/_elftc.h
  stable/11/contrib/elftoolchain/common/elfdefinitions.h
  stable/11/contrib/elftoolchain/common/native-elf-format
  stable/11/contrib/elftoolchain/cxxfilt/c++filt.1
  stable/11/contrib/elftoolchain/elfcopy/ascii.c
  stable/11/contrib/elftoolchain/elfcopy/binary.c
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.1
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/11/contrib/elftoolchain/elfcopy/main.c
  stable/11/contrib/elftoolchain/elfcopy/mcs.1
  stable/11/contrib/elftoolchain/elfcopy/sections.c
  stable/11/contrib/elftoolchain/elfcopy/segments.c
  stable/11/contrib/elftoolchain/elfcopy/strip.1
  stable/11/contrib/elftoolchain/elfdump/elfdump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf.h
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_producer.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_reference.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_directory_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_addr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_gen.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_fde_inst.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_file_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_cie.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_funcname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_pubname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_typename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_varname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_weakname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrlist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attroffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrval_signed.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_child.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dealloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_link.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_diename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dieoffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_end_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errmsg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_current_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_into_block.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_finish.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formaddr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formblock.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formexprloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formflag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formstring.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formudata.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_address_size.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_index.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_elf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_list.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_n.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_range.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_form_class.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_funcs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_globals.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_loclist_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_macro_details.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_pubtypes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_str.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_types.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_vars.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_weaks.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasform.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_highpc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lineno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_end_sequence.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_set_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist_from_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_die.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_types_section.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_object_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_set_isa.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_reset_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_reloc_application.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_seterrarg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srcfiles.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srclines.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_start_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_undef_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_vendor_ext.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_attr.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_die.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_frame.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_lineno.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
  stable/11/contrib/elftoolchain/libelf/Makefile
  stable/11/contrib/elftoolchain/libelf/Version.map
  stable/11/contrib/elftoolchain/libelf/_libelf.h
  stable/11/contrib/elftoolchain/libelf/_libelf_config.h
  stable/11/contrib/elftoolchain/libelf/elf.3
  stable/11/contrib/elftoolchain/libelf/elf_begin.3
  stable/11/contrib/elftoolchain/libelf/elf_cntl.3
  stable/11/contrib/elftoolchain/libelf/elf_data.c
  stable/11/contrib/elftoolchain/libelf/elf_end.3
  stable/11/contrib/elftoolchain/libelf/elf_end.c
  stable/11/contrib/elftoolchain/libelf/elf_errmsg.3
  stable/11/contrib/elftoolchain/libelf/elf_fill.3
  stable/11/contrib/elftoolchain/libelf/elf_flagdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getarhdr.3
  stable/11/contrib/elftoolchain/libelf/elf_getarsym.3
  stable/11/contrib/elftoolchain/libelf/elf_getbase.3
  stable/11/contrib/elftoolchain/libelf/elf_getdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.c
  stable/11/contrib/elftoolchain/libelf/elf_getphdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getphnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getscn.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_getshnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_hash.3
  stable/11/contrib/elftoolchain/libelf/elf_kind.3
  stable/11/contrib/elftoolchain/libelf/elf_memory.3
  stable/11/contrib/elftoolchain/libelf/elf_next.3
  stable/11/contrib/elftoolchain/libelf/elf_next.c
  stable/11/contrib/elftoolchain/libelf/elf_open.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.c
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.3
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.c
  stable/11/contrib/elftoolchain/libelf/elf_scn.c
  stable/11/contrib/elftoolchain/libelf/elf_strptr.3
  stable/11/contrib/elftoolchain/libelf/elf_update.3
  stable/11/contrib/elftoolchain/libelf/elf_update.c
  stable/11/contrib/elftoolchain/libelf/elf_version.3
  stable/11/contrib/elftoolchain/libelf/gelf.3
  stable/11/contrib/elftoolchain/libelf/gelf.h
  stable/11/contrib/elftoolchain/libelf/gelf_cap.c
  stable/11/contrib/elftoolchain/libelf/gelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/gelf_checksum.3
  stable/11/contrib/elftoolchain/libelf/gelf_dyn.c
  stable/11/contrib/elftoolchain/libelf/gelf_fsize.3
  stable/11/contrib/elftoolchain/libelf/gelf_getcap.3
  stable/11/contrib/elftoolchain/libelf/gelf_getchdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getclass.3
  stable/11/contrib/elftoolchain/libelf/gelf_getdyn.3
  stable/11/contrib/elftoolchain/libelf/gelf_getehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getmove.3
  stable/11/contrib/elftoolchain/libelf/gelf_getphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrel.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrela.3
  stable/11/contrib/elftoolchain/libelf/gelf_getshdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsym.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsyminfo.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsymshndx.3
  stable/11/contrib/elftoolchain/libelf/gelf_move.c
  stable/11/contrib/elftoolchain/libelf/gelf_newehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_newphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_rel.c
  stable/11/contrib/elftoolchain/libelf/gelf_rela.c
  stable/11/contrib/elftoolchain/libelf/gelf_sym.c
  stable/11/contrib/elftoolchain/libelf/gelf_syminfo.c
  stable/11/contrib/elftoolchain/libelf/gelf_symshndx.c
  stable/11/contrib/elftoolchain/libelf/gelf_update_ehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/gelf_xlatetof.3
  stable/11/contrib/elftoolchain/libelf/libelf.h
  stable/11/contrib/elftoolchain/libelf/libelf_allocate.c
  stable/11/contrib/elftoolchain/libelf/libelf_ar.c
  stable/11/contrib/elftoolchain/libelf/libelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_convert.m4
  stable/11/contrib/elftoolchain/libelf/libelf_data.c
  stable/11/contrib/elftoolchain/libelf/libelf_ehdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_elfmachine.c
  stable/11/contrib/elftoolchain/libelf/libelf_extended.c
  stable/11/contrib/elftoolchain/libelf/libelf_memory.c
  stable/11/contrib/elftoolchain/libelf/libelf_msize.m4
  stable/11/contrib/elftoolchain/libelf/libelf_phdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/os.Linux.mk
  stable/11/contrib/elftoolchain/libelftc/_libelftc.h
  stable/11/contrib/elftoolchain/libelftc/elftc.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/elftc_copyfile.3
  stable/11/contrib/elftoolchain/libelftc/elftc_demangle.3
  stable/11/contrib/elftoolchain/libelftc/elftc_reloc_type_str.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table_create.3
  stable/11/contrib/elftoolchain/libelftc/elftc_timestamp.3
  stable/11/contrib/elftoolchain/libelftc/elftc_version.3
  stable/11/contrib/elftoolchain/libelftc/libelftc.h
  stable/11/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_arm.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_vstr.c
  stable/11/contrib/elftoolchain/libelftc/make-toolchain-version
  stable/11/contrib/elftoolchain/libpe/pe_symtab.c
  stable/11/contrib/elftoolchain/nm/nm.1
  stable/11/contrib/elftoolchain/nm/nm.c
  stable/11/contrib/elftoolchain/readelf/readelf.1
  stable/11/contrib/elftoolchain/readelf/readelf.c
  stable/11/contrib/elftoolchain/size/size.c
  stable/11/contrib/elftoolchain/strings/strings.c
  stable/11/lib/libelf/Makefile
  stable/11/lib/libelftc/Makefile
  stable/11/lib/libelftc/elftc_version.c
  stable/11/sys/sys/elf_common.h
  stable/11/usr.bin/readelf/Makefile
Comment 38 commit-hook freebsd_committer freebsd_triage 2020-11-07 23:58:19 UTC
A commit references this bug:

Author: dim
Date: Sat Nov  7 23:58:00 UTC 2020
New revision: 367466
URL: https://svnweb.freebsd.org/changeset/base/367466

Log:
  Sync up elftoolchain with head, except for the capsicum-related commits,
  which are incompatible with stable/11.

  MFC r308465 (by emaste):

  c++filt: flush output after newline

  Some tools spawn c++filt and pass it a single line at a time for
  demangling. This is akin to r276689 for addr2line.

  Sponsored by:	The FreeBSD Foundation

  MFC r317626 (by emaste):

  revert r308465: c++filt: flush output after newline

  The ELF Tool Chain update to r3520 uses setvbuf to set line buffering.

  Sponsored by:	The FreeBSD Foundation

  MFC r340746 (by oshogbo):

  strings: fix style nits

  Reviewed by:	cem, emaste, Joseph Koshy <jkoshy@users.sourceforge.net>
  Differential Revision:	https://reviews.freebsd.org/D18036

  MFC r340750 (by mjg):

  strings: unbreak the build after r340746

  Discussed with:	oshogbo
  Sponsored by:	The FreeBSD Foundation

  MFC r342918 (by emaste):

  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

  MFC r343592 (by emaste):

  readelf: decode flag bits in DT_FLAGS/DT_FLAGS_1

  Decode d_val when the tag is DT_FLAGS or DT_FLAGS_1 based on the
  information at:

  https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html

  PR:		232983
  Submitted by:	Bora Ozarslan borako.ozarslan@gmail.com
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D18784

  MFC r343593 (by emaste):

  readelf: fix i386 build

  Use %jx and (uintmax_t) cast.

  PR:		232983
  Sponsored by:	The FreeBSD Foundation

  MFC r343614 (by emaste):

  readelf: dump elf note data

  Output format is compatible with GNU readelf's handling of unknown note
  types (modulo a GNU char signedness bug); future changes will add type-
  specific decoding.

  Reviewed by:	kib
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation

  MFC r343665 (by emaste):

  readelf: use table-based DT_FLAGS and DT_FLAGS_1 decoding

  Fewer lines of code and more maintainable.

  Reviewed by:	brooks, kib
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19053

  MFC r343669 (by emaste):

  readelf: decode FreeBSD note types

  Decode NT_FREEBSD_ABI_TAG, NT_FREEBSD_ARCH_TAG, and NT_FREEBSD_FEATURE_CTL.

  Reviewed by:	brooks, kib (earlier)
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19054

  MFC r345360 (by oshogbo):

  strings: do not depend on stdin

  Instead of depending on one stdin FILE structure and use freopen(3), pass to
  the functions appropriate FILE structure.

  Reviewed by:	cem
  Discussed with:	emaste
  Differential Revision:	https://reviews.freebsd.org/D18037

  MFC r345361 (by oshogbo):

  strings: do not continue if getc or getcharacter returns EOF

  Reported by:	cem

  MFC r345362 (by oshogbo):

  Fix powerpc and arm builds after r345361.

  Reported by:	jenkins

  MFC r345364 (by oshogbo):

  In case of ENCODING_8BIT the EOF code will be pass to putchar.
  EOF check should be done before (uint8_t)c > 127 test.

  Reported by:	cem

  MFC r345431 (by oshogbo):

  strings: return an error code and the char value separately

  If we returning 32 bits value it's hard to distinguish if the returned value
  is a valid one or if its an error (in case of EOF). For that reason separate
  exit code of the function from the returned character.

  Reported by:	cem, se

  MFC r345593 (by markj):

  Prepend DW_AT_comp_dir to relative line number directory table entries.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19705

  MFC r345646 (by emaste):

  readelf: add newline after dumping dynamic FLAGS / FLAGS_1

  All three dump_flags() callers need a newline after printing the flags.

  Sponsored by:	The FreeBSD Foundation

  MFC r346323 (by emaste):

  readelf: speed up readelf -wo

  Use an array instead of STAILQ, and sort at the end instead of while
  adding new elements.

  PR:		212539
  Submitted by:	Bora ?zarslan <borako.ozarslan@gmail.com>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation

  MFC r346327 (by emaste):

  readelf: use size_t for object counts

  PR:		212539
  Reported by:	cem
  Sponsored by:	The FreeBSD Foundation

  MFC r348347 (by jhibbits):

  Add missing powerpc64 relocation support to libdwarf

  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

  MFC r348430 (by markj):

  elfcopy: Remove an unneeded memset.

  Reviewed by:	emaste, trasz
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20445

  MFC r348431 (by markj):

  elfcopy: Optimize for insertions at the end of the section list.

  This is the common case when strip(1) is creating the output file.
  The change provides a significant speedup when running on ELF files with
  many sections.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20444

  MFC r348443 (by markj):

  readelf: Make -t imply -S, for compatibility with GNU binutils.

  Reported by:	jhb
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20475

  MFC r348444 (by markj):

  libelftc: Add MLINKS.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20474

  MFC r348652 (by markj):

  libelf: Use a red-black tree to manage the section list.

  The tree is indexed by section number.  This speeds up elf_getscn()
  and its callers, which previously had to traverse a linked list. In
  particular, since .shstrtab is often the last section in a file,
  elf_strptr() would have to traverse the entire list.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20443

  MFC r348654 (by markj):

  elfcopy: Use elf_getscn() instead of iterating over all sections.

  When removing a section, we would loop over all sections looking for
  a corresponding relocation section.  With r348652 it is much faster
  to just use elf_getscn().

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20471

  MFC r348655 (by markj):

  libelftc: Fix some minor style bugs.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20472

  MFC r348657 (by markj):

  elfcopy: Use libelftc's string table routines to build .shstrtab.

  This replaces some hand-rolled routines and is substantially faster
  since libelftc uses a hash table for lookups and insertions, whereas
  elfcopy would perform a linear scan of the table.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20473

  MFC r348776 (by csjp):

  Teach readelf about some OpenBSD ELF program headers

  - Add constants for OpenBSD wxneeded, bootdata and randomize to the
    FreeBSD elf_common.h file. This is the file that gets used by the
    elftoolchain library.
  - Update readelf and elfdump utilities to decode these program headers
    if they are encountered.

  Note: FreeBSD has it's own version of elfdump(1), which will be updated
  in a subsequent commit. I am adding it here anyway because this diff is
  going to be submitted upstream.

  Discussed with:	emaste
  Reviewed by:	imp
  Differential Revision:	https://reviews.freebsd.org/D20548

  MFC r349420 (by markj):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20760

  MFC r349421 (by markj):

  libelftc: Consistently use size_t for string table offsets and sizes.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20702

  MFC r349422 (by markj):

  libelftc: Fix the documented prototype for elftc_string_table_destroy().

  Sponsored by:	The FreeBSD Foundation

  MFC r349423 (by markj):

  elfcopy: Provide a size hint when creating the section string table.

  Use the input file's .shstrtab size as the hint if it exists.  This
  gives a small performance improvement when processing files with
  many sections.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20544

  MFC r349424 (by markj):

  libdwarf: Use the cached strtab pointer when reading string attributes.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20759

  MFC r349481 (by mhorne):

  Add some missing RISC-V ELF defines

  This adds defines for the RISC-V specific e_flags values, and some of
  the missing static relocations.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20766

  MFC r349482 (by mhorne):

  readelf: Add support for RISC-V specific e_flags

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20767

  MFC r349483 (by mhorne):

  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)
  Differential Revision:	https://reviews.freebsd.org/D20768

  MFC r349510 (by luporl):

  [PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)

  This prints out description text with the meaning of 'Flags' value in PowerPC64.

  Example:

  $ readelf -h ~/tmp/t1-Flag2
  ELF Header:

  Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           PowerPC 64-bit
  Version:                           0x1
  Entry point address:               0x10010000
  Start of program headers:          64 (bytes into file)
  Start of section headers:          209368 (bytes into file)
  Flags:                             0x2, OpenPOWER ELF V2 ABI
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         10
  Size of section headers:           64 (bytes)
  Number of section headers:         34
  Section header string table index: 31

  Submitted by:	 alfredo.junior_eldorado.org.br
  Reviewed by:	luporl
  Differential Revision:	https://reviews.freebsd.org/D20782

  MFC r349562 (by mhorne):

  elftoolchain: fix an incorrect e_flags description

  r349482 introduced the definitions and descriptions of the RISC-V
  specific e_flags values to elftoolchain. However, the description for
  the EF_RISCV_RVE flag was incorrectly duplicated from EF_RISCV_RVC. Fix
  this by providing the proper description for this flag.

  Reported by:	jhb
  Approved by:	markj (mentor)

  MFC r349563 (by mhorne):

  readelf: Add RISC-V DWARF register aliases

  This allows DWARF debugging output to use the common register
  mneumonics, such as ra, sp, or t0.

  DWARF registers 0-31 are mapped to the 32 general purpose registers,
  which are then followed by the 32 floating point registers.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20779

  MFC r349577 (by arichardson):

  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

  MFC r349730 (by markj):

  elfcopy: Clear errors after fetching the shstrtab index.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20852

  MFC r350432 (by markj):

  Merge r3778 and r3779 from ELFToolchain.

  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.

  Sponsored by:	The FreeBSD Foundation

  MFC r350511 (by emaste):

  readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND

  These bits are used for Intel CET IBT/Shadow Stack.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20516

  MFC r350679 (by markj):

  Merge r3780 from elftoolchain.

  Adjust argc and argv by optind before using them.  This slightly
  simplifies the code.  No functional change intended.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21079

  MFC r352875 (by ray):

  ections into expected offset in binary format.
  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
  Differential Revision:	D21827

  MFC r352878 (by ray):

  Initialize baseaddr to suppres warning.

  Pointy hat to:	ray

  MFC r352908 (by markj):

  nm: Adjust argc and argv in get_opt().

  This refactoring makes it slightly easier to capsicumize nm(1).

  Discussed with:	emaste
  Sponsored by:	The FreeBSD Foundation

  MFC r354544 (by emaste):

  elfcopy/strip: Ensure sections have required alignment on output

  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

  MFC r354842 (by jhibbits):

  ELF toolchain: Add PowerPC VMX and VSX note decode to readelf

  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

  MFC r355413 (by emaste):

  Update ELF Tool Chain to upstream r3769

  This contains many small bugfixes and documentation improvements.

  Sponsored by:	The FreeBSD Foundation

  MFC r357450 (by markj):

  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>
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23418

  MFC r357462 (by markj):

  addr2line: Avoid a name collision.

  The RB_ macros define functions with a parameter named head, and gcc
  warns about this.

  MFC r357531 (by markj):

  libdwarf: Remove unnecessary NULL checks.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357532 (by markj):

  libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().

  CID:		1193364
  Sponsored by:	The FreeBSD Foundation

  MFC r357533 (by markj):

  libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357534 (by markj):

  libdwarf: Fix a memory leak in _dwarf_frame_section_init().

  If frame length validation failed we would leak memory.

  CID:		1193366
  Sponsored by:	The FreeBSD Foundation

  MFC r357535 (by markj):

  libelftc: Fix memory leaks in the C++ demanglers.

  CID:		1262518, 1262519, 1262520, 1262529
  Sponsored by:	The FreeBSD Foundation

  MFC r357536 (by markj):

  libelftc: Add a missing check for an error from vector_str_init().

  While here consistently use the same spelling for such checks.

  CID:		1376769
  Sponsored by:	The FreeBSD Foundation

  MFC r357537 (by markj):

  elfcopy: Handle multiple data descriptors properly.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357538 (by markj):

  elfcopy: Avoid leaking dst's fd when we fail to copy a file.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357539 (by markj):

  size: Avoid returning a stack pointer from xlatetom().

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357540 (by markj):

  readelf: Fix a double close of the input file.

  The caller of dump_object() is responsible for opening the file, let it
  be responsible for closing too.

  CID:		1411588
  Sponsored by:	The FreeBSD Foundation

  MFC r357541 (by markj):

  readelf: Fix the check for an error from realloc().

  Use err() instead of errx() while here, since realloc() sets errno.

  CID:		1401326
  Sponsored by:	The FreeBSD Foundation

  MFC r357542 (by markj):

  readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r357826 (by emaste):

  elfcopy: set ELF OS/ABI field when converting from binary

  PR:		228934
  Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
  Reviewed by:	markj, jkoshy
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23504

  MFC r357844 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23501

  MFC r357862 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358499 (by emaste):

  readelf: add PROTMAX_DISABLE and STKGAP_DISABLE

  From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE).  Commited
  upstream (in a slightly different form) as r3831.

  Sponsored by:	The FreeBSD Foundation

  MFC r358631 (by emaste):

  Reserve WXNEEDED ELF feature control flag

  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

  MFC r358637 (by emaste):

  readelf: check note namesz and descsz

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358639 (by emaste):

  readelf: simplify namesz / descsz checks

  Sponsored by:	The FreeBSD Foundation

  MFC r358685 (by emaste):

  libelf: rationalize error handling in ELF note conversion

  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

  MFC r358706 (by emaste):

  readelf: add XEN_ELFNOTE_PHYS32_ENTRY note

  See r336469 for details.

  Sponsored by:	The FreeBSD Foundation

  MFC r358708 (by emaste):

  readelf: decode and print Xen ELF note strings

  Sponsored by:	The FreeBSD Foundation

  MFC r358713 (by emaste):

  readelf: print GNU Build-ID

  Sponsored by:	The FreeBSD Foundation

  MFC r358778 (by emaste):

  readelf: hoist file opening out of dump_object

  Diff reduction with HEAD to facilitate other MFCs.

  MFC r359166 (by emaste):

  objcopy: add new sections also when there is no .shstrtab

  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

  MFC r359172 (by markj):

  libdwarf: Make an out-pointer assignment unconditional.

  There is no reason for diep to ever be NULL, since in that case we would
  simply be leaking memory.

  CID:		1418801
  Sponsored by:	The FreeBSD Foundation

  MFC r359173 (by markj):

  libpe: Avoid a potential use-after-free in pe_update_symtab().

  This function appears to be unused within FreeBSD and ELFToolChain.

  CID:		1418982
  Sponsored by:	The FreeBSD Foundation

  MFC r359174 (by markj):

  readelf: Avoid leaking ELF descriptors for archive entries.

  CID:		1292494
  Sponsored by:	The FreeBSD Foundation

  MFC r359175 (by markj):

  readelf: Fix another instance of the leak mentioned in r357542.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r359176 (by markj):

  libelftc: Fix a memory leak in cpp_demangle_read_type().

  CID:		1305425
  Sponsored by:	The FreeBSD Foundation

  MFC r359189 (by emaste):

  readelf: simplify Xen string note printing

  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24140

  MFC r361104 (by jhibbits):

  elftoolchain: Add powerpc64 definition to elftoolchain config

  powerpc is already in place, but powerpc64 is needed separately.

  MFC r361662 (by emaste):

  readelf: add more DT_FLAGS_1 flags

  Reference:
  https://docs.oracle.com/cd/E36784_01/html/E36857/chapter6-42444.html

  > DF_1_SINGLETON  Singleton symbols exist.
  > DF_1_STUB       Object is a stub.
  > DF_1_PIE        Object is a position-independent executable.

  Sponsored by:	The FreeBSD Foundation

  MFC r365489 (by bdragon):

  [PowerPC64LE] PPC64LE support for libelf.

  Fix native detection when building on powerpc64le.

  I will be submitting this and r361104 upstream shortly.

  Sponsored by:	Tag1 Consulting, Inc.

  MFC r366977 (by emaste):

  libelf: add compression header support

  GNU and Oracle libelf implementations added support for section
  compression, intended to reduce the size of DWARF debug info (which
  might be an order of magnitude larger than the code).

  There are two compressed ELF section formats:

  1. Old GNU - sections are renmaed to start with 'z'.  Section contains
     a magic number, uncompressed size, and compressed data.

  2. Oracle and New GNU - compressed sections use the SHF_COMPRESSED flag.
     The compression header contains the compression type, uncompressed
     size, and uncompressed alignment.

  The second style is preferred and this change implements only that one.

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24566

  MFC r367209 (by emaste):

  readelf: Add -z decompression support

  Compatible with GNU readelf, -z decompresses sections displayed by
  -x or -p.

  ELF Tool Chain ticket #555
  https://sourceforge.net/p/elftoolchain/tickets/555/

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:    https://reviews.freebsd.org/D26909

  MFC r367238 (by bdragon):

  Fix 32-bit build after r367209

  Fix build on systems with a 32-bit size_t.

  Since it's being passed as a pointer, a 64-bit write to it will overflow.

  MFC r367322 (by dim):

  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

Changes:
_U  stable/11/
  stable/11/contrib/elftoolchain/.cirrus.yml
  stable/11/contrib/elftoolchain/README.rst
  stable/11/contrib/elftoolchain/addr2line/addr2line.1
  stable/11/contrib/elftoolchain/addr2line/addr2line.c
  stable/11/contrib/elftoolchain/ar/ar.1
  stable/11/contrib/elftoolchain/ar/ar.5
  stable/11/contrib/elftoolchain/ar/ar.c
  stable/11/contrib/elftoolchain/ar/ar.h
  stable/11/contrib/elftoolchain/ar/ranlib.1
  stable/11/contrib/elftoolchain/ar/read.c
  stable/11/contrib/elftoolchain/ar/write.c
  stable/11/contrib/elftoolchain/common/_elftc.h
  stable/11/contrib/elftoolchain/common/elfdefinitions.h
  stable/11/contrib/elftoolchain/common/native-elf-format
  stable/11/contrib/elftoolchain/cxxfilt/c++filt.1
  stable/11/contrib/elftoolchain/elfcopy/ascii.c
  stable/11/contrib/elftoolchain/elfcopy/binary.c
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.1
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/11/contrib/elftoolchain/elfcopy/main.c
  stable/11/contrib/elftoolchain/elfcopy/mcs.1
  stable/11/contrib/elftoolchain/elfcopy/sections.c
  stable/11/contrib/elftoolchain/elfcopy/segments.c
  stable/11/contrib/elftoolchain/elfcopy/strip.1
  stable/11/contrib/elftoolchain/elfdump/elfdump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf.h
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_producer.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_reference.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_directory_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_addr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_gen.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_fde_inst.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_file_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_cie.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_funcname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_pubname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_typename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_varname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_weakname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrlist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attroffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrval_signed.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_child.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dealloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_link.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_diename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dieoffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_end_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errmsg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_current_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_into_block.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_finish.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formaddr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formblock.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formexprloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formflag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formstring.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formudata.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_address_size.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_index.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_elf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_list.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_n.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_range.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_form_class.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_funcs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_globals.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_loclist_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_macro_details.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_pubtypes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_str.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_types.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_vars.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_weaks.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasform.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_highpc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lineno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_end_sequence.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_set_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist_from_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_die.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_types_section.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_object_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_set_isa.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_reset_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_reloc_application.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_seterrarg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srcfiles.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srclines.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_start_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_undef_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_vendor_ext.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_attr.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_die.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_frame.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_lineno.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
  stable/11/contrib/elftoolchain/libelf/Makefile
  stable/11/contrib/elftoolchain/libelf/Version.map
  stable/11/contrib/elftoolchain/libelf/_libelf.h
  stable/11/contrib/elftoolchain/libelf/_libelf_config.h
  stable/11/contrib/elftoolchain/libelf/elf.3
  stable/11/contrib/elftoolchain/libelf/elf_begin.3
  stable/11/contrib/elftoolchain/libelf/elf_cntl.3
  stable/11/contrib/elftoolchain/libelf/elf_data.c
  stable/11/contrib/elftoolchain/libelf/elf_end.3
  stable/11/contrib/elftoolchain/libelf/elf_end.c
  stable/11/contrib/elftoolchain/libelf/elf_errmsg.3
  stable/11/contrib/elftoolchain/libelf/elf_fill.3
  stable/11/contrib/elftoolchain/libelf/elf_flagdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getarhdr.3
  stable/11/contrib/elftoolchain/libelf/elf_getarsym.3
  stable/11/contrib/elftoolchain/libelf/elf_getbase.3
  stable/11/contrib/elftoolchain/libelf/elf_getdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.c
  stable/11/contrib/elftoolchain/libelf/elf_getphdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getphnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getscn.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_getshnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_hash.3
  stable/11/contrib/elftoolchain/libelf/elf_kind.3
  stable/11/contrib/elftoolchain/libelf/elf_memory.3
  stable/11/contrib/elftoolchain/libelf/elf_next.3
  stable/11/contrib/elftoolchain/libelf/elf_next.c
  stable/11/contrib/elftoolchain/libelf/elf_open.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.c
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.3
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.c
  stable/11/contrib/elftoolchain/libelf/elf_scn.c
  stable/11/contrib/elftoolchain/libelf/elf_strptr.3
  stable/11/contrib/elftoolchain/libelf/elf_update.3
  stable/11/contrib/elftoolchain/libelf/elf_update.c
  stable/11/contrib/elftoolchain/libelf/elf_version.3
  stable/11/contrib/elftoolchain/libelf/gelf.3
  stable/11/contrib/elftoolchain/libelf/gelf.h
  stable/11/contrib/elftoolchain/libelf/gelf_cap.c
  stable/11/contrib/elftoolchain/libelf/gelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/gelf_checksum.3
  stable/11/contrib/elftoolchain/libelf/gelf_dyn.c
  stable/11/contrib/elftoolchain/libelf/gelf_fsize.3
  stable/11/contrib/elftoolchain/libelf/gelf_getcap.3
  stable/11/contrib/elftoolchain/libelf/gelf_getchdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getclass.3
  stable/11/contrib/elftoolchain/libelf/gelf_getdyn.3
  stable/11/contrib/elftoolchain/libelf/gelf_getehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getmove.3
  stable/11/contrib/elftoolchain/libelf/gelf_getphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrel.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrela.3
  stable/11/contrib/elftoolchain/libelf/gelf_getshdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsym.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsyminfo.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsymshndx.3
  stable/11/contrib/elftoolchain/libelf/gelf_move.c
  stable/11/contrib/elftoolchain/libelf/gelf_newehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_newphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_rel.c
  stable/11/contrib/elftoolchain/libelf/gelf_rela.c
  stable/11/contrib/elftoolchain/libelf/gelf_sym.c
  stable/11/contrib/elftoolchain/libelf/gelf_syminfo.c
  stable/11/contrib/elftoolchain/libelf/gelf_symshndx.c
  stable/11/contrib/elftoolchain/libelf/gelf_update_ehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/gelf_xlatetof.3
  stable/11/contrib/elftoolchain/libelf/libelf.h
  stable/11/contrib/elftoolchain/libelf/libelf_allocate.c
  stable/11/contrib/elftoolchain/libelf/libelf_ar.c
  stable/11/contrib/elftoolchain/libelf/libelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_convert.m4
  stable/11/contrib/elftoolchain/libelf/libelf_data.c
  stable/11/contrib/elftoolchain/libelf/libelf_ehdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_elfmachine.c
  stable/11/contrib/elftoolchain/libelf/libelf_extended.c
  stable/11/contrib/elftoolchain/libelf/libelf_memory.c
  stable/11/contrib/elftoolchain/libelf/libelf_msize.m4
  stable/11/contrib/elftoolchain/libelf/libelf_phdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/os.Linux.mk
  stable/11/contrib/elftoolchain/libelftc/_libelftc.h
  stable/11/contrib/elftoolchain/libelftc/elftc.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/elftc_copyfile.3
  stable/11/contrib/elftoolchain/libelftc/elftc_demangle.3
  stable/11/contrib/elftoolchain/libelftc/elftc_reloc_type_str.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table_create.3
  stable/11/contrib/elftoolchain/libelftc/elftc_timestamp.3
  stable/11/contrib/elftoolchain/libelftc/elftc_version.3
  stable/11/contrib/elftoolchain/libelftc/libelftc.h
  stable/11/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_arm.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_vstr.c
  stable/11/contrib/elftoolchain/libelftc/make-toolchain-version
  stable/11/contrib/elftoolchain/libpe/pe_symtab.c
  stable/11/contrib/elftoolchain/nm/nm.1
  stable/11/contrib/elftoolchain/nm/nm.c
  stable/11/contrib/elftoolchain/readelf/readelf.1
  stable/11/contrib/elftoolchain/readelf/readelf.c
  stable/11/contrib/elftoolchain/size/size.c
  stable/11/contrib/elftoolchain/strings/strings.c
  stable/11/lib/libelf/Makefile
  stable/11/lib/libelftc/Makefile
  stable/11/lib/libelftc/elftc_version.c
  stable/11/sys/sys/elf_common.h
  stable/11/usr.bin/readelf/Makefile
Comment 39 commit-hook freebsd_committer freebsd_triage 2020-11-07 23:58:20 UTC
A commit references this bug:

Author: dim
Date: Sat Nov  7 23:58:00 UTC 2020
New revision: 367466
URL: https://svnweb.freebsd.org/changeset/base/367466

Log:
  Sync up elftoolchain with head, except for the capsicum-related commits,
  which are incompatible with stable/11.

  MFC r308465 (by emaste):

  c++filt: flush output after newline

  Some tools spawn c++filt and pass it a single line at a time for
  demangling. This is akin to r276689 for addr2line.

  Sponsored by:	The FreeBSD Foundation

  MFC r317626 (by emaste):

  revert r308465: c++filt: flush output after newline

  The ELF Tool Chain update to r3520 uses setvbuf to set line buffering.

  Sponsored by:	The FreeBSD Foundation

  MFC r340746 (by oshogbo):

  strings: fix style nits

  Reviewed by:	cem, emaste, Joseph Koshy <jkoshy@users.sourceforge.net>
  Differential Revision:	https://reviews.freebsd.org/D18036

  MFC r340750 (by mjg):

  strings: unbreak the build after r340746

  Discussed with:	oshogbo
  Sponsored by:	The FreeBSD Foundation

  MFC r342918 (by emaste):

  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

  MFC r343592 (by emaste):

  readelf: decode flag bits in DT_FLAGS/DT_FLAGS_1

  Decode d_val when the tag is DT_FLAGS or DT_FLAGS_1 based on the
  information at:

  https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html

  PR:		232983
  Submitted by:	Bora Ozarslan borako.ozarslan@gmail.com
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D18784

  MFC r343593 (by emaste):

  readelf: fix i386 build

  Use %jx and (uintmax_t) cast.

  PR:		232983
  Sponsored by:	The FreeBSD Foundation

  MFC r343614 (by emaste):

  readelf: dump elf note data

  Output format is compatible with GNU readelf's handling of unknown note
  types (modulo a GNU char signedness bug); future changes will add type-
  specific decoding.

  Reviewed by:	kib
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation

  MFC r343665 (by emaste):

  readelf: use table-based DT_FLAGS and DT_FLAGS_1 decoding

  Fewer lines of code and more maintainable.

  Reviewed by:	brooks, kib
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19053

  MFC r343669 (by emaste):

  readelf: decode FreeBSD note types

  Decode NT_FREEBSD_ABI_TAG, NT_FREEBSD_ARCH_TAG, and NT_FREEBSD_FEATURE_CTL.

  Reviewed by:	brooks, kib (earlier)
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19054

  MFC r345360 (by oshogbo):

  strings: do not depend on stdin

  Instead of depending on one stdin FILE structure and use freopen(3), pass to
  the functions appropriate FILE structure.

  Reviewed by:	cem
  Discussed with:	emaste
  Differential Revision:	https://reviews.freebsd.org/D18037

  MFC r345361 (by oshogbo):

  strings: do not continue if getc or getcharacter returns EOF

  Reported by:	cem

  MFC r345362 (by oshogbo):

  Fix powerpc and arm builds after r345361.

  Reported by:	jenkins

  MFC r345364 (by oshogbo):

  In case of ENCODING_8BIT the EOF code will be pass to putchar.
  EOF check should be done before (uint8_t)c > 127 test.

  Reported by:	cem

  MFC r345431 (by oshogbo):

  strings: return an error code and the char value separately

  If we returning 32 bits value it's hard to distinguish if the returned value
  is a valid one or if its an error (in case of EOF). For that reason separate
  exit code of the function from the returned character.

  Reported by:	cem, se

  MFC r345593 (by markj):

  Prepend DW_AT_comp_dir to relative line number directory table entries.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19705

  MFC r345646 (by emaste):

  readelf: add newline after dumping dynamic FLAGS / FLAGS_1

  All three dump_flags() callers need a newline after printing the flags.

  Sponsored by:	The FreeBSD Foundation

  MFC r346323 (by emaste):

  readelf: speed up readelf -wo

  Use an array instead of STAILQ, and sort at the end instead of while
  adding new elements.

  PR:		212539
  Submitted by:	Bora ?zarslan <borako.ozarslan@gmail.com>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation

  MFC r346327 (by emaste):

  readelf: use size_t for object counts

  PR:		212539
  Reported by:	cem
  Sponsored by:	The FreeBSD Foundation

  MFC r348347 (by jhibbits):

  Add missing powerpc64 relocation support to libdwarf

  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

  MFC r348430 (by markj):

  elfcopy: Remove an unneeded memset.

  Reviewed by:	emaste, trasz
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20445

  MFC r348431 (by markj):

  elfcopy: Optimize for insertions at the end of the section list.

  This is the common case when strip(1) is creating the output file.
  The change provides a significant speedup when running on ELF files with
  many sections.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20444

  MFC r348443 (by markj):

  readelf: Make -t imply -S, for compatibility with GNU binutils.

  Reported by:	jhb
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20475

  MFC r348444 (by markj):

  libelftc: Add MLINKS.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20474

  MFC r348652 (by markj):

  libelf: Use a red-black tree to manage the section list.

  The tree is indexed by section number.  This speeds up elf_getscn()
  and its callers, which previously had to traverse a linked list. In
  particular, since .shstrtab is often the last section in a file,
  elf_strptr() would have to traverse the entire list.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20443

  MFC r348654 (by markj):

  elfcopy: Use elf_getscn() instead of iterating over all sections.

  When removing a section, we would loop over all sections looking for
  a corresponding relocation section.  With r348652 it is much faster
  to just use elf_getscn().

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20471

  MFC r348655 (by markj):

  libelftc: Fix some minor style bugs.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20472

  MFC r348657 (by markj):

  elfcopy: Use libelftc's string table routines to build .shstrtab.

  This replaces some hand-rolled routines and is substantially faster
  since libelftc uses a hash table for lookups and insertions, whereas
  elfcopy would perform a linear scan of the table.

  PR:		234949
  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20473

  MFC r348776 (by csjp):

  Teach readelf about some OpenBSD ELF program headers

  - Add constants for OpenBSD wxneeded, bootdata and randomize to the
    FreeBSD elf_common.h file. This is the file that gets used by the
    elftoolchain library.
  - Update readelf and elfdump utilities to decode these program headers
    if they are encountered.

  Note: FreeBSD has it's own version of elfdump(1), which will be updated
  in a subsequent commit. I am adding it here anyway because this diff is
  going to be submitted upstream.

  Discussed with:	emaste
  Reviewed by:	imp
  Differential Revision:	https://reviews.freebsd.org/D20548

  MFC r349420 (by markj):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20760

  MFC r349421 (by markj):

  libelftc: Consistently use size_t for string table offsets and sizes.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20702

  MFC r349422 (by markj):

  libelftc: Fix the documented prototype for elftc_string_table_destroy().

  Sponsored by:	The FreeBSD Foundation

  MFC r349423 (by markj):

  elfcopy: Provide a size hint when creating the section string table.

  Use the input file's .shstrtab size as the hint if it exists.  This
  gives a small performance improvement when processing files with
  many sections.

  Reviewed by:	emaste
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20544

  MFC r349424 (by markj):

  libdwarf: Use the cached strtab pointer when reading string attributes.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20759

  MFC r349481 (by mhorne):

  Add some missing RISC-V ELF defines

  This adds defines for the RISC-V specific e_flags values, and some of
  the missing static relocations.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20766

  MFC r349482 (by mhorne):

  readelf: Add support for RISC-V specific e_flags

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20767

  MFC r349483 (by mhorne):

  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)
  Differential Revision:	https://reviews.freebsd.org/D20768

  MFC r349510 (by luporl):

  [PowerPC64] readelf: print description for 'e_flags' in ELF header (ABI type)

  This prints out description text with the meaning of 'Flags' value in PowerPC64.

  Example:

  $ readelf -h ~/tmp/t1-Flag2
  ELF Header:

  Magic:   7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, big endian
  Version:                           1 (current)
  OS/ABI:                            FreeBSD
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           PowerPC 64-bit
  Version:                           0x1
  Entry point address:               0x10010000
  Start of program headers:          64 (bytes into file)
  Start of section headers:          209368 (bytes into file)
  Flags:                             0x2, OpenPOWER ELF V2 ABI
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         10
  Size of section headers:           64 (bytes)
  Number of section headers:         34
  Section header string table index: 31

  Submitted by:	 alfredo.junior_eldorado.org.br
  Reviewed by:	luporl
  Differential Revision:	https://reviews.freebsd.org/D20782

  MFC r349562 (by mhorne):

  elftoolchain: fix an incorrect e_flags description

  r349482 introduced the definitions and descriptions of the RISC-V
  specific e_flags values to elftoolchain. However, the description for
  the EF_RISCV_RVE flag was incorrectly duplicated from EF_RISCV_RVC. Fix
  this by providing the proper description for this flag.

  Reported by:	jhb
  Approved by:	markj (mentor)

  MFC r349563 (by mhorne):

  readelf: Add RISC-V DWARF register aliases

  This allows DWARF debugging output to use the common register
  mneumonics, such as ra, sp, or t0.

  DWARF registers 0-31 are mapped to the 32 general purpose registers,
  which are then followed by the 32 floating point registers.

  Reviewed by:	markj
  Approved by:	markj (mentor)
  Differential Revision:	https://reviews.freebsd.org/D20779

  MFC r349577 (by arichardson):

  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

  MFC r349730 (by markj):

  elfcopy: Clear errors after fetching the shstrtab index.

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20852

  MFC r350432 (by markj):

  Merge r3778 and r3779 from ELFToolchain.

  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.

  Sponsored by:	The FreeBSD Foundation

  MFC r350511 (by emaste):

  readelf: decode NT_GNU_PROPERTY_TYPE_0 / GNU_PROPERTY_X86_FEATURE_1_AND

  These bits are used for Intel CET IBT/Shadow Stack.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D20516

  MFC r350679 (by markj):

  Merge r3780 from elftoolchain.

  Adjust argc and argv by optind before using them.  This slightly
  simplifies the code.  No functional change intended.

  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D21079

  MFC r352875 (by ray):

  ections into expected offset in binary format.
  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
  Differential Revision:	D21827

  MFC r352878 (by ray):

  Initialize baseaddr to suppres warning.

  Pointy hat to:	ray

  MFC r352908 (by markj):

  nm: Adjust argc and argv in get_opt().

  This refactoring makes it slightly easier to capsicumize nm(1).

  Discussed with:	emaste
  Sponsored by:	The FreeBSD Foundation

  MFC r354544 (by emaste):

  elfcopy/strip: Ensure sections have required alignment on output

  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

  MFC r354842 (by jhibbits):

  ELF toolchain: Add PowerPC VMX and VSX note decode to readelf

  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

  MFC r355413 (by emaste):

  Update ELF Tool Chain to upstream r3769

  This contains many small bugfixes and documentation improvements.

  Sponsored by:	The FreeBSD Foundation

  MFC r357450 (by markj):

  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>
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23418

  MFC r357462 (by markj):

  addr2line: Avoid a name collision.

  The RB_ macros define functions with a parameter named head, and gcc
  warns about this.

  MFC r357531 (by markj):

  libdwarf: Remove unnecessary NULL checks.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357532 (by markj):

  libdwarf: Fix a possible memory leak in dwarf_add_AT_location_expr().

  CID:		1193364
  Sponsored by:	The FreeBSD Foundation

  MFC r357533 (by markj):

  libdwarf: Make an out-pointer of _dwarf_abbrev_add() mandatory.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357534 (by markj):

  libdwarf: Fix a memory leak in _dwarf_frame_section_init().

  If frame length validation failed we would leak memory.

  CID:		1193366
  Sponsored by:	The FreeBSD Foundation

  MFC r357535 (by markj):

  libelftc: Fix memory leaks in the C++ demanglers.

  CID:		1262518, 1262519, 1262520, 1262529
  Sponsored by:	The FreeBSD Foundation

  MFC r357536 (by markj):

  libelftc: Add a missing check for an error from vector_str_init().

  While here consistently use the same spelling for such checks.

  CID:		1376769
  Sponsored by:	The FreeBSD Foundation

  MFC r357537 (by markj):

  elfcopy: Handle multiple data descriptors properly.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357538 (by markj):

  elfcopy: Avoid leaking dst's fd when we fail to copy a file.

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357539 (by markj):

  size: Avoid returning a stack pointer from xlatetom().

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r357540 (by markj):

  readelf: Fix a double close of the input file.

  The caller of dump_object() is responsible for opening the file, let it
  be responsible for closing too.

  CID:		1411588
  Sponsored by:	The FreeBSD Foundation

  MFC r357541 (by markj):

  readelf: Fix the check for an error from realloc().

  Use err() instead of errx() while here, since realloc() sets errno.

  CID:		1401326
  Sponsored by:	The FreeBSD Foundation

  MFC r357542 (by markj):

  readelf: Don't leak memory when dwarf_get_fde_info_for_all_regs() fails.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r357826 (by emaste):

  elfcopy: set ELF OS/ABI field when converting from binary

  PR:		228934
  Submitted by:	Tiger Gao <tig@freebsdfoundation.org>
  Reviewed by:	markj, jkoshy
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23504

  MFC r357844 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D23501

  MFC r357862 (by emaste):

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358499 (by emaste):

  readelf: add PROTMAX_DISABLE and STKGAP_DISABLE

  From r349609 (PROTMAX_DISABLE) and r354790 (STKGAP_DISABLE).  Commited
  upstream (in a slightly different form) as r3831.

  Sponsored by:	The FreeBSD Foundation

  MFC r358631 (by emaste):

  Reserve WXNEEDED ELF feature control flag

  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

  MFC r358637 (by emaste):

  readelf: check note namesz and descsz

  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
  Sponsored by:	The FreeBSD Foundation

  MFC r358639 (by emaste):

  readelf: simplify namesz / descsz checks

  Sponsored by:	The FreeBSD Foundation

  MFC r358685 (by emaste):

  libelf: rationalize error handling in ELF note conversion

  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

  MFC r358706 (by emaste):

  readelf: add XEN_ELFNOTE_PHYS32_ENTRY note

  See r336469 for details.

  Sponsored by:	The FreeBSD Foundation

  MFC r358708 (by emaste):

  readelf: decode and print Xen ELF note strings

  Sponsored by:	The FreeBSD Foundation

  MFC r358713 (by emaste):

  readelf: print GNU Build-ID

  Sponsored by:	The FreeBSD Foundation

  MFC r358778 (by emaste):

  readelf: hoist file opening out of dump_object

  Diff reduction with HEAD to facilitate other MFCs.

  MFC r359166 (by emaste):

  objcopy: add new sections also when there is no .shstrtab

  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

  MFC r359172 (by markj):

  libdwarf: Make an out-pointer assignment unconditional.

  There is no reason for diep to ever be NULL, since in that case we would
  simply be leaking memory.

  CID:		1418801
  Sponsored by:	The FreeBSD Foundation

  MFC r359173 (by markj):

  libpe: Avoid a potential use-after-free in pe_update_symtab().

  This function appears to be unused within FreeBSD and ELFToolChain.

  CID:		1418982
  Sponsored by:	The FreeBSD Foundation

  MFC r359174 (by markj):

  readelf: Avoid leaking ELF descriptors for archive entries.

  CID:		1292494
  Sponsored by:	The FreeBSD Foundation

  MFC r359175 (by markj):

  readelf: Fix another instance of the leak mentioned in r357542.

  CID:		1292493
  Sponsored by:	The FreeBSD Foundation

  MFC r359176 (by markj):

  libelftc: Fix a memory leak in cpp_demangle_read_type().

  CID:		1305425
  Sponsored by:	The FreeBSD Foundation

  MFC r359189 (by emaste):

  readelf: simplify Xen string note printing

  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24140

  MFC r361104 (by jhibbits):

  elftoolchain: Add powerpc64 definition to elftoolchain config

  powerpc is already in place, but powerpc64 is needed separately.

  MFC r361662 (by emaste):

  readelf: add more DT_FLAGS_1 flags

  Reference:
  https://docs.oracle.com/cd/E36784_01/html/E36857/chapter6-42444.html

  > DF_1_SINGLETON  Singleton symbols exist.
  > DF_1_STUB       Object is a stub.
  > DF_1_PIE        Object is a position-independent executable.

  Sponsored by:	The FreeBSD Foundation

  MFC r365489 (by bdragon):

  [PowerPC64LE] PPC64LE support for libelf.

  Fix native detection when building on powerpc64le.

  I will be submitting this and r361104 upstream shortly.

  Sponsored by:	Tag1 Consulting, Inc.

  MFC r366977 (by emaste):

  libelf: add compression header support

  GNU and Oracle libelf implementations added support for section
  compression, intended to reduce the size of DWARF debug info (which
  might be an order of magnitude larger than the code).

  There are two compressed ELF section formats:

  1. Old GNU - sections are renmaed to start with 'z'.  Section contains
     a magic number, uncompressed size, and compressed data.

  2. Oracle and New GNU - compressed sections use the SHF_COMPRESSED flag.
     The compression header contains the compression type, uncompressed
     size, and uncompressed alignment.

  The second style is preferred and this change implements only that one.

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D24566

  MFC r367209 (by emaste):

  readelf: Add -z decompression support

  Compatible with GNU readelf, -z decompresses sections displayed by
  -x or -p.

  ELF Tool Chain ticket #555
  https://sourceforge.net/p/elftoolchain/tickets/555/

  Submitted by:	Tiger Gao <tig@FreeBSDFoundation.org>
  Reviewed by:	markj
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:    https://reviews.freebsd.org/D26909

  MFC r367238 (by bdragon):

  Fix 32-bit build after r367209

  Fix build on systems with a 32-bit size_t.

  Since it's being passed as a pointer, a 64-bit write to it will overflow.

  MFC r367322 (by dim):

  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

Changes:
_U  stable/11/
  stable/11/contrib/elftoolchain/.cirrus.yml
  stable/11/contrib/elftoolchain/README.rst
  stable/11/contrib/elftoolchain/addr2line/addr2line.1
  stable/11/contrib/elftoolchain/addr2line/addr2line.c
  stable/11/contrib/elftoolchain/ar/ar.1
  stable/11/contrib/elftoolchain/ar/ar.5
  stable/11/contrib/elftoolchain/ar/ar.c
  stable/11/contrib/elftoolchain/ar/ar.h
  stable/11/contrib/elftoolchain/ar/ranlib.1
  stable/11/contrib/elftoolchain/ar/read.c
  stable/11/contrib/elftoolchain/ar/write.c
  stable/11/contrib/elftoolchain/common/_elftc.h
  stable/11/contrib/elftoolchain/common/elfdefinitions.h
  stable/11/contrib/elftoolchain/common/native-elf-format
  stable/11/contrib/elftoolchain/cxxfilt/c++filt.1
  stable/11/contrib/elftoolchain/elfcopy/ascii.c
  stable/11/contrib/elftoolchain/elfcopy/binary.c
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.1
  stable/11/contrib/elftoolchain/elfcopy/elfcopy.h
  stable/11/contrib/elftoolchain/elfcopy/main.c
  stable/11/contrib/elftoolchain/elfcopy/mcs.1
  stable/11/contrib/elftoolchain/elfcopy/sections.c
  stable/11/contrib/elftoolchain/elfcopy/segments.c
  stable/11/contrib/elftoolchain/elfcopy/strip.1
  stable/11/contrib/elftoolchain/elfdump/elfdump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf.h
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_comp_dir.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_const_value_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_dataref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_location_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_producer.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_ref_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_reference.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_signed_const.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_string.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_AT_targ_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_die_to_debug.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_directory_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_addr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_expr_gen.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_fde_inst.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_file_decl.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_cie.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_frame_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_funcname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_pubname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_typename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_varname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_add_weakname.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrlist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attroffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_attrval_signed.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_child.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dealloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_die_link.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_diename.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dieoffset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_dump.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_end_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errmsg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_errno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_current_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_expr_into_block.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_fde_cfa_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_find_macro_value_start.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_finish.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formaddr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formblock.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formexprloc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formflag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formref.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formstring.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_formudata.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_AT_name.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_children_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_code.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_abbrev_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_address_size.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_arange_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_aranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_index.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cie_of_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_cu_die_offset.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_die_infotypes_flag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_elf.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_at_pc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_cfa_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg3.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_instr_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_list.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_n.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_fde_range.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_form_class.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_funcs.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_globals.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_loclist_entry.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_macro_details.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_pubtypes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_relocation_info_count.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_section_max_offsets.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_str.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_types.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_vars.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_get_weaks.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_hasform.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_highpc.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lineno.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_end_sequence.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_lne_set_address.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_loclist_from_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_die.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_expr.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_new_fde.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_next_types_section.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_object_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_attr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_pro_expr.c
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_producer_set_isa.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_reset_section_bytes.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_frame_cfa_value.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_set_reloc_application.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_seterrarg.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srcfiles.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_srclines.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_start_macro_file.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_tag.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_transform_to_disk_form.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_undef_macro.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_vendor_ext.3
  stable/11/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_abbrev.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_attr.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_die.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_frame.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_lineno.c
  stable/11/contrib/elftoolchain/libdwarf/libdwarf_reloc.c
  stable/11/contrib/elftoolchain/libelf/Makefile
  stable/11/contrib/elftoolchain/libelf/Version.map
  stable/11/contrib/elftoolchain/libelf/_libelf.h
  stable/11/contrib/elftoolchain/libelf/_libelf_config.h
  stable/11/contrib/elftoolchain/libelf/elf.3
  stable/11/contrib/elftoolchain/libelf/elf_begin.3
  stable/11/contrib/elftoolchain/libelf/elf_cntl.3
  stable/11/contrib/elftoolchain/libelf/elf_data.c
  stable/11/contrib/elftoolchain/libelf/elf_end.3
  stable/11/contrib/elftoolchain/libelf/elf_end.c
  stable/11/contrib/elftoolchain/libelf/elf_errmsg.3
  stable/11/contrib/elftoolchain/libelf/elf_fill.3
  stable/11/contrib/elftoolchain/libelf/elf_flagdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getarhdr.3
  stable/11/contrib/elftoolchain/libelf/elf_getarsym.3
  stable/11/contrib/elftoolchain/libelf/elf_getbase.3
  stable/11/contrib/elftoolchain/libelf/elf_getdata.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.3
  stable/11/contrib/elftoolchain/libelf/elf_getident.c
  stable/11/contrib/elftoolchain/libelf/elf_getphdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getphnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getscn.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshdrstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_getshnum.3
  stable/11/contrib/elftoolchain/libelf/elf_getshstrndx.3
  stable/11/contrib/elftoolchain/libelf/elf_hash.3
  stable/11/contrib/elftoolchain/libelf/elf_kind.3
  stable/11/contrib/elftoolchain/libelf/elf_memory.3
  stable/11/contrib/elftoolchain/libelf/elf_next.3
  stable/11/contrib/elftoolchain/libelf/elf_next.c
  stable/11/contrib/elftoolchain/libelf/elf_open.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.3
  stable/11/contrib/elftoolchain/libelf/elf_rand.c
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.3
  stable/11/contrib/elftoolchain/libelf/elf_rawfile.c
  stable/11/contrib/elftoolchain/libelf/elf_scn.c
  stable/11/contrib/elftoolchain/libelf/elf_strptr.3
  stable/11/contrib/elftoolchain/libelf/elf_update.3
  stable/11/contrib/elftoolchain/libelf/elf_update.c
  stable/11/contrib/elftoolchain/libelf/elf_version.3
  stable/11/contrib/elftoolchain/libelf/gelf.3
  stable/11/contrib/elftoolchain/libelf/gelf.h
  stable/11/contrib/elftoolchain/libelf/gelf_cap.c
  stable/11/contrib/elftoolchain/libelf/gelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/gelf_checksum.3
  stable/11/contrib/elftoolchain/libelf/gelf_dyn.c
  stable/11/contrib/elftoolchain/libelf/gelf_fsize.3
  stable/11/contrib/elftoolchain/libelf/gelf_getcap.3
  stable/11/contrib/elftoolchain/libelf/gelf_getchdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getclass.3
  stable/11/contrib/elftoolchain/libelf/gelf_getdyn.3
  stable/11/contrib/elftoolchain/libelf/gelf_getehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getmove.3
  stable/11/contrib/elftoolchain/libelf/gelf_getphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrel.3
  stable/11/contrib/elftoolchain/libelf/gelf_getrela.3
  stable/11/contrib/elftoolchain/libelf/gelf_getshdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsym.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsyminfo.3
  stable/11/contrib/elftoolchain/libelf/gelf_getsymshndx.3
  stable/11/contrib/elftoolchain/libelf/gelf_move.c
  stable/11/contrib/elftoolchain/libelf/gelf_newehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_newphdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_rel.c
  stable/11/contrib/elftoolchain/libelf/gelf_rela.c
  stable/11/contrib/elftoolchain/libelf/gelf_sym.c
  stable/11/contrib/elftoolchain/libelf/gelf_syminfo.c
  stable/11/contrib/elftoolchain/libelf/gelf_symshndx.c
  stable/11/contrib/elftoolchain/libelf/gelf_update_ehdr.3
  stable/11/contrib/elftoolchain/libelf/gelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/gelf_xlatetof.3
  stable/11/contrib/elftoolchain/libelf/libelf.h
  stable/11/contrib/elftoolchain/libelf/libelf_allocate.c
  stable/11/contrib/elftoolchain/libelf/libelf_ar.c
  stable/11/contrib/elftoolchain/libelf/libelf_chdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_convert.m4
  stable/11/contrib/elftoolchain/libelf/libelf_data.c
  stable/11/contrib/elftoolchain/libelf/libelf_ehdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_elfmachine.c
  stable/11/contrib/elftoolchain/libelf/libelf_extended.c
  stable/11/contrib/elftoolchain/libelf/libelf_memory.c
  stable/11/contrib/elftoolchain/libelf/libelf_msize.m4
  stable/11/contrib/elftoolchain/libelf/libelf_phdr.c
  stable/11/contrib/elftoolchain/libelf/libelf_xlate.c
  stable/11/contrib/elftoolchain/libelf/os.Linux.mk
  stable/11/contrib/elftoolchain/libelftc/_libelftc.h
  stable/11/contrib/elftoolchain/libelftc/elftc.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfd_find_target.3
  stable/11/contrib/elftoolchain/libelftc/elftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/elftc_copyfile.3
  stable/11/contrib/elftoolchain/libelftc/elftc_demangle.3
  stable/11/contrib/elftoolchain/libelftc/elftc_reloc_type_str.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.3
  stable/11/contrib/elftoolchain/libelftc/elftc_set_timestamps.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table.c
  stable/11/contrib/elftoolchain/libelftc/elftc_string_table_create.3
  stable/11/contrib/elftoolchain/libelftc/elftc_timestamp.3
  stable/11/contrib/elftoolchain/libelftc/elftc_version.3
  stable/11/contrib/elftoolchain/libelftc/libelftc.h
  stable/11/contrib/elftoolchain/libelftc/libelftc_bfdtarget.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_arm.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu2.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
  stable/11/contrib/elftoolchain/libelftc/libelftc_vstr.c
  stable/11/contrib/elftoolchain/libelftc/make-toolchain-version
  stable/11/contrib/elftoolchain/libpe/pe_symtab.c
  stable/11/contrib/elftoolchain/nm/nm.1
  stable/11/contrib/elftoolchain/nm/nm.c
  stable/11/contrib/elftoolchain/readelf/readelf.1
  stable/11/contrib/elftoolchain/readelf/readelf.c
  stable/11/contrib/elftoolchain/size/size.c
  stable/11/contrib/elftoolchain/strings/strings.c
  stable/11/lib/libelf/Makefile
  stable/11/lib/libelftc/Makefile
  stable/11/lib/libelftc/elftc_version.c
  stable/11/sys/sys/elf_common.h
  stable/11/usr.bin/readelf/Makefile
Comment 40 Niklas Hambüchen 2021-07-06 20:54:14 UTC
For those interested:

I found a 300x performance regression in GNU binutils `strip`:

https://sourceware.org/bugzilla/show_bug.cgi?id=28058