Age | Commit message (Collapse) | Author | Files | Lines |
|
|
|
|
|
Add missing bounds check, and tidy the existing bounds checking.
* ecoff.c (_bfd_ecoff_slurp_symbol_table): Break overlong lines.
Set bfd_error. Bounds check internal_sym.iss.
|
|
|
|
|
|
* dwarf1.c (_bfd_dwarf1_find_nearest_line): Exclude .debug
sections without contents.
|
|
|
|
Commit 43025f01a0c9 ("RISC-V: Improve link time complexity.") reduced the
time complexity of the linker relaxation but some code portions did not
reflect this change.
This commit fixes a comment describing each relaxation pass and reduces
actual number of passes for the RISC-V linker relaxation from 3 to 2.
Though it does not change the functionality, it marginally improves the
performance while linking large programs (with many relocations).
bfd/ChangeLog:
* elfnn-riscv.c (_bfd_riscv_relax_section): Fix a comment to
reflect current roles of each relaxation pass.
ld/ChangeLog:
* emultempl/riscvelf.em: Reduce the number of linker relaxation
passes from 3 to 2.
|
|
The main one here is the section buffer, which can be quite large.
By using alloc rather than malloc we can leave tidying memory to the
generic bfd code when the bfd is closed. bfd_check_format also
releases memory when object_p fails, so while it wouldn't be wrong
to bfd_release at bad_format_free in mmo_object_p, it's a little extra
code and work for no gain.
* mmo.c (mmo_object_p): bfd_alloc rather than bfd_malloc
lop_stab_symbol. Don't free/release on error.
(mmo_get_spec_section): bfd_zalloc rather than bfd_zmalloc
section buffer.
(mmo_scan): Free fname on another error path.
|
|
Anti-fuzzer measure. I'm not sure what the correct fix is for
objcopy. Probably the BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS,
BFD_MACH_O_S_LAZY_SYMBOL_POINTERS and BFD_MACH_O_S_SYMBOL_STUBS
contents should be read.
* mach-o.c (bfd_mach_o_section_get_nbr_indirect): Omit sections
with NULL sec->indirect_syms.
|
|
|
|
keep_relocs is set by pe_ILF_save_relocs but not used anywhere in the
coff/pe code. It is tested by the xcoff backend but not set.
keep_contents is only used by the xcoff backend when dealing with
the .loader section, and it's easy enough to dispense with it there.
keep_contents is set in various places but that's fairly useless when
the contents aren't freed anyway until later linker support functions,
add_dynamic_symbols and check_dynamic_ar_symbols. There the contents
were freed if keep_contents wasn't set. I reckon we can free them
unconditionally.
* coff-bfd.h (struct coff_section_tdata): Delete keep_relocs
and keep_contents.
* peicode.h (pe_ILF_save_relocs): Don't set keep_relocs.
* xcofflink.c (xcoff_get_section_contents): Cache contents.
Return the contents. Update callers.
(_bfd_xcoff_canonicalize_dynamic_symtab): Don't set
keep_contents for .loader.
(xcoff_link_add_dynamic_symbols): Free .loader contents
unconditionally.
(xcoff_link_check_dynamic_ar_symbols): Likewise.
|
|
|
|
keep_relocs and keep_contents are unused nowadays except by
xcofflink.c, and I can't see a reason why keep_syms needs to be set.
The external syms are read and used by sh_relax_section and used by
sh_relax_delete_bytes. There doesn't appear to be any way that
freeing them will cause trouble.
* coff-sh.c (sh_relax_section): Don't set keep_relocs,
keep_contents or keep_syms.
(sh_relax_delete_bytes): Don't set keep_contents.
|
|
* compress.c (bfd_init_section_compress_status): Free
uncompressed_buffer on error return.
|
|
If file size is calculated by bfd_get_file_size, as it is by
_bfd_alloc_and_read calls in coff_object_p, then it is cached and when
pe_ILF_build_a_bfd converts an archive entry over to BFD_IN_MEMORY,
the file size is no longer valid. Found when attempting objdump -t on
a very small (27 bytes) ILF file and hitting the pr24707 fix (commit
781152ec18f5). So, clear file size when setting BFD_IN_MEMORY on bfds
that may have been read. (It's not necessary in writable bfds,
because caching is ignored by bfd_get_size when bfd_write_p.)
I also think the PR 24707 fix is no longer neeeded. All of the
testcases in that PR and in PR24712 are caught earlier by file size
checks when reading the symbols from file. So I'm reverting that fix,
which just compared the size of an array of symbol pointers against
file size. That's only valid if on-disk symbols are larger than a
host pointer, so the test is better done in format-specific code.
bfd/
* coff-alpha.c (alpha_ecoff_get_elt_at_filepos): Clear cached
file size when making a BFD_IN_MEMORY bfd.
* opncls.c (bfd_make_readable): Likewise.
* peicode.h (pe_ILF_build_a_bfd): Likewise.
binutils/
PR 24707
* objdump.c (slurp_symtab): Revert PR24707 fix. Tidy.
(slurp_dynamic_symtab): Tidy.
|
|
f.bfd_ptr is set too early to be a reliable indicator of good debug
info.
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Correct test for
debug info being previously found.
|
|
|
|
|
|
When using a bss-plt we'll always trigger the RWX warning, which
disturbs gcc test results. On the other hand, there may be reason to
want the warning when gcc is configured with --enable-secureplt.
So turning off the warning entirely for powerpc might not be the best
solution. Instead, we'll turn off the warning whenever a bss-plt is
generated, unless the user explicitly asked for the warning.
bfd/
* elf32-ppc.c (ppc_elf_select_plt_layout): Set
no_warn_rwx_segments on generating a bss plt, unless explicity
enabled by the user. Also show the bss-plt warning when
--warn-rwx-segments is given without --bss-plt.
include/
* bfdlink.h (struct bfd_link_info): Add user_warn_rwx_segments.
ld/
* lexsup.c (parse_args): Set user_warn_rwx_segments.
* testsuite/ld-elf/elf.exp: Pass --secure-plt for powerpc to
the rwx tests.
|
|
There are failure paths in _bfd_dwarf2_slurp_debug_info that can
result in altered section vmas. Also, when setting ET_REL section
vmas it's not too difficult to handle cases where the original vma was
non-zero, so do that too.
This patch was really in response to an addr2line buffer overflow
processing a fuzzed mips relocatable object file. The file had a
number of .debug_info sections with relocations that included lo16 and
hi16 relocs, and in that order. At least one section VMA was
non-zero. This resulted in processing of DWARF info twice, once via
the call to _bfd_dwarf2_find_nearest_line in
_bfd_mips_elf_find_nearest_line, and because that failed leaving VMAs
altered, the second via the call in _bfd_elf_find_nearest_line. The
first call left entries on mips_hi16_list pointing at buffers
allocated during the first call, the second call processed the
mips_hi16_list after the buffers had been freed. (At least when
running with asan and under valgrind. Under gdb with a non-asan
addr2line the second call allocated exactly the same buffer and the
bug didn't show.) Now I don't really care too much what happens with
fuzzed files, but the logic in _bfd_dwarf2_find_nearest_line is meant
to result in only one read of .debug_info, not multiple reads of the
same info when there are errors. This patch fixes that problem.
* dwarf2.c (struct adjusted_section): Add orig_vma.
(unset_sections): Reset vma to it.
(place_sections): Handle non-zero vma too. Save orig_vma.
(_bfd_dwarf2_slurp_debug_info): Tidy. Correct outdated comment.
On error returns after calling place_sections, call
unset_sections.
(_bfd_dwarf2_find_nearest_line_with_alt): Simplify call to
unset_sections.
|
|
|
|
|
|
|
|
Anti-fuzzer measures. The checks don't ensure the various elements in
the header are distinct, but that isn't important as far as making
sure we don't overrun the buffer containing all the elements. Also,
we now don't care about offsets where the corresponding count is zero.
* ecoff.c (_bfd_ecoff_slurp_symbolic_info): Sanity check offsets
in debug->symbolic_header.
|
|
|
|
SFrame format is meant for generating stack traces only.
bfd/
* elf-bfd.h: Replace the use of "unwind" with "stack trace".
* elf-sframe.c: Likewise.
* elf64-x86-64.c: Likewise.
* elfxx-x86.c: Likewise.
include/
* elf/common.h: Likewise.
|
|
|
|
|
|
* merge.c (hash_blob): Write 1u << 31.
|
|
|
|
|
|
|
|
|
|
It seems reasonable to continue after errors in bfd_close_all_done,
particularly since bfd_close_all_done is typically called on an output
file after we've hit some sort of error elsewhere. The iovec test is
necessary if bfd_close_all_done is to work on odd bfd's opened by
bfd_create.
* opncls.c (bfd_close): Call bfd_close_all_done after errors
from _bfd_write_contents.
(bfd_close_all_done): Call _bfd_delete_bfd after errors.
Don't call iovec->bclose when iovec is NULL.
|
|
|
|
* coff-aarch64.c (coff_aarch64_addr32nb_reloc): When output_bfd
is NULL (which it is for objdump -W) get the output bfd via the
input section.
|
|
|
|
|
|
ld PR 29998
* pe-dll.c (generate_reloc): Handle sections
with no assigned output section.
Terminate early of there are no relocs to put
in the .reloc section.
(pe_exe_fill_sections): Do not emit an empty
.reloc section.
bfd * cofflink.c (_bfd_coff_generic_relocate_section):
Add an assertion that the output section is set
for defined, global symbols.
|
|
|
|
This patch adds support for the .secidx directive and its corresponding
relocation to aarch64-w64-mingw32. As with x86, this is a two-byte LE
integer which gets filled in with the 1-based index of the output
section that a symbol ends up in.
This is needed for PDBs, which represent addresses as a .secrel32,
.secidx pair.
The test is substantially the same as for amd64, but with changes made
for padding and alignment.
|
|
|
|
|
|
|
|
* use power-of-two hash table
* use better hash function (hashing 32bits at once and with better
mixing characteristics)
* use input-offset-to-entry maps instead of retaining full input
contents for lookup time
* don't reread SEC_MERGE section multiple times
* care for cache behaviour for the hot lookup routine
The overall effect is less usage in libz and much faster string merging
itself. On a debug-info-enabled cc1 the effect at the time of this
writing on the machine I used was going from 14400 perf samples to 9300
perf samples or from 3.7 seconds to 2.4 seconds, i.e. about 33% .
|
|
|
|
Emit R_386_TLS_LE and R_386_TLS_IE, instead of R_386_TLS_LE_32 and
R_386_TLS_IE_32, on Solaris.
PR ld/13671
* elf32-i386.c (elf_i386_tls_transition): Only emit R_386_TLS_LE,
R_386_TLS_IE on Solaris.
(elf_i386_relocate_section): Only use R_386_TLS_GD->R_386_TLS_LE
transition on Solaris.
Co-Authored-By: H.J. Lu <hjl.tools@gmail.com>
|
|
So let's not copy .libs/libbfd.a to libbfd.a now that nothing in the
binutils-gdb source tries to link against it.
PR 30022
* Makefile.am (noinst_LIBRARIES, libbfd_a_SOURCES, stamp-lib),
(libbfd.a): Delete rules.
(CLEANFILES): Adjust to suit.
|
|
All of them need a bfd_reloc_offset_in_range check before accessing
data + reloc_entry->address. This patch adds the missing checks and
sanity checks reloc offsets in coff_pe_aarch64_relocate_section too.
All of them also need changing to support objdump -W calls to
bfd_simple_get_relocated_section_contents. At least, secrel_reloc
needs the support, the others might not be present in dwarf debug
sections.
* coff-aarch64.c (coff_aarch64_rel21_reloc): Range check
reloc offset. Support final-linking.
(coff_aarch64_po12l_reloc): Likewise.
(coff_aarch64_addr32nb_reloc): Likewise.
(coff_aarch64_secrel_reloc): Likewise.
(coff_pe_aarch64_relocate_section): Range check reloc offset.
|