Age | Commit message (Collapse) | Author | Files | Lines |
|
* doc/chew.c (add_to_definition): Use correct type when
calculating size of array reallocation.
(nextword): Always initialise the word return parameter.
(compile): Check return value of nextword().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* elf-bfd.h (elf_backend_data) <elf_backend_core_find_build_id>:
New field.
(_bfd_elf32_core_find_build_id, _bfd_elf64_core_find_build_id):
New functions.
(elf_read_notes): Add declaration.
* elf.c (elf_read_notes): Move elf-bfd.h.
(_bfd_elf_core_find_build_id): New function.
(bfd_section_from_phdr): Scan core file PT_LOAD segments for
build-id if none is known.
(elf_parse_notes): For core files, scan for notes.
* elfcore.h (elf_core_file_matches_executable_p): If both
BFDs have identical build-ids, then they match.
(_bfd_elf_core_find_build_id): New function.
* elfxx-target.h (elf_backend_core_find_build_id): Define.
(elfNN_bed): Add elf_backend_core_find_build_id.
|
|
|
|
re-initiialising it.
* libcoff-in.h (struct pe_tdata): Add dos_message field.
* libcoff.h: Regenerate.
* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Copy the
dos_message field rather than initialising it.
(_bfd_XX_bfd_copy_private_bfd_data_common): Copy the dos_message
field.
* peicode.h (pe_mkobject): Initialise the dos_message field.
(pe_mkobject_hook): Copy the dos_message field.
(pe_bfd_object_p): Copy the dos_message field.
|
|
|
|
|
|
|
|
|
|
This rewrites much of assign_file_positions_for_non_load_sections to
allow objcopy and strip to handle cases like that in PR4499 where
program headers were not in their usual position immediately after the
ELF file header, and PT_LOAD headers were not sorted by paddr.
PR 4499
include/
* elf/internal.h (struct elf_segment_map): Delete header_size.
Add no_sort_lma and idx.
bfd/
* elf-nacl.c (nacl_modify_segment_map): Set no_sort_lma for all
PT_LOAD segments.
* elf32-spu.c (spu_elf_modify_segment_map): Likewise on overlay
PT_LOAD segments.
* elf.c (elf_sort_segments): New function.
(assign_file_positions_except_relocs): Use shortcuts to elfheader
and elf_tdata. Seek to e_phoff not sizeof_ehdr to write program
headers. Move PT_PHDR check..
(assign_file_positions_for_non_load_sections): ..and code setting
PT_PHDR p_vaddr and p_paddr, and code setting __ehdr_start value..
(assign_file_positions_for_load_sections): ..to here. Sort
PT_LOAD headers. Delete header_pad code. Use actual number of
headers rather than allocated in calculating size for program
headers. Don't assume program headers follow ELF file header.
Simplify pt_load_count code. Only set "off" for PT_LOAD or
PT_NOTE in cores.
(rewrite_elf_program_header): Set p_vaddr_offset for segments
that include file and program headers.
(copy_elf_program_header): Likewise, replacing header_size code.
|
|
|
|
|
|
|
|
|
|
This patch extends "ar P" to allow creation of normal (as distinct
from thin) archives with full path names.
PR 452
PR 25104
bfd/
* archive.c (normalize): Return file unchanged when
BFD_ARCHIVE_FULL_PATH.
(_bfd_construct_extended_name_table): Pass abfd, the output
bfd, to normalize.
(_bfd_archive_bsd44_construct_extended_name_table): Likewise.
* bfd.c (struct bfd): Make flags a full flagword.
(BFD_ARCHIVE_FULL_PATH): Define.
* bfd-in2.h: Regenerate.
binutils/
* ar.c (write_archive): Set BFD_ARCHIVE_FULL_PATH.
* doc/binutils.texi (extract from archive): Mention
restrictions when extracting from archives with full paths.
(ar P): Update to current P support.
(ar -X32_64): Fix spelling.
|
|
|
|
This change increases the default alignment for the .plt section
from 4 bytes to 8 bytes. When function descriptors are 8-byte
aligned, they can be updated atomically on 32-bit hppa. This
helps with ordering issues on SMP machines. It also ensures
that descriptors reside on the same cache line. This reduces
the probability of a double TLB miss in a call.
2019-10-20 John David Anglin <danglin@gcc.gnu.org>
* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Provide 8-byte
minimum alignment for .plt section.
|
|
|
|
This commit updates the import stubs to leave the pointer to the
function descriptor in register %r22. This provides a backup
mechanism for _dl_runtime_resolve to fixup descriptors during
lazy binding.
bfd/ChangeLog
2019-10-19 John David Anglin <danglin@gcc.gnu.org>
* elf32-hppa.c: Revise import stub sequences.
(LONG_BRANCH_STUB_SIZE): Define.
(LONG_BRANCH_SHARED_STUB_SIZE): Define.
(IMPORT_STUB_SIZE): Define.
(IMPORT_SHARED_STUB_SIZE): Define.
(EXPORT_STUB_SIZE): Define.
(plt_stub): Revise to not use register %r22.
(LDO_R1_R22): Define.
(LDW_R22_R21): Define.
(LDW_R22_R19): Define.
(hppa_build_one_stub): Update stub generation and use new defines.
(hppa_size_one_stub): Likewise.
|
|
|
|
|
|
Two patches from Nelson Chu.
It is better to use the linker's callback functions to handle the link time
error when relocating. The unresolved relocation error can be regarded as
an unsupported relocation. To make user easier to understand different errors,
we need to extend the current error message format of the callback function
since the format is fixed.
bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Use asprintf to extend
the error message if needed, and then store the result into the
`msg_buf`. Finally, remember to free the unused `msg_buf`. All error
message for the dangerous relocation should be set before we call the
callback function. If we miss the error message since linker runs out
of memory, we should set the default error message for the error.
ld/
* testsuite/ld-riscv-elf/lib-nopic-01a.s: Create the shared library
lib-nopic-01a.so, it will be linked with lib-nopic-01b.s.
* testsuite/ld-riscv-elf/lib-nopic-01b.s: Add new test for the
unresolved relocation. Link the non-pic code into a shared library
may cause the error.
* testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise.
* testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run the new test only when
the shared library is supported.
R_RISCV_CALL, R_RISCV_JAL and R_RISCV_RVC_JUMP are pc-relative relocation.
For now, we do not allow the object with these relocation links into a shared
library since the referenced symbols may be loaded to the places that too far
from the pc. We can improve the error message for these unsupported relocation
to notice user that they should recompile their code with `fPIC`.
bfd/
* elfnn-riscv.c (riscv_elf_relocate_section): Report the error message
that user should recompile their code with `fPIC` when linking non-pic
code into shared library.
ld/
* testsuite/ld-riscv-elf/lib-nopic-01b.d: Update the error message.
Change-Id: Ib3347a0a6fa1c2b20a9647c314d5bec2c322ff04
|
|
|
|
This implements padding of orphan executable sections for PowerPC.
Of course, the simple implementation of bfd_arch_ppc_nop_fill and
removing the NOP definition didn't work, with powerpc64 hitting a
testsuite failure linking to S-records. That's because the srec
target is BFD_ENDIAN_UNKNOWN so the test of bfd_big_endian (abfd) in
default_data_link_order therefore returned false, resulting in a
little-endian nop pattern. The rest of the patch fixes that problem
by adding a new field to bfd_link_info that can be used to determine
actual endianness on targets like srec.
PR 13616
include/
* bfdlink.h (struct bfd_link_info <big_endian>): New field.
bfd/
* cpu-powerpc.c (bfd_arch_ppc_nop_fill): New function, use it
for all ppc arch info.
* linker.c (default_data_link_order): Pass info->big_endian to
arch_info->fill function.
ld/
* emulparams/elf64lppc.sh (NOP): Don't define.
* emulparams/elf64ppc.sh (NOP): Don't define.
* ldwrite.c (build_link_order): Use link_info.big_endian. Move
code determining endian to use for data_statement to..
* ldemul.c (after_open_default): ..here. Set link_info.big_endian.
|
|
|
|
* elf32-m68hc1x.c (reloc_warning): Add printf attribute.
(elf32_m68hc11_relocate_section): Don't use a variable for format
strings. Delete some unnecessary xgettext:c-format comments.
|
|
Also fixes m68hc1x printf arguments which would have bombed when
compiling on a 32-bit host with --enable-64-bit-bfd.
bfd/
PR 24955
* elf32-arm.c (set_cmse_veneer_addr_from_implib): Use bfd_malloc
rather than xmalloc.
* elf32-m68hc1x.c (reloc_warning): New function.
(elf32_m68hc11_relocate_section): Use it here. Cast bfd_vma values
corresponding to %lx in format strings.
* elf32-nds32.c (nds32_insertion_sort): Use a stack temporary.
gas/
* config/tc-nds32.c (nds32_set_section_relocs): Use relocs and n
parameters rather than equivalent sec->orelocation and
sec->reloc_count. Don't sort for n <= 1. Tidy.
|
|
of double equal for comparison
PR 25100
* elf64-ppc.c (sfpr_define): Delete dead code that triggered a warning.
|
|
* bfd.c (bfd_check_compression_header): Check for powers of two
with x == (x & -x).
|
|
|
|
* syms.c (struct indexentry): Add idx field.
(cmpindexentry): Final sort on idx.
(_bfd_stab_section_find_nearest_line): Set idx.
|
|
This patch ensures qsort stability in line and function sorting done
in dwarf2.c. For the line sequences we make use of an existing field
that isn't used until later, as a monotonic counter for the qsort.
* dwarf2.c (struct lookup_funcinfo): Add idx field.
(compare_lookup_funcinfos): Perform final sort on idx.
(build_lookup_funcinfo_table): Set idx.
(compare_sequences): Perform final sort on num_lines.
(build_line_info_table): Set num_lines and line_info_lookup earlier.
(sort_line_sequences): Set num_lines for sort.
|
|
This particular sort almost certainly does not need to be stable for
the ELF linker to work correctly. However it is conceivable that an
unstable sort could affect linker output, and thus different output be
seen with differing qsort implementations. The argument goes like
this: Given more than one strong alias symbol of equal section, value,
and size, the aliases will compare equal by elf_sort_symbol and thus
which one is chosen as the "real" symbol to be made dynamic depends on
qsort. Why would anyone define two symbols at the same address?
Well, sometimes the fact that there are more than one strong alias
symbol is due to linker script symbols like __bss_start being made
dynamic. This will match the first symbol defined in .bss if it
doesn't have correct size, and forgetting to properly set size and
type of symbols isn't as rare as it should be.
This patch adds some more heuristics to elf_sort_symbol.
* elflink.c (elf_sort_symbol): Sort on type and name as well.
(elf_link_add_object_symbols): Style fix.
|
|
elf_sort_sections tried to ensure a stable qsort by using target_index
as the final comparison, but target_index hasn't been set by anything
at the time elf_sort_sections was run. This patch arrange to have
target_index set.
* elf.c (_bfd_elf_map_sections_to_segments): Init target_index
for sections about to be sorted.
(assign_file_positions_for_load_sections): Likewise.
(elf_sort_sections): Don't bother optimising both TOEND case.
* elflink.c (bfd_elf_final_link): Reset target_index.
|
|
The linker SHF_LINK_ORDER section sorting had a number of defects.
1) The ordering was by VMA, which won't work with overlays. LMA is
better.
2) Zero size sections can result in two sections at the same LMA/VMA.
When only one of the two sections at the same LMA is zero size,
that one must be first.
3) Warnings given by elf_get_linked_section_vma won't ever be emitted
since elf_object_p warns and excludes objects with zero sh_link on
a SHF_LINK_ORDER section.
4) Section offset was adjusted down rather than up by section
alignment, possibly creating overlapping sections.
5) Finding the linked section did so the hard way, rather than simply
using elf_linked_to_section.
* elflink.c (elf_get_linked_section_vma): Delete.
(compare_link_order): Use elf_linked_to_section and sort by lma,
size, and id.
(elf_fixup_link_order): Use size_t variables where appropriate.
Make use of elf_linked_to_section. Formatting. Properly align
sections.
|
|
qsort isn't guaranteed to be a stable sort, that is, elements
comparing equal according to the comparison function may be reordered
relative to their original ordering. Of course sometimes you may not
care, but even in those cases it is good to force some ordering
(ie. not have the comparison function return 0) so that linker output
is reproducible over different libc qsort implementations.
One way to make qsort stable (which the glibc manual incorrectly says
is the only way) is to augment the elements being sorted with a
monotonic counter of some kind, and use that counter as the final
arbiter of ordering in the comparison function.
Another way is to set up an array of pointers into the array of
elements, first pointer to first element, second pointer to second
element and so so, and sort the pointer array rather than the element
array. Final arbiter in the comparison function then is the pointer
difference. This works well with, for example, the symbol pointers
returned by _bfd_elf_canonicalize_symtab which point into a symbol
array.
This patch fixes a few places where sorting by symbol pointers is
appropriate, and adds comments where qsort stability is a non-issue.
* elf-strtab.c (strrevcmp): Comment.
* merge.c (strrevcmp): Likewise.
* elf64-ppc.c (compare_symbols): Correct final pointer comparison.
Comment on why comparing pointers ensures a stable sort.
* elflink.c (struct elf_symbol): Add void* to union.
(elf_sort_elf_symbol): Ensure a stable sort with pointer comparison.
(elf_sym_name_compare): Likewise.
(bfd_elf_match_symbols_in_sections): Style fix.
(elf_link_sort_cmp1): Comment.
|
|
PR 24955
* elflink.c (elf_output_implib): Don't use xmalloc. Don't ignore
return value of bfd_alloc2.
* peXXigen.c (_bfd_XXi_write_codeview_record): Don't use xmalloc.
* pef.c (bfd_pef_print_symbol): Likewise. Don't ignore return
value of bfd_get_section_contents.
* som.c (som_write_space_strings): Don't use xmalloc.
(som_write_symbol_strings): Likewise.
|
|
|
|
|
|
|
|
stash_maybe_enable_info_hash_tables sets
stash->info_hash_status = STASH_INFO_HASH_ON;
regardless of the result of stash_maybe_update_info_hash_tables call. In
case it fails this results in repeated invocation of comp_unit_hash_info
for the same comp unit and assertion failure in this function.
Only set stash->info_hash_status = STASH_INFO_HASH_ON; when
stash_maybe_update_info_hash_tables is successful.
bfd/
2019-10-11 Max Filippov <jcmvbkbc@gmail.com>
* dwarf2.c (stash_maybe_enable_info_hash_tables): Only set
stash->info_hash_status = STASH_INFO_HASH_ON when
stash_maybe_update_info_hash_tables succeeds.
|
|
|
|
|
|
Evil testcase with two debug info sections, with sizes of 2aaaabac4ec1
and ffffd5555453b140 result in a total size of 1. Reading the first
section of course overflows the buffer and tramples on other memory.
PR 25070
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Catch overflow of
total_size calculation.
|
|
|