From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30131 invoked by alias); 16 Apr 2013 13:19:02 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 30113 invoked by uid 9755); 16 Apr 2013 13:19:01 -0000 Date: Tue, 16 Apr 2013 13:19:00 -0000 Message-ID: <20130416131901.30058.qmail@sourceware.org> From: aristovski@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] aristovski/validate-binary-before-use: Tests for validate symbol file using build-id. X-Git-Refname: refs/heads/aristovski/validate-binary-before-use X-Git-Reftype: branch X-Git-Oldrev: f3af537c2c4595df30f2ef1d60706b51c6a9df11 X-Git-Newrev: 298921b071404e2f5ed21184fe8a8f8b55cbcc5f X-SW-Source: 2013-q2/txt/msg00025.txt.bz2 List-Id: The branch, aristovski/validate-binary-before-use has been updated discards f3af537c2c4595df30f2ef1d60706b51c6a9df11 (commit) discards a93c3646c09eb1125cb5070b8bad42dad5f8b07e (commit) discards 659ff615c91a714fbe4f56068955c40bdf7234a8 (commit) discards 1e324e602f9679cf00ac82306bdc0dd4de4611e0 (commit) discards 6c805422d1704fee8bb033cb5b26a343ba7a60e9 (commit) discards 504aa1b8c2b181a4d4deb6542961c804966d1775 (commit) discards 34358983877ff06af9dba085317072896836351c (commit) discards 37c064593ba6d72b03b3589fab66816a0b792999 (commit) discards 20be147335c0ee6e21230c934ec790cf5380cfcb (commit) via 298921b071404e2f5ed21184fe8a8f8b55cbcc5f (commit) via c85cc58af91177b6fee9e56bd58c30280d88a581 (commit) via 90e5ca4da95bf8e7a9888dd4ee66c9f9ef3242a8 (commit) via 9923a243a7d47715778b7aabec420a273fcc880d (commit) via 9156b67d1f394a904737c304c106730ea4005e38 (commit) via f3f4f26ac1cbd9405807d5e9d4fb26f65a27d520 (commit) via 5f2fbbb9aef6c57311872673c1b86af0c8e8ee5e (commit) via 4e6ba4862e4190be9ec6a92447d11a7b2c7c0a9e (commit) via f6c8560c008449b811612a2c1560069102f50684 (commit) via 92687545f1f26e54b40d90812b34791d97ecd867 (commit) via 20cf09b42ad2bcb0225cdc36cb228e515bd510a7 (commit) via 766ce5943c7dd9484310bd71a91a8b19d5b7b5c2 (commit) via 972f1ca0327da78f0eb9cd7fe9a760696642dc75 (commit) via cb22b288a796779e3238ff812226a9897854c5aa (commit) via 049dc1118adce445d49828154b415f963c41a4d5 (commit) from f3af537c2c4595df30f2ef1d60706b51c6a9df11 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 298921b071404e2f5ed21184fe8a8f8b55cbcc5f Author: Aleksandar Ristovski Date: Wed Mar 27 16:06:26 2013 -0400 Tests for validate symbol file using build-id. * gdb.base/solib-mismatch-lib.c: New file. * gdb.base/solib-mismatch-libmod.c: New file. * gdb.base/solib-mismatch.c: New file. * gdb.base/solib-mismatch.exp: New file. commit c85cc58af91177b6fee9e56bd58c30280d88a581 Author: Aleksandar Ristovski Date: Wed Mar 27 16:05:19 2013 -0400 Validate symbol file using build-id. * solib-darwin.c (_initialize_darwin_solib): Assign validate value. * solib-dsbt.c (_initialize_dsbt_solib): Ditto. * solib-frv.c (_initialize_frv_solib): Ditto. * solib-ia64-hpux.c (ia64_hpux_target_so_ops): Ditto. * solib-irix.c (_initialize_irix_solib): Ditto. * solib-osf.c (_initialize_osf_solib): Ditto. * solib-pa64.c (_initialize_pa64_solib): Ditto. * solib-som.c (_initialize_som_solib): Ditto. * solib-spu.c (set_spu_solib_ops): Ditto. * solib-sunos.c (_initialize_sunos_solib): Ditto. * solib-svr4.c (NOTE_GNU_BUILD_ID_NAME): New define. (svr4_validate): New function. (library_list_start_library): Parse 'build-id' attribute. (svr4_library_attributes): Add 'build-id' attribute. (_initialize_svr4_solib): Assign validate value. * solib-target.c (solib.h): Include. (_initialize_solib_target): Assign validate value. * solib.c (solib_map_sections): Use ops->validate. (free_so): Free build_id. (solib_validate): New function. * solib.h (solib_validate): New declaration. * solist.h (so_list): New fields 'build_idsz' and 'build_id'. (target_so_ops): New field 'validate'. commit 90e5ca4da95bf8e7a9888dd4ee66c9f9ef3242a8 Author: Aleksandar Ristovski Date: Wed Mar 27 11:56:57 2013 -0400 gdbserver build-id attribute generator * doc/gdb.texinfo (Library List Format for SVR4 Targets): Add 'build-id' in description, example, new attribute in dtd. * features/library-list-svr4.dtd (library-list-svr4): New 'build-id' attribute. * linux-low.c (linux-maps.h, search.h): Include. (ElfXX_Ehdr, ElfXX_Phdr, ElfXX_Nhdr): New. (ELFXX_FLD, ELFXX_SIZEOF, ELFXX_ROUNDUP, BUILD_ID_INVALID): New. (find_phdr): New. (get_dynamic): Use find_pdhr to traverse program headers. (struct mapping_entry): New structure. (mapping_entry_s): New typedef, new vector type def. (free_mapping_entry, compare_mapping_entry, compare_mapping_entry_range, compare_mapping_entry_inode): New. (struct find_memory_region_callback_data): New. (find_memory_region_callback): New fwd. declaration. (read_build_id, find_memory_region_callback, get_hex_build_id): New. (linux_qxfer_libraries_svr4): Add optional build-id attribute to reply XML document. commit 9923a243a7d47715778b7aabec420a273fcc880d Author: Aleksandar Ristovski Date: Wed Mar 27 09:54:36 2013 -0400 Move linux_find_memory_regions_full & co. * common/common-target.c (gdb_assert.h, gdb_string.h): Include. (read_alloc, read_stralloc): Move definitions from target.c. * common/common-target.h (read_alloc_pread_ftype): New typedef. (read_alloc): New declaration. (read_stralloc_func_ftype): New typedef. (read_stralloc): New declaration. * common/linux-maps.c (fcntl.h, unistd.h, target.h, gdb_assert.h, ctype.h, string.h, common-target.h): Include. (read_mapping): Move from linux-tdep.c. (linux_find_memory_read_stralloc_1_pread): New function. (linux_find_memory_read_stralloc_1): New function. (linux_find_memory_read_stralloc): New function. * common/linux-maps.h (read_mapping): New declaration. (linux_find_memory_region_ftype): Moved typedef from linux-tdep.c. (linux_find_memory_regions_full): New declaration. * linux-tdep.c (linux-maps.h): Include. (read_mapping): Moved to common/linux-maps.c. (linux_find_memory_region_ftype): Moved typedef to common/linux-maps.h. (linux_find_memory_regions_full): Moved definition to common/linux-maps.c. * target.c (common-target.h): Include. (read_alloc_pread_ftype): Moved typedef to common/common-target.h. (read_alloc, read_stralloc): Moved definitions to common/common-target.c. commit 9156b67d1f394a904737c304c106730ea4005e38 Author: Aleksandar Ristovski Date: Wed Mar 27 09:49:36 2013 -0400 Prepare linux_find_memory_regions_full & co. for move * linux-tdep.c (linux_find_memory_region_ftype): Comment. (linux_find_memory_regions_full): Change signature and prepare for moving to linux-maps. (linux_find_memory_regions_data): Rename field 'obfd' to 'data'. (linux_find_memory_regions_thunk): New. (linux_find_memory_regions_thunk): Use 'data' field instead of 'obfd'. (linux_find_memory_regions_gdb): New. (linux_find_memory_regions): Rename argument 'obfd' to 'func_data'. (linux_make_mappings_corefile_notes): Use linux_find_memory_regions_gdb. * target.c (read_alloc_pread_ftype): New typedef. (target_fileio_read_alloc_1_pread): New function. (read_alloc): Refactor from target_fileio_read_alloc_1. (read_stralloc_func_ftype): New typedef. (target_fileio_read_alloc_1): New implementation. Use read_alloc. (read_stralloc): Refactored from target_fileio_read_stralloc. (target_fileio_read_stralloc): New implementation, use read_stralloc. commit f3f4f26ac1cbd9405807d5e9d4fb26f65a27d520 Author: Aleksandar Ristovski Date: Wed Mar 27 09:40:24 2013 -0400 Create empty common/linux-maps.[ch] and common/common-target.[ch] * Makefile.in (HFILES_NO_SRCDIR); Add common/linux-maps.h, common/common-target.h. (COMMON_OBS): Add common-target.o. (linux-maps.o, common-target.o): New. * common/common-target.c: New file. * common/common-target.h: New file. * common/linux-maps.c: New file. * common/linux-maps.h: New file. * config/i386/linux.mh (NATDEPFILES): Add linux-maps.o. * config/i386/linux64.mh (NATDEPFILES): Ditto. * gdbserver/Makefile.in (OBS): Add common-taret.o. (linux-maps.o, common-target.o): New. * gdbserver/configure.srv (srv_tgtobj): Add linux-maps.o. commit 5f2fbbb9aef6c57311872673c1b86af0c8e8ee5e Author: Aleksandar Ristovski Date: Wed Mar 27 09:39:05 2013 -0400 Merge multiple hex conversions * common/common-utils.c (fromhex): Make externally linkable. Change error message. (tohex): Make externally linkable. * common/common-utils.h (fromhex, tohex): New declaration. * gdbserver/gdbreplay.c (tohex): Rename to 'fromhex'. (logchar): Use fromhex. * gdbserver/remote-utils.c (fromhex, unhexify): Remove. (tohex, hexify): Remove. (look_up_one_symbol, monitor_output): Use bin2hex instead of hexify. * gdbserver/server.c (handle_query): Use bin2hex instead of hexify. (handle_v_run): Ditto. * gdbserver/server.h (unhexify, hexify): Remove declarations. * gdbserver/tracepoint.c (cmd_qtdpsrc, cmd_qtdv): Use hex2bin instead of unhexify. (cmd_qtstatus): Use bin2hex instead of hexify. (cmd_qtnotes): Use hex2bin instead of unhexify. * monitor.c (fromhex): Remove definition. * remote.c (tohex, fromhex): Remove fwd declarations, remove definitions. commit 4e6ba4862e4190be9ec6a92447d11a7b2c7c0a9e Author: Aleksandar Ristovski Date: Wed Mar 27 09:39:05 2013 -0400 Move utility functions to common/ * cli/cli-utils.c (skip_spaces, skip_spaces_const): Move defs to common/common-utils.c. * cli/cli-utils.h (skip_spaces, skip_spaces_const): Move decls to common/common-utils.h. * common/common-utils.c (ctype.h): Include. (HIGH_BYTE_POSN, is_digit_in_base, digit_to_int, strtoulst): Move from utils.c. (fromhex): Copy from remote.c. (hex2bin): Move from remote.c. (tohex): Copy from remote.c. (bin2hex): Move from remote.c. (skip_spaces, skip_spaces_const): Move from cli/cli-utils.c. * common/common-utils.h (TARGET_CHAR_BIT, HOST_CHAR_BIT): Moved from defs.h. (strtoulst): Move decl from utils.h. (hex2bin, bin2hex): Move decls from remote.h. (skip_spaces, skip_spaces_const): Move decls from cli/cli-utils.h. * defs.h (TARGET_CHAR_BIT, HOST_CHAR_BIT): Move to common/common-utils.h * remote.c (hex2bin, bin2hex): Moved defs to common/common-utils.c. * remote.h (hex2bin, bin2hex): Moved decls to common/common-utils.h. * utils.c (HIGH_BYTE_POSN, is_digit_in_base, digit_to_int, strtoulst): Move to common/common-utils.c. * utils.h (strtoulst): Moved decl to common/common-utils.h. commit f6c8560c008449b811612a2c1560069102f50684 Author: Aleksandar Ristovski Date: Wed Apr 10 14:01:34 2013 -0400 Add README.archer commit 92687545f1f26e54b40d90812b34791d97ecd867 Author: gdbadmin Date: Tue Apr 16 00:00:32 2013 +0000 *** empty log message *** commit 20cf09b42ad2bcb0225cdc36cb228e515bd510a7 Author: Alan Modra Date: Tue Apr 16 00:00:04 2013 +0000 daily update commit 766ce5943c7dd9484310bd71a91a8b19d5b7b5c2 Author: Doug Evans Date: Mon Apr 15 23:53:37 2013 +0000 * dwarf2read.c (struct dwo_file): Replace member "cus" with "cu". (struct create_dwo_cu_data): Renamed from create_dwo_info_table_data. (create_dwo_cu_reader): Renamed from create_dwo_debug_info_hash_table_reader. (create_dwo_cu): Renamed from create_dwo_debug_info_hash_table. Remove support for multiple CUs in a DWO file. (open_and_init_dwo_file, lookup_dwo_cutu): Update. commit 972f1ca0327da78f0eb9cd7fe9a760696642dc75 Author: Doug Evans Date: Mon Apr 15 22:14:40 2013 +0000 * dwarf2read.c (create_debug_types_hash_table): Use hex_string instead of phex. (lookup_dwo_unit, create_dwo_debug_info_hash_table_reader): Ditto. (create_dwo_in_dwp): Ditto. commit cb22b288a796779e3238ff812226a9897854c5aa Author: H.J. Lu Date: Mon Apr 15 21:16:17 2013 +0000 Check regular reference without non-GOT reference non_got_ref may not be set when building shared library. We need to set non_got_ref if there are any non-PIC relocations. But we only did this when there were no PLT/GOT relocations. It failed when there is a PLT relocation. This checkin moves the non_got_ref check out. bfd/ 2013-04-15 H.J. Lu PR ld/15371 * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Check regular reference without non-GOT reference when building shared library. ld/testsuite/ 2013-04-15 H.J. Lu PR ld/15371 * ld-ifunc/ifunc-20-i386.d: New file. * ld-ifunc/ifunc-20-x86-64.d: Likewise. * ld-ifunc/ifunc-20.s: Likewise. diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c index e56427d..7e7ec36 100644 --- a/bfd/elf-ifunc.c +++ b/bfd/elf-ifunc.c @@ -187,23 +187,20 @@ _bfd_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info, htab = elf_hash_table (info); + /* When building shared library, we need to handle the case where it is + marked with regular reference, but not non-GOT reference since the + non-GOT reference bit may not be set here. */ + if (info->shared && !h->non_got_ref && h->ref_regular) + for (p = *head; p != NULL; p = p->next) + if (p->count) + { + h->non_got_ref = 1; + goto keep; + } + /* Support garbage collection against STT_GNU_IFUNC symbols. */ if (h->plt.refcount <= 0 && h->got.refcount <= 0) { - /* When building shared library, we need to handle the case - where it is marked with regular reference, but not non-GOT - reference. It may happen if we didn't see STT_GNU_IFUNC - symbol at the time when checking relocations. */ - if (info->shared - && !h->non_got_ref - && h->ref_regular) - for (p = *head; p != NULL; p = p->next) - if (p->count) - { - h->non_got_ref = 1; - goto keep; - } - h->got = htab->init_got_offset; h->plt = htab->init_plt_offset; *head = NULL; diff --git a/ld/testsuite/ld-ifunc/ifunc-20-i386.d b/ld/testsuite/ld-ifunc/ifunc-20-i386.d new file mode 100644 index 0000000..9373fcf --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-20-i386.d @@ -0,0 +1,13 @@ +#source: ifunc-20.s +#ld: -shared -m elf_i386 -z nocombreloc +#as: --32 +#readelf: -r --wide +#target: x86_64-*-* i?86-*-* + +Relocation section '.rel.ifunc' at offset 0x[0-9a-f]+ contains 1 entries: +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_32[ ]+ifunc\(\)[ ]+ifunc + +Relocation section '.rel.plt' at offset 0x[0-9a-f]+ contains 1 entries: +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_386_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc diff --git a/ld/testsuite/ld-ifunc/ifunc-20-x86-64.d b/ld/testsuite/ld-ifunc/ifunc-20-x86-64.d new file mode 100644 index 0000000..39492d4 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-20-x86-64.d @@ -0,0 +1,13 @@ +#source: ifunc-20.s +#ld: -shared -m elf_x86_64 -z nocombreloc +#as: --64 +#readelf: -r --wide +#target: x86_64-*-* + +Relocation section '.rela.ifunc' at offset 0x[0-9a-f]+ contains 1 entries: +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_64[ ]+ifunc\(\)[ ]+ifunc \+ 0 + +Relocation section '.rela.plt' at offset 0x[0-9a-f]+ contains 1 entries: +[ ]+Offset[ ]+Info[ ]+Type[ ]+.* +[0-9a-f]+[ ]+[0-9a-f]+[ ]+R_X86_64_JUMP_SLOT[ ]+ifunc\(\)[ ]+ifunc \+ 0 diff --git a/ld/testsuite/ld-ifunc/ifunc-20.s b/ld/testsuite/ld-ifunc/ifunc-20.s new file mode 100644 index 0000000..9d45455 --- /dev/null +++ b/ld/testsuite/ld-ifunc/ifunc-20.s @@ -0,0 +1,16 @@ + .section .data.rel,"aw",@progbits + .globl ifunc_ptrt + .type ifunc_ptr, @object +ifunc_ptr: + .dc.a ifunc + .text + .type ifunc, @gnu_indirect_function + .globl ifunc +ifunc: + ret + .size ifunc, .-ifunc + .type bar, @function + .globl bar +bar: + call ifunc@PLT + .size bar, .-bar commit 049dc1118adce445d49828154b415f963c41a4d5 Author: sivachandra Date: Mon Apr 15 20:37:36 2013 +0000 2013-04-15 Siva Chandra Reddy Add option to link testcases with Pthreads library when using 'prepare_for_testing' in tests. testsuite/ * lib/gdb.exp (build_executable_from_specs): Use gdb_compile_pthreads to compile if option "pthreads" is specified. ----------------------------------------------------------------------- Summary of changes: bfd/ChangeLog | 7 ++ bfd/elf-ifunc.c | 25 +++---- bfd/version.h | 2 +- gdb/ChangeLog | 15 ++++ gdb/dwarf2read.c | 160 +++++++++++++++++++++++---------------------- gdb/gdbserver/linux-low.c | 123 +++++++++++++++-------------------- gdb/testsuite/ChangeLog | 9 +++ gdb/testsuite/lib/gdb.exp | 20 ++++-- gdb/version.in | 2 +- 9 files changed, 195 insertions(+), 168 deletions(-) First 500 lines of diff: diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e717f12..883c4a2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2013-04-15 H.J. Lu + + PR ld/15371 + * elf-ifunc.c (_bfd_elf_allocate_ifunc_dyn_relocs): Check + regular reference without non-GOT reference when building + shared library. + 2013-04-15 Alan Modra * archive.c (_bfd_archive_close_and_cleanup): Clear parent diff --git a/bfd/elf-ifunc.c b/bfd/elf-ifunc.c index e56427d..7e7ec36 100644 --- a/bfd/elf-ifunc.c +++ b/bfd/elf-ifunc.c @@ -187,23 +187,20 @@ _bfd_elf_allocate_ifunc_dyn_relocs (struct bfd_link_info *info, htab = elf_hash_table (info); + /* When building shared library, we need to handle the case where it is + marked with regular reference, but not non-GOT reference since the + non-GOT reference bit may not be set here. */ + if (info->shared && !h->non_got_ref && h->ref_regular) + for (p = *head; p != NULL; p = p->next) + if (p->count) + { + h->non_got_ref = 1; + goto keep; + } + /* Support garbage collection against STT_GNU_IFUNC symbols. */ if (h->plt.refcount <= 0 && h->got.refcount <= 0) { - /* When building shared library, we need to handle the case - where it is marked with regular reference, but not non-GOT - reference. It may happen if we didn't see STT_GNU_IFUNC - symbol at the time when checking relocations. */ - if (info->shared - && !h->non_got_ref - && h->ref_regular) - for (p = *head; p != NULL; p = p->next) - if (p->count) - { - h->non_got_ref = 1; - goto keep; - } - h->got = htab->init_got_offset; h->plt = htab->init_plt_offset; *head = NULL; diff --git a/bfd/version.h b/bfd/version.h index a62bb74..f564488 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -1,4 +1,4 @@ -#define BFD_VERSION_DATE 20130415 +#define BFD_VERSION_DATE 20130416 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f36f87c..2595f8d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,18 @@ +2013-04-15 Doug Evans + + * dwarf2read.c (struct dwo_file): Replace member "cus" with "cu". + (struct create_dwo_cu_data): Renamed from create_dwo_info_table_data. + (create_dwo_cu_reader): Renamed from + create_dwo_debug_info_hash_table_reader. + (create_dwo_cu): Renamed from create_dwo_debug_info_hash_table. + Remove support for multiple CUs in a DWO file. + (open_and_init_dwo_file, lookup_dwo_cutu): Update. + + * dwarf2read.c (create_debug_types_hash_table): Use hex_string + instead of phex. + (lookup_dwo_unit, create_dwo_debug_info_hash_table_reader): Ditto. + (create_dwo_in_dwp): Ditto. + 2013-04-15 Tom Tromey * NEWS: Move recent entries into "since 7.6" section. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 8947f8f..0542bea 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -742,9 +742,12 @@ struct dwo_file /* Section info for this file. */ struct dwo_sections sections; - /* Table of CUs in the file. - Each element is a struct dwo_unit. */ - htab_t cus; + /* The CU in the file. + We only support one because having more than one requires hacking the + dwo_name of each to match, which is highly unlikely to happen. + Doing this means all TUs can share comp_dir: We also assume that + DW_AT_comp_dir across all TUs in a DWO file will be identical. */ + struct dwo_unit *cu; /* Table of TUs in the file. Each element is a struct dwo_unit. */ @@ -4317,16 +4320,16 @@ create_debug_types_hash_table (struct dwo_file *dwo_file, complaint (&symfile_complaints, _("debug type entry at offset 0x%x is duplicate to" - " the entry at offset 0x%x, signature 0x%s"), + " the entry at offset 0x%x, signature %s"), offset.sect_off, dup_offset.sect_off, - phex (signature, sizeof (signature))); + hex_string (signature)); } *slot = dwo_file ? (void *) dwo_tu : (void *) sig_type; if (dwarf2_read_debug) - fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature 0x%s\n", + fprintf_unfiltered (gdb_stdlog, " offset 0x%x, signature %s\n", offset.sect_off, - phex (signature, sizeof (signature))); + hex_string (signature)); info_ptr += length; } @@ -4634,8 +4637,7 @@ lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu, { error (_("Dwarf Error: CU at offset 0x%x references unknown DWO" " with ID %s [in module %s]"), - this_cu->offset.sect_off, - phex (signature, sizeof (signature)), + this_cu->offset.sect_off, hex_string (signature), this_cu->objfile->name); } @@ -8389,85 +8391,64 @@ allocate_dwo_unit_table (struct objfile *objfile) /* Structure used to pass data to create_dwo_debug_info_hash_table_reader. */ -struct create_dwo_info_table_data +struct create_dwo_cu_data { struct dwo_file *dwo_file; - htab_t cu_htab; + struct dwo_unit dwo_unit; }; -/* die_reader_func for create_dwo_debug_info_hash_table. */ +/* die_reader_func for create_dwo_cu. */ static void -create_dwo_debug_info_hash_table_reader (const struct die_reader_specs *reader, - const gdb_byte *info_ptr, - struct die_info *comp_unit_die, - int has_children, - void *datap) +create_dwo_cu_reader (const struct die_reader_specs *reader, + const gdb_byte *info_ptr, + struct die_info *comp_unit_die, + int has_children, + void *datap) { struct dwarf2_cu *cu = reader->cu; struct objfile *objfile = dwarf2_per_objfile->objfile; sect_offset offset = cu->per_cu->offset; struct dwarf2_section_info *section = cu->per_cu->section; - struct create_dwo_info_table_data *data = datap; + struct create_dwo_cu_data *data = datap; struct dwo_file *dwo_file = data->dwo_file; - htab_t cu_htab = data->cu_htab; - void **slot; + struct dwo_unit *dwo_unit = &data->dwo_unit; struct attribute *attr; - struct dwo_unit *dwo_unit; attr = dwarf2_attr (comp_unit_die, DW_AT_GNU_dwo_id, cu); if (attr == NULL) { - error (_("Dwarf Error: debug entry at offset 0x%x is missing" - " its dwo_id [in module %s]"), - offset.sect_off, dwo_file->dwo_name); + complaint (&symfile_complaints, + _("Dwarf Error: debug entry at offset 0x%x is missing" + " its dwo_id [in module %s]"), + offset.sect_off, dwo_file->dwo_name); return; } - dwo_unit = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwo_unit); dwo_unit->dwo_file = dwo_file; dwo_unit->signature = DW_UNSND (attr); dwo_unit->section = section; dwo_unit->offset = offset; dwo_unit->length = cu->per_cu->length; - slot = htab_find_slot (cu_htab, dwo_unit, INSERT); - gdb_assert (slot != NULL); - if (*slot != NULL) - { - const struct dwo_unit *dup_dwo_unit = *slot; - - complaint (&symfile_complaints, - _("debug entry at offset 0x%x is duplicate to the entry at" - " offset 0x%x, dwo_id 0x%s [in module %s]"), - offset.sect_off, dup_dwo_unit->offset.sect_off, - phex (dwo_unit->signature, sizeof (dwo_unit->signature)), - dwo_file->dwo_name); - } - else - *slot = dwo_unit; - if (dwarf2_read_debug) - fprintf_unfiltered (gdb_stdlog, " offset 0x%x, dwo_id 0x%s\n", - offset.sect_off, - phex (dwo_unit->signature, - sizeof (dwo_unit->signature))); + fprintf_unfiltered (gdb_stdlog, " offset 0x%x, dwo_id %s\n", + offset.sect_off, hex_string (dwo_unit->signature)); } -/* Create a hash table to map DWO IDs to their CU entry in - .debug_info.dwo in DWO_FILE. - Note: This function processes DWO files only, not DWP files. - Note: A DWO file generally contains one CU, but we don't assume this. */ +/* Create the dwo_unit for the lone CU in DWO_FILE. + Note: This function processes DWO files only, not DWP files. */ -static htab_t -create_dwo_debug_info_hash_table (struct dwo_file *dwo_file) +static struct dwo_unit * +create_dwo_cu (struct dwo_file *dwo_file) { struct objfile *objfile = dwarf2_per_objfile->objfile; struct dwarf2_section_info *section = &dwo_file->sections.info; bfd *abfd; htab_t cu_htab; const gdb_byte *info_ptr, *end_ptr; - struct create_dwo_info_table_data create_dwo_info_table_data; + struct create_dwo_cu_data create_dwo_cu_data; + struct dwo_unit *dwo_unit; dwarf2_read_section (objfile, section); info_ptr = section->buffer; @@ -8480,19 +8461,22 @@ create_dwo_debug_info_hash_table (struct dwo_file *dwo_file) abfd = section->asection->owner; if (dwarf2_read_debug) - fprintf_unfiltered (gdb_stdlog, "Reading .debug_info.dwo for %s:\n", - bfd_get_filename (abfd)); - - cu_htab = allocate_dwo_unit_table (objfile); + { + fprintf_unfiltered (gdb_stdlog, "Reading %s for %s:\n", + bfd_section_name (abfd, section->asection), + bfd_get_filename (abfd)); + } - create_dwo_info_table_data.dwo_file = dwo_file; - create_dwo_info_table_data.cu_htab = cu_htab; + create_dwo_cu_data.dwo_file = dwo_file; + dwo_unit = NULL; end_ptr = info_ptr + section->size; while (info_ptr < end_ptr) { struct dwarf2_per_cu_data per_cu; + memset (&create_dwo_cu_data.dwo_unit, 0, + sizeof (create_dwo_cu_data.dwo_unit)); memset (&per_cu, 0, sizeof (per_cu)); per_cu.objfile = objfile; per_cu.is_debug_types = 0; @@ -8502,13 +8486,30 @@ create_dwo_debug_info_hash_table (struct dwo_file *dwo_file) init_cutu_and_read_dies_no_follow (&per_cu, &dwo_file->sections.abbrev, dwo_file, - create_dwo_debug_info_hash_table_reader, - &create_dwo_info_table_data); + create_dwo_cu_reader, + &create_dwo_cu_data); + + if (create_dwo_cu_data.dwo_unit.dwo_file != NULL) + { + /* If we've already found one, complain. We only support one + because having more than one requires hacking the dwo_name of + each to match, which is highly unlikely to happen. */ + if (dwo_unit != NULL) + { + complaint (&symfile_complaints, + _("Multiple CUs in DWO file %s [in module %s]"), + dwo_file->dwo_name, objfile->name); + break; + } + + dwo_unit = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct dwo_unit); + *dwo_unit = create_dwo_cu_data.dwo_unit; + } info_ptr += per_cu.length; } - return cu_htab; + return dwo_unit; } /* DWP file .debug_{cu,tu}_index section format: @@ -8734,9 +8735,9 @@ create_dwo_in_dwp (struct dwp_file *dwp_file, if (dwarf2_read_debug) { - fprintf_unfiltered (gdb_stdlog, "Reading %s %u/0x%s in DWP file: %s\n", + fprintf_unfiltered (gdb_stdlog, "Reading %s %u/%s in DWP file: %s\n", kind, - section_index, phex (signature, sizeof (signature)), + section_index, hex_string (signature), dwp_file->name); } @@ -9059,7 +9060,7 @@ dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr) } /* Initialize the use of the DWO file specified by DWO_NAME and referenced - by PER_CU. + by PER_CU. This is for the non-DWP case. The result is NULL if DWO_NAME can't be found. */ static struct dwo_file * @@ -9087,7 +9088,7 @@ open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu, bfd_map_over_sections (dbfd, dwarf2_locate_dwo_sections, &dwo_file->sections); - dwo_file->cus = create_dwo_debug_info_hash_table (dwo_file); + dwo_file->cu = create_dwo_cu (dwo_file); dwo_file->tus = create_debug_types_hash_table (dwo_file, dwo_file->sections.types); @@ -9318,26 +9319,31 @@ lookup_dwo_cutu (struct dwarf2_per_cu_data *this_unit, if (dwo_file != NULL) { - htab_t htab = is_debug_types ? dwo_file->tus : dwo_file->cus; + struct dwo_unit *dwo_cutu = NULL; - if (htab != NULL) + if (is_debug_types && dwo_file->tus) { - struct dwo_unit find_dwo_cutu, *dwo_cutu; + struct dwo_unit find_dwo_cutu; memset (&find_dwo_cutu, 0, sizeof (find_dwo_cutu)); find_dwo_cutu.signature = signature; - dwo_cutu = htab_find (htab, &find_dwo_cutu); + dwo_cutu = htab_find (dwo_file->tus, &find_dwo_cutu); + } + else if (!is_debug_types && dwo_file->cu) + { + if (signature == dwo_file->cu->signature) + dwo_cutu = dwo_file->cu; + } - if (dwo_cutu != NULL) + if (dwo_cutu != NULL) + { + if (dwarf2_read_debug) { - if (dwarf2_read_debug) - { - fprintf_unfiltered (gdb_stdlog, "DWO %s %s(%s) found: @%s\n", - kind, dwo_name, hex_string (signature), - host_address_to_string (dwo_cutu)); - } - return dwo_cutu; + fprintf_unfiltered (gdb_stdlog, "DWO %s %s(%s) found: @%s\n", + kind, dwo_name, hex_string (signature), + host_address_to_string (dwo_cutu)); } + return dwo_cutu; } } diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 8d8ba17..eac5318 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -5462,9 +5462,7 @@ get_phdr_phnum_from_proc_auxv (const int pid, const int is_elf64, return 0; } -/* Linearly traverse pheaders given in PHDR until supplied - predicate function returns 1. If supplied predicate function - did return 1, stop traversal and return that PHDR. */ +/* Linearly traverse pheaders and look for P_TYPE pheader. */ static const void * find_phdr (const int is_elf64, const void *const phdr_begin, @@ -5475,9 +5473,6 @@ find_phdr (const int is_elf64, const void *const phdr_begin, const ElfXX_Phdr *phdr = phdr_begin; - if (phdr == NULL) - return NULL; - while (PHDR_NEXT (phdr) <= phdr_end) { if (ELFXX_FLD (is_elf64, *phdr, p_type) == p_type) @@ -5497,8 +5492,8 @@ get_dynamic (const int pid, const int is_elf64) CORE_ADDR phdr_memaddr, relocation; int num_phdr; unsigned char *phdr_buf; - const int phdr_size = is_elf64 ? sizeof (Elf64_Phdr) : sizeof (Elf32_Phdr); - const void *phdr; + const ElfXX_Phdr *phdr; + const int phdr_size = ELFXX_SIZEOF (is_elf64, *phdr); if (get_phdr_phnum_from_proc_auxv (pid, is_elf64, &phdr_memaddr, &num_phdr)) return 0; @@ -5515,21 +5510,7 @@ get_dynamic (const int pid, const int is_elf64) phdr = find_phdr (is_elf64, phdr_buf, phdr_buf + num_phdr * phdr_size, PT_PHDR); if (phdr != NULL) - { - if (is_elf64) - { - const Elf64_Phdr *const p = phdr; - - relocation = phdr_memaddr - p->p_vaddr; - } - else - { - const Elf32_Phdr *const p = phdr; - - relocation = phdr_memaddr - p->p_vaddr; - } - } - + relocation = phdr_memaddr - ELFXX_FLD (is_elf64, *phdr, p_vaddr); if (relocation == -1) { /* PT_PHDR is optional, but necessary for PIE in general. Fortunately @@ -5549,20 +5530,7 @@ get_dynamic (const int pid, const int is_elf64) PT_DYNAMIC); if (phdr != NULL) - { - if (is_elf64) - { - const Elf64_Phdr *const p = phdr; - - return p->p_vaddr + relocation; - } - else - { - const Elf32_Phdr *const p = phdr; - - return p->p_vaddr + relocation; - } - } + return ELFXX_FLD (is_elf64, *phdr, p_vaddr) + relocation; return 0; } @@ -5725,8 +5693,10 @@ typedef struct mapping_entry mapping_entry_s; DEF_VEC_O(mapping_entry_s); +/* Free vector of mapping_entry_s objects. */ + static void -free_mapping_entry (VEC (mapping_entry_s) *lst) +free_mapping_entry_vec (VEC (mapping_entry_s) *lst) { int ix; mapping_entry_s *p; @@ -5743,7 +5713,7 @@ free_mapping_entry (VEC (mapping_entry_s) *lst) static int compare_mapping_entry_range (const void *const k, const void *const b) { - const ULONGEST key = *(CORE_ADDR*) k; + const ULONGEST key = *(CORE_ADDR *) k; const mapping_entry_s *const p = b; if (key < p->vaddr) @@ -5759,14 +5729,14 @@ struct find_memory_region_callback_data { unsigned is_elf64; - /* Return. Ordered list of all object mappings sorted in - ascending order by VADDR. Must be freed with free_mapping_entry. */ + /* Return. Must be freed with free_mapping_entry_vec. */ VEC (mapping_entry_s) *list; }; -static linux_find_memory_region_ftype find_memory_region_callback; - -/* Read build-id from PT_NOTE. */ +/* Read build-id from PT_NOTE. + Argument LOAD_ADDR pepresents run time virtual address corresponding to hooks/post-receive -- Repository for Project Archer.