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
Convert to elf_getshdrstrndx() while here since elf_getshstrndx() is
Obtained from FreeBSD r349730 by markj.
readelf: display NT_GNU_PROPERTY_TYPE_0 note name
NT_GNU_PROPERTY_TYPE_0 in a .note.gnu.property section "contains a
program property note which describes special handling requirements
for linker and run-time loader." (from the System V Application Binary
Interface - Linux Extensions")
Intel CET uses two processor-specific program properties in
NT_GNU_PROPERTY_TYPE_0: GNU_PROPERTY_X86_FEATURE_1_IBT to indicate that
all executable sections are compatible with Indirect Branch Tracking,
and GNU_PROPERTY_X86_FEATURE_1_SHSTK to indicate that sections are
compatible with shadow stack.
A later change should add decoding of the individual properties.
Obtained from FreeBSD r337569 by emaste.
readelf: print description for 'e_flags' in ELF header (ABI type)
This prints out description text with the meaning of 'Flags' value in
Submitted by alfredo.junior_eldorado.org.br
Obtained from FreeBSD r349510 by luporl.
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-
Obtained from FreeBSD r343614 by emaste.
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
Obtained from FreeBSD r349423 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.
Obtained from FreeBSD r348657 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().
Obtained from FreeBSD r348654 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
Obtained from FreeBSD r348431 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
Obtained from FreeBSD r349424 by markj.