As of LLVM revision 238073, LLVM stores symbols and section names in
the same string table. From the upstream commit mesage:
With the scheme of naming sections like ".text.foo" where foo is a
symbol, there is a big potential saving in using a single one.
This is a cherry-pick of ELF Tool Chain revision 3225.
Sponsored by: The FreeBSD Foundation
Highlights (upstream revisions):
- Fix SHT_GROUP handling in elfcopy/strip (3206 3220 3221)
- Misc elfcopy / strip bug fixes (3215 3216 3217)
- Many C++ demangler improvements (3199 3200 3201 3202 3203 3204 3205
3208 3210 3211 3212)
- Improve GNU binutils compatibility in elfcopy / strip (3213 3214)
- Add -g option to readelf(1): dump contents of section groups (3219)
- Add EM_IAMCU 32-bit Intel MCU (3198)
Also add a compat #define for building with older FreeBSD ELF headers.
The GRP_COMDAT flag was added to elf_common.h in r283110, but it's not
available during the bootstrap build. It is also convenient to be able
to build on older hosts.
Thanks to antoine@ for tracking down issues through multiple exp-runs
and to kaiw@ for fixing.
PR: 198611 (exp-run), 200350
Sponsored by: The FreeBSD Foundation
Highlights:
- Fix man page markup, whitespace, and typos
- Fix sh_info of SHT_GROUP section to point to the correct string
- Improve validation in readelf and elfcopy/strip
- Handle DWARF 4's DW_AT_high_pc in addr2line
Sponsored by: The FreeBSD Foundation
This can occur when DW_AT_specification is used to refer to another DIE
that provides the actual DW_AT_name string. For example:
< 3><0x00000086> DW_TAG_subprogram
DW_AT_name PrettyStackTraceEntry
...
< 1><0x00002cf4> DW_TAG_subprogram
DW_AT_specification <0x00000086>
We will need to add support for DW_AT_specification, but in the interim
we should not segfault.
Obtained from: Elftoolchain (r3170)
Sponsored by: The FreeBSD Foundation
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.