Some architectures use .rel relocations (for debug data), so they must
be handled.
This was discovered from ctfconvert on ARM object files. The lack of
relocation handling caused all string lookups to return the string at
offset 0 in .debug_str, typically "FreeBSD clang version ..."
Reviewed by: gnn, imp, rpaulo (earlier version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1819
Strip is often used to modify existing files, rather than creating new
files. If the existing file has hard links or is a symbolic link, act as
if editing the file in place and preserve the links.
Reported by: luigi
Reviewed by: imp, rpaulo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1682
According to ELF ABI, alignment 0 and 1 has the same meaning: the
section has no alignment constraints.
PR: 196715
Sponsored by: The FreeBSD Foundation
Previously elftoolchain readelf(1) produced correct description text
only for Linux note types.
Upstream elftoolchain ticket #473
Differential Revision: https://reviews.freebsd.org/D1428
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
In general 64-bit ELF notes use 4-byte padding, not 8, despite what is
claimed in various specs.
Upstream elftoolchain ticket 472
https://sourceforge.net/p/elftoolchain/tickets/472/
Sponsored by: The FreeBSD Foundation
The initial fix in r276374 is valid only for 64-bit objects. Revert it
and return an error in CHECK_EHDR if the multiplication would overflow.
The original buffer overflow issue was found with the security/afl
fuzzer and has upstream elftoolchain ticket 462. The 32-bit object issue
with r276374 found by antoine@ during an i386 exp-run.
Sponsored by: The FreeBSD Foundation
This fixes two strip(1) issues found during ports exp-run and adds a
string hash implementation which significantly speeds up certain
operations on objects with large numbers of symbols.
This also improves libdwarf handling for stripped objects with
.eh_frame or .debug_frame (but not other debug) sections.
PR: 196107
Sponsored by: The FreeBSD Foundation
Previously a corrupt ELF file could read beyond the end of e_rawfile.
Upstream elftoolchain ticket 462. Found via the security/afl fuzzer.
Sponsored by: The FreeBSD Foundation
Track r270303:
This provides a minor cleanup in elfdump; there are otherwise no
consumers in the tree. Old SUN documentation can be found for either
variant, but GNU binutils switched to DT_FEATURE around 2000.
Sponsored by: The FreeBSD Foundation
This includes a number of libdwarf improvements (particularly DWARF4
related) and updates to elftoolchain tools such as strip(1). It also
includes a large number of miscellaneous fixes (memory leaks, sign and
cast warnings, integer overflow and underflow, etc.).
This is a merge of r276167,276170-276172 from the
projects/elftoolchain-update-r3130 branch.
Sponsored by: The FreeBSD Foundation
Instead of waiting until the addition of the first non-default entry.
This fixes a segfault when strip(1) is asked to remove every section from
an object file.
Upstream elftoolchain ticket 463
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1341
When requested to strip specific symbols (-N flag) the default should be
to strip nothing (other than the requested symbols). This is consistent
with binutils strip(1).
PR: 196038
Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1327
Calculate the segment's memory size (p_memsz) using the virtual
addresses, not the file offsets. Otherwise padding preceeding SHT_NOBITS
sections may be excluded from the calculation, resulting in a segment
that is too small.
PR: 195653
Sponsored by: The FreeBSD Foundation
The namesz and descsz variables need to be used in native endianness.
The sizes are in native order after swapping in the file to memory case,
and before swapping in the memory to file case.
This issue was identified for r273443, but the change was applied to the
wrong case. Revert r273443 to fix the to-memory case, and apply the
equivalent change to the to-file case.
Sponsored by: DARPA, AFRL
Reviewed by: adrian, brooks, marcel
Differential Revision: https://reviews.freebsd.org/D1257
the ELF file's byte order is not the native byte order. The
bug is that the variables holding the name and description size
are used (natively) after having been byte-swapped. The fix is
to calculate sz from them just prior to byte-swapping.
Approved by: jkoshy@
Obtained from: Juniper Networks, Inc.
running ctfmerge on its objects, libelf asserts as it expects
.note sections to be 4-byte aligned. Change that expectation.
Approved by: jkoshy@
Obtained from: Juniper Networks, Inc.
attributes that have form DW_FORM_sec_offset.
* If the .debug_info section conforms to DWARF4, do not allow the value
of attributes with form DW_FORM_data[48] to be used as section
offset.
(DWARF4) form DW_FORM_flag_present which implicitly indicates the
presence of the attribute. Manual page is updated to reflect this
change.
Note that this was previously fixed in the old libdwarf.
comes with elftoolchain. This version of libelf doesn't need to be
portable; using FreeBSD's own ELF headers will avoid conflicts and
make integration easier.