This promotes BFD's struct elf_build_id to the generic struct bfd_build_id,
populated when an ELF or PE BFD is read.
gdb is updated to use that, and to use the build-id to find symbols for PE files
also.
There is currently no generic way to extract the build-id from an object file,
perhaps an option to objdump to do this might make sense?
On x86_64-pc-cygwin, gdb's sepdebug.exp changes:
-# of unsupported tests 1
+# of expected passes 90
I don't seem to get consistent testsuite runs on i686-linux-gnu, but there
don't appear to be any regressions.
bfd/ChangeLog:
2015-06-10 Jon Turney <jon.turney@dronecode.org.uk>
* elf-bfd.h : Remove struct elf_build_id.
* bfd.c : Add struct bfd_build_id.
* bfd-in2.h: Regenerate.
* elf.c (elfobj_grok_gnu_build_id): Update to use bfd_build_id.
* libpei.h: Add protoype and macros for
bfd_XXi_slurp_codeview_record.
* peXXigen.c (_bfd_XXi_slurp_codeview_record): Make public
* peicode.h (pe_bfd_read_buildid): Add.
(pe_bfd_object_p): Use pe_bfd_read_buildid().
gdb/ChangeLog:
2015-06-10 Jon Turney <jon.turney@dronecode.org.uk>
* build-id.c: Don't include elf-bfd.h.
(build_id_bfd_get): Use bfd_build_id.
(build_id_verify): Ditto.
* build-id.h: Ditto.
(find_separate_debug_file_by_buildid): Ditto.
* python/py-objfile.c: Don't include elf-bfd.h.
(objfpy_get_build_id) Use bfd_build_id.
(objfpy_build_id_matches, objfpy_lookup_objfile_by_build_id): Ditto.
* coffread.c: Include build-id.h.
(coff_symfile_read): Try find_separate_debug_file_by_buildid.
gdb/doc/ChangeLog:
2015-06-10 Jon Turney <jon.turney@dronecode.org.uk>
* gdb.texinfo (Separate Debug Files): Document that PE is also
supported.
gdb/testsuite/ChangeLog:
2015-06-10 Jon Turney <jon.turney@dronecode.org.uk>
* gdb.base/sepdebug.exp: Add EXEEXT where needed.
* lib/gdb.exp (get_build_id): Teach how to extract build-id from a
PE file.
* lib/future.exp (gdb_find_objdump): Add gdb_find_objdump.
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
* cofflink.c (_bfd_coff_generic_relocate_section): Revert
2014-03-26 change. Call _bfd_clear_contents for relocs against
local and global symbols defined in discarded input sections.
* elf32-msp430.c (rl78_sym_diff_handler): New function.
(msp430_howto_table): Use the new function for the SYM_DIFF reloc.
(msp430x_howto_table): Likewise.
When building a shared lib from non-PIC objects, we'll get dynamic
text relocations. These need to move with any insns we move.
Otherwise the dynamic reloc will modify the branch, resulting in
crashes and other unpleasant behaviour.
Also, ld -r --ppc476-workaround used with sufficiently aligned PIC
objects needs a fix for emitted REL16 relocs.
bfd/
* elf64-ppc.c (ppc_elf_relocate_section): Move dynamic text
relocs with insns moved by --ppc476-workaround. Correct
output of REL16 relocs.
ld/testsuite/
* ld-powerpc/ppc476-shared.s,
* ld-powerpc/ppc476-shared.lnk,
* ld-powerpc/ppc476-shared.d,
* ld-powerpc/ppc476-shared2.d: New tests.
* ld-powerpc/powerpc.exp: Run them.
BFD_RELOC_AARCH64_TLSLE_ADD_LO12 is used to generate simplest
one-instruction addressing for TLS LE model when tls size is smaller
4K. Linker need to make sure there is no TLS offset overflow.
2015-06-01 Jiong Wang <jiong.wang@arm.com>
bfd/
* elfnn-aarch64.c (elfNN_aarch64_howto_table): Set overflow type to
complain_overflow_unsigned for BFD_RELOC_AARCH64_TLSLE_ADD_LO12.
* elfxx-aarch64.c (_bfd_aarch64_elf_resolve_relocation): Don't use
PGOFF for BFD_RELOC_AARCH64_TLSLE_ADD_LO12, that will mask off all
potential high overflowed bits.
ld/testsuite/
* ld-aarch64/tprel_add_lo12_overflow.s: New testcase.
* ld-aarch64/tprel_add_lo12_overflow.d: Nex expectation file.
* ld-aarch64/aarch64-elf.exp: Run new testcase.
When pointer equality needed, we can't replace PLT relocations with
GOT relocations for -z now. This patch checks if pointer equality is
needed before converting PLT relocations to GOT relocations.
bfd/
PR binutils/18458
* elf32-i386.c (elf_i386_check_relocs): Create .plt.got section
for now binding only if pointer equality isn't needed.
(elf_i386_allocate_dynrelocs): Use .plt.got section for now
binding only if pointer equality isn't needed.
* elf64-x86-64.c (elf_x86_64_check_relocs): Create .plt.got
section for now binding only if pointer equality isn't needed.
(elf_x86_64_allocate_dynrelocs): Use .plt.got section for now
binding only if pointer equality isn't needed.
ld/testsuite/
PR binutils/18458
* ld-elf/shared.exp (build_tests): Build libpr18458a.so and
libpr18458b.so.
(run_tests): Run pr18458 test.
* ld-elf/pr18458a.c: New file.
* ld-elf/pr18458b.c: Likewise.
* ld-elf/pr18458c.c: Likewise.
Extra relocations may be added to the .rel.plt/.rela.plt section, which
are unrelated to PLT. We should skip them when retrieving PLT entry
symbol values.
PR binutils/18437
* elf32-i386.c (elf_i386_get_plt_sym_val): Skip extra relocations
in .rel.plt/.rela.plt.
* elf64-x86-64.c (elf_x86_64_get_plt_sym_val): Likewise.
There is no need for PLT relocations with -z now. We can use GOT
relocations, which take less space, instead and replace 16-byte .plt
entres with 8-byte .plt.got entries.
bfd/
* elf32-i386.c (elf_i386_check_relocs): Create .plt.got section
for now binding.
(elf_i386_allocate_dynrelocs): Use .plt.got section for now
binding.
* elf64-x86-64.c (elf_x86_64_check_relocs): Create .plt.got
section for now binding.
(elf_x86_64_allocate_dynrelocs): Use .plt.got section for now
binding.
ld/testsuite/
* ld-i386/i386.exp: Run PR ld/17689 tests with -z now.
* ld-x86-64/x86-64.exp: Likewise
* ld-i386/pr17689now.rd: New file.
* ld-x86-64/pr17689now.rd: Likewise
In a SHF_COMPRESSED compressed section, the raw compressed data should
begin immediately after the compression header. This patch removes the
extra zlib header from the SHF_COMPRESSED section.
bfd/
* bfd.c (bfd_update_compression_header): Also write the zlib
header if the SHF_COMPRESSED bit cleared..
(bfd_check_compression_header): Return the uncompressed size.
* compress.c (decompress_contents): Don't skip the zlib header.
(bfd_compress_section_contents): Properly handle ELFCOMPRESS_ZLIB,
which doesn't have the zlib header.
(bfd_init_section_decompress_status): Likewise.
(bfd_get_full_section_contents): Updated.
(bfd_is_section_compressed): Likewise.
(bfd_is_section_compressed_with_header): Return the uncompressed
size.
* elf.c (_bfd_elf_make_section_from_shdr): Updated.
* bfd-in2.h: Regenerated.
binutils/
* readelf.c (uncompress_section_contents): Add a parameter for
uncompressed size. Don't check the zlib header.
(load_specific_debug_section): Updated.
binutils/testsuite/
* binutils-all/compress.exp: Replace "$OBJDUMP -s -j .debug_info"
with "$OBJDUMP -W".
* binutils-all/libdw2-compressedgabi.out: Updated.
gas/
2015-05-14 H.J. Lu <hongjiu.lu@intel.com>
* write.c (compress_debug): Don't write the zlib header, which
is handled by bfd_update_compression_header.
elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
made local, that results in link failure with the following message:
BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
3372 in elf_xtensa_finish_dynamic_sections
elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
relocation type. Relocation types are not changed when symbol becomes
local, but its PLT references are added to GOT references and
plt.refcount is set to 0. Such symbol cannot be unreferences in the
elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
relocations section size not match number of GOT relocations.
Fix it by treating PLT reference as GOT reference when plt.refcount is
not positive.
2015-05-14 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (elf_xtensa_gc_sweep_hook): Treat PLT reference
as GOT reference when plt.refcount is not positive.
Commit dd7e64d45b may optimize out
i386/x86-64 JUMP_SLOT relocation. If there is no JUMP_SLOT relocation
left, we don't need to the first .plt entry. This patch allocates
space for the first .plt entry only if we also reserve space for a PLT
slot for JUMP_SLOT relocation.
bfd/
* elf32-i386.c (elf_i386_allocate_dynrelocs): Allocate space
for the first .plt entry only if needed.
* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs): Likewise.
ld/testsuite/
* ld-i386/i386.exp: Run pltgot-1 for Linux targets.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pltgot-1.d: New file.
* ld-i386/pltgot-1.s: Likewise.
* ld-x86-64/pltgot-1.d: Likewise.
* ld-x86-64/pltgot-1.s: Likewise.
The first argument to bfd_get_8/bfd_put_8 isn't used. But we should
use something real. Replace input_bfd and output_bfd with abfd.
* elf32-i386.c (elf_i386_convert_mov_to_lea): Replace input_bfd
and output_bfd with abfd.
* elf64-x86-64.c (elf_x86_64_convert_mov_to_lea): Likewise.
2015-04-24 Jiong. Wang <jiong.wang@arm.com>
bfd/
PR ld/18270
* elfnn-aarch64.c (elfNN_aarch64_size_dynamic): Count local symbol for
GOT_NORMAL for both sgot/srelgot section.
(elfNN_aarch64_final_link_relocate): Relocate against GOT entry address
and generate necessary runtime relocation for GOT entry.
PR 18313
bin * ieee.c (ieee_read_cxx_class): Initialise the varargs variable.
* readelf.c (uncompress_section_contents): Zero initialise the
zstream structure.
bfd * compress.c (decompress_contents): Zero initialse the z_stream
structure.
Bits in section flags should only be defined in bfd/section.c. This
patch moves SEC_MEP_VLIW to bfd/section.c.
bfd/
PR binutils/18316
* section.c (SEC_MEP_VLIW): New.
* bfd-in2.h: Regenerated.
include/elf/
PR binutils/18316
* mep.h (SEC_MEP_VLIW): Removed.
When we set up st_name for output section name in elf_fake_sections, we
don't know if the compressed DWARF debug section will be smaller. We may
end up with compressed DWARF debug sections which are bigger than the
uncompressed ones. This patch delays setting up st_name for output DWARF
debug section to _bfd_elf_assign_file_positions_for_non_load which will
compress the output debug section. We also postpone placement of shstrtab
section after DWARF debug sections have been compressed. The net effect
is .shstrtab section is now placed after .symtab and .strtab sections.
bfd/
PR ld/18277
* compress.c (bfd_compress_section_contents): Remove the
write_compress argument.
(bfd_init_section_compress_status): Updated.
(bfd_compress_section): Likewise.
* elf.c (_bfd_elf_set_reloc_sh_name): New.
(_bfd_elf_init_reloc_shdr): Add delay_st_name_p. Set sh_name
to (unsigned int) -1 if delay_st_name_p is TRUE. Use
_bfd_elf_set_reloc_sh_name.
(elf_fake_sections): Don't rename DWARF debug section for
linker output if it will be compressed. Instead, set
delay_st_name_p to TRUE and pass it to _bfd_elf_init_reloc_shdr.
(assign_section_numbers): Call _bfd_elf_strtab_addref only if
sh_name != (unsigned int) -1. Don't finalize nor assign
shstrtab section here. Delay setting output section names to
_bfd_elf_write_object_contents.
(_bfd_elf_compute_section_file_positions): Update comments on
sh_offset for shstrtab section.
(assign_file_positions_for_non_load_sections): Set sh_offset to
-1 for shstrtab section.
(assign_file_positions_except_relocs): Likewise.
(_bfd_elf_assign_file_positions_for_non_load): Set up sh_name
when compressing DWARF debug sections. Place shstrtab section
after DWARF debug sections have been compressed.
(_bfd_elf_write_object_contents): Setting sh_name for output
sections.
ld/testsuite/
PR ld/18277
* ld-elf/compressed1d.d: New.
* ld-elf/compressed1e.d: Likewise.
Change compressed input debug section name for objdump is very confusing.
But we need to change it for linker so that linker will consider the
input section as a debug section. This patch delays section rename to
elf_fake_sections for objcopy and avoids it for objdump.
bfd/
PR binutils/18209
* bfd.c (bfd): Add is_linker_input.
* elf.c (convert_debug_to_zdebug): New.
(convert_zdebug_to_debug): Likewise.
(_bfd_elf_make_section_from_shdr): Don't convert .debug_* to
.zdebug_* here. Use convert_zdebug_to_debug. Set SEC_ELF_RENAME.
(_bfd_elf_init_reloc_shdr): Pass a pointer to section name
instead of a pointer to section.
(elf_fake_sections): Rename the section name if SEC_ELF_RENAME
is set.
* section.c (SEC_ELF_RENAME): New.
* bfd-in2.h: Regenerated.
binutils/
PR binutils/18209
* objcopy.c (setup_section): Copy compress status.
binutils/testsuite/
PR binutils/18209
* binutils-all/compress.exp: Replace dw2-3.W with dw2-3gabi.W
on zlib-gabi output.
* binutils-all/dw2-1.W: Convert section names to .zdebug_*.
* binutils-all/dw2-3.W: Likewise.
* binutils-all/objdump.W: Likewise.
* binutils-all/dw2-3gabi.W: New file.
ld/
PR binutils/18209
* ldfile.c (ldfile_try_open_bfd): Set is_linker_input to 1.
commit 9ad5cbcfb2 added the initial support
for more than 64k ELF sections with holes for reserved section indices in
section header table and set entries of reserved section indices in
section header table to index 0:
for (secn = 1; secn < section_number; ++secn)
- i_shdrp[secn]->sh_name = _bfd_elf_strtab_offset (elf_shstrtab (abfd),
- i_shdrp[secn]->sh_name);
-
+ if (i_shdrp[secn] == NULL)
+ i_shdrp[secn] = i_shdrp[0];
+ else
+ i_shdrp[secn]->sh_name = _bfd_elf_strtab_offset (elf_shstrtab (abfd),
+ i_shdrp[secn]->sh_name);
commit 4fbb74a605 removed holes in section
header table. Check for i_shdrp[secn] == NULL is no longer needed now.
This patch removes it.
* elf.c (assign_section_numbers): Always set up sh_name.