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>
* coff-x86_64.c (bfd_pe_print_pdata): Defined to
_bfd_pex64_print_pdata only if PE is defined.
* libpei.h (_bfd_pep_print_x64_pdata): Renamed to ...
(_bfd_pex64_print_pdata): This.
* peXXigen.c (_bfd_pep_print_x64_pdata): Renamed to ...
(_bfd_pex64_print_pdata): This. Defined only if COFF_WITH_pex64
is defined.
COFF_WITH_PE based SH ports.
* libpei.h (_bfd_XX_print_ce_compressed_pdata): Prototype.
* arm-wince-pe.c (bfd_pe_print_pdata): Use
_bfd_pe_print_ce_compressed_pdata.
(slurp_symcache, cleanup_syms, pe_print_ce_compressed_pdata): Move
to...
* peXXigen.c: ... here and rename pe_print_ce_compressed_pdata to
_bfd_XX_print_ce_compressed_pdata.
* efi-bsdrv-ia32.c: New file.
* efi-rtdrv-ia64.c: New file.
* efi-bsdrv-ia64.c: New file.
* efi-rtdrv-x86_64.c: New file.
* efi-bsdrv-x86_64.c: New file.
* peicode.h (pe_bfd_object_p): Add support for boot service and
runtime service drivers.
* libpei.h: Add macros for EFI formats, and rename the efi application
format macros to disambiguate.
* targets.c: Add bfd_target _vec externs.
(_bfd_tar): Add EFI _vec entries.
* config.bfd: Add EFI vectors into the selection routines.
* configure.in: add EFI _vec entries.
* configure: Regenerate.
* Makefile.am: Add EFI files.
* Makefile.in: Regenerate.
* libpei.h (_bfd_XXi_final_link_postscript): Remove
duplication.
(bfd_target_pei_p): New.
(bfd_target_pei_arch): New
(bfd_target_efi_p): Likewise.
(bfd_target_efi_arch): New
(bfd_pe_executable_p): Use bfd_target_pei_p and
bfd_target_efi_p.
* peicode.h (arch_type): New enum.
(pe_arch): New function.
(pe_bfd_object_p): Don't match PE/EFI target with EFI/PE file
if there is an EFI/PE target.
argument and emits the string followed by a comma and then the length of
the string.
(CONST_STRNEQ): New macro. Checks to see if a variable string has a constant
string as its initial characters.
(CONST_STRNCPY): New macro. Copies a constant string to the start of a
variable string.
* bfd-in2.h: Regenerate.
* <remainign files>: Make use of the new macros.
executables.
(coff_swap_scnhdr_in): Only set the s_size field for object files or for
executables who have not already initialised the field.
(bfd_pe_executable_p): New macro. Return true if the PE format bfd is an
executable.
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
as _bfd_XXi_only_swap_filehdr_out.
(pe_mkobject) [PEI_FORCE_MINIMUM_ALIGNMENT]: Set
pe->force_minimum_alignment to TRUE.
(pe_mkobject) [PEI_TARGET_SUBSYSTEM]: Set pe->target_subsystem to
PEI_TARGET_SUBSYSTEM.
(pe_print_private_bfd_data): Call
_bfd_XX_print_private_bfd_data_common() instead of
_bfd_pe_print_private_bfd_data_common().
(pe_bfd_copy_private_bfd_data): Call
_bfd_XX_bfd_copy_private_bfd_data_common() instead of
_bfd_pe_bfd_copy_private_bfd_data_common().
(coff_bfd_copy_private_section_data): Define as
_bfd_XX_bfd_copy_private_section_data instead of
_bfd_pe_bfd_copy_private_section_data.
(coff_get_symbol_info): Define as _bfd_XX_get_symbol_info instead
of a _bfd_pe_get_symbol_info.
* peigen.c: Delete.
* peXXigen.c: Renamed from peigen.c.
(COFF_WITH_XX): Define this macro (will get expanded into
COFF_WITH_pep or COFF_WITH_pe, depending on whether this is being
compiled as peigen.c or pepigen.c.
[COFF_WITH_pep]: Include "coff/ia64.h" instead of "coff/i386.h" to
define the canonical PEP structures and definitions.
(_bfd_XXi_swap_aouthdr_out): If pe->force_minimum_alignment is in
effect, enforce minimum file and section alignments. If
extra->Subsystem is IMAGE_SUBSYSTEM_UNKNOWN, set it to
pe->target_subsystem (this defaults to IMAGE_SUBSYSTEM_UNKNOWN,
so, by default, this is a no-op).
* libpei.h: Rename COFF_WITH_PEP to COFF_WITH_pep.
(_bfd_XX_bfd_copy_private_bfd_data_common): Add macros to map
_bfd_XXfoo to _bfd_pepfoo if COFF_WIT_PEP is defined and to
_bfd_pefoo if it's not defined. Use these macros to define
coff swap macros.
* libcoff.h (pe_tdata): Add members target_subsystem and
force_minimum_alignment.
* efi-app-ia64.c (COFF_WITH_pep): Rename COFF_WITH_PEP to
COFF_WITH_pep.
(PEI_TARGET_SUBSYSTEM): Rename from PEI_DEFAULT_TARGET_SUBSYSTEM.
* configure.in (bfd_efi_app_ia64_vec): Use pepigen.lo instead of
peigen.lo.
* coff-ia64.c: Rename COFF_WITH_PEP to COFF_WITH_pep.
(AOUTSZ): Rename PEP64AOUTSZ and PEP64AOUTHDR to PEPAOUTSZ and
PEPAOUTHDR.
* Makefile.in (BFD64_BACKENDS): Mention pepigen.lo.
(BFD64_BACKENDS_CFILES): Mention pepigen.c
(peigen.c): Add rule to generate from peXXigen.c.
(pepigen.c): Ditto.
(pepigen.lo): List dependencies for pepigen.lo.
* unwind-ia64.c (unw_decode_x1): Declare code arg with
ATTRIBUTE_UNUSED.
(unw_decode_x2): Ditto.
(unw_decode_x3): Ditto.
(unw_decode_x4): Ditto.
* pe.h (PEPAOUTSZ): Rename from PEP64AOUTSZ.
Rename from PEPAOUTHDR.
* libpei.h (_bfd_pei_final_link_postscript): Declare.
(coff_final_link_postscript): Define.
* peigen.c (_bfd_pei_swap_aouthdr_out): Don't set value for data
directory entries here.
(_bfd_pei_final_link_postscript): New function.
* libpei.h: New file, broken out of peicode.h.
* peigen.c: New file, broken out of peicode.h.
* peicode.h: A bunch of code moved out to libpei.h and peigen.c.
* configure.in: Add peigen.lo to list of files required for each
PE target.
* Makefile.am: Rebuild dependencies.
(BFD32_BACKENDS): Add peigen.lo.
(BFD32_BACKENDS_CFILES): Add peigen.c.
(SOURCE_HFILES): Add libpei.h.
* configure, Makefile.in: Rebuild.