From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19911 invoked by alias); 2 May 2010 15:54:17 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 19868 invoked by uid 9674); 2 May 2010 15:54:16 -0000 Date: Sun, 02 May 2010 15:54:00 -0000 Message-ID: <20100502155416.19853.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] master: Merge remote branch 'gdb/master' X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 6f316690aaae8e0cbc09fe722a50c71292a9b8c0 X-Git-Newrev: f435677142e149f7298f24769d5047a9cec54977 X-SW-Source: 2010-q2/txt/msg00038.txt.bz2 List-Id: The branch, master has been updated via f435677142e149f7298f24769d5047a9cec54977 (commit) via 79a428f4a05c32fb55d88492ea042c748f31f40c (commit) via 0e4debf4f732f631368b794e95b47d8322c413bb (commit) via fa4a9b9107fc5a47692649270cdb07c8eeef3d47 (commit) via 8f0cde7c65bdccbb1471eaa65437c7803fbefb4d (commit) via ff7a32364a3fab68b62298c514dba750141ad68e (commit) via 41913fd3a887565e2abc63e867b4357122820015 (commit) via 02acd6f7d5788125c9b26b1532bb3441ed9bfe5e (commit) via faa0af7963038e3a5f0d9366837e02fb956f81f8 (commit) via b0ac534d8cfc7f24f31b6c02b4177b55e75507c4 (commit) via 8f7056958860649bc9200db2e40f10df172a2c6e (commit) via 429e6ea3034841abe6d7937179cff50d898875aa (commit) via 16541465c3aebfffc007dc977b4b5bd59de646c0 (commit) via 4a525c8f93a1f3344947db9b89d78ec523090c23 (commit) via b319a9de41dbab17e8c4c6cb87ad56b7b6e5c582 (commit) via 7b57f4a47be72d3d85cb208a98f5ac386fd7cbfb (commit) via 93d636881f46c4fdd4688adf1f4862debb5970f7 (commit) via f5984db56b3b95ba0ba90570e7e6dff288c56278 (commit) via c42e51ce369144aaaf29104e654fbbcfe3fa92f7 (commit) from 6f316690aaae8e0cbc09fe722a50c71292a9b8c0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit f435677142e149f7298f24769d5047a9cec54977 Merge: 6f316690aaae8e0cbc09fe722a50c71292a9b8c0 79a428f4a05c32fb55d88492ea042c748f31f40c Author: Jan Kratochvil Date: Sun May 2 17:53:59 2010 +0200 Merge remote branch 'gdb/master' commit 79a428f4a05c32fb55d88492ea042c748f31f40c Author: Jan Kratochvil Date: Sun May 2 09:13:34 2010 +0000 gdb/ * cli/cli-dump.h (parse_and_eval_with_error): Remove the declaration. commit 0e4debf4f732f631368b794e95b47d8322c413bb Author: Jan Kratochvil Date: Sun May 2 09:08:58 2010 +0000 gdb/testsuite/ * gdb.base/break-interp.exp: Remove $exec.debug safety removal. * gdb.base/sepdebug.exp: Remove .debug subdirectory handling. New variable different_dir. Move debugfile into a full directory pathname under DIFFERENT_DIR. * lib/gdb.exp (separate_debug_filename): Remove. (gdb_gnu_strip_debug): No longer call separate_debug_filename. Remove variable debug_dir and mkdir of it. Update function comments. commit fa4a9b9107fc5a47692649270cdb07c8eeef3d47 Author: Pedro Alves Date: Sun May 2 00:47:34 2010 +0000 * linux-low.c (linux_kill_one_lwp): Assume the lwp is stopped. (linux_kill): Stop all lwps here. Don't delete the main lwp here. (linux_detach_one_lwp): Assume the lwp is stopped. (any_thread_of): Delete. (linux_detach): Stop all lwps here. Don't blindly delete all breakpoints. (delete_lwp_callback): New. (linux_mourn): Delete all lwps of the process that is gone. (linux_wait_1): Don't delete the last lwp of the process here. * mem-break.h (mark_breakpoints_out): Declare. * mem-break.c (mark_breakpoints_out): New. (free_all_breakpoints): Use it. * server.c (handle_target_event): If the process is gone, mark breakpoints out. * thread-db.c (struct thread_db) : New field. (thread_db_enable_reporting): Fix prototype. Store a thread event breakpoint reference in the thread_db struct. (thread_db_load_search): Clear the thread_db object. (try_thread_db_load_1): Ditto. (switch_to_process): New. (disable_thread_event_reporting): Use it. (remove_thread_event_breakpoints): New. (thread_db_detach, thread_db_mourn): Use it. commit 8f0cde7c65bdccbb1471eaa65437c7803fbefb4d Author: gdbadmin Date: Sun May 2 00:00:33 2010 +0000 *** empty log message *** commit ff7a32364a3fab68b62298c514dba750141ad68e Author: Alan Modra Date: Sun May 2 00:00:05 2010 +0000 daily update commit 41913fd3a887565e2abc63e867b4357122820015 Author: Pedro Alves Date: Sat May 1 15:56:51 2010 +0000 * infrun.c (prepare_for_detach): In non-stop, context switch to the thread that got the event before handling the event. commit 02acd6f7d5788125c9b26b1532bb3441ed9bfe5e Author: Pedro Alves Date: Sat May 1 15:46:26 2010 +0000 * linux-low.c (linux_enable_event_reporting): New. (linux_wait_for_event_1, handle_extended_wait): Use it. commit faa0af7963038e3a5f0d9366837e02fb956f81f8 Author: Alan Modra Date: Sat May 1 00:00:05 2010 +0000 daily update commit b0ac534d8cfc7f24f31b6c02b4177b55e75507c4 Author: gdbadmin Date: Sat May 1 00:00:03 2010 +0000 *** empty log message *** commit 8f7056958860649bc9200db2e40f10df172a2c6e Author: Pedro Alves Date: Fri Apr 30 21:36:44 2010 +0000 * linux-low.c (linux_kill_one_lwp, linux_kill) (linux_detach_one_lwp): Adjust to send_sigstop interface change. (send_sigstop): Take an lwp_info as parameter instead. Queue a SIGSTOP even if the LWP is stopped. (send_sigstop_callback): New. (stop_all_lwps): Use send_sigstop_callback instead. (linux_resume_one_thread): Adjust. (proceed_one_lwp): Still proceed an LWP that the client has requested to stop, if we haven't reported it as stopped yet. Make sure that LWPs the client want stopped, have a pending SIGSTOP. commit 429e6ea3034841abe6d7937179cff50d898875aa Author: H.J. Lu Date: Fri Apr 30 18:27:25 2010 +0000 Remove relocation against discarded sections for relocatable link. bfd/ 2010-04-30 H.J. Lu PR ld/11542 * elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): New. * elf32-i386.c (elf_i386_relocate_section): Use it. * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. ld/testsuite/ 2010-04-30 H.J. Lu PR ld/11542 * ld-elf/discard.ld: New. * ld-elf/discard1.d: Likewise. * ld-elf/discard1.s: Likewise. * ld-elf/discard2.d: Likewise. * ld-elf/discard2.s: Likewise. * ld-elf/discard3.d: Likewise. commit 16541465c3aebfffc007dc977b4b5bd59de646c0 Author: Tom Tromey Date: Fri Apr 30 17:43:55 2010 +0000 * symtab.c (symbol_set_names): Fix typo. commit 4a525c8f93a1f3344947db9b89d78ec523090c23 Author: Pierre Muller Date: Fri Apr 30 16:22:41 2010 +0000 * python/py-param.c (parm_constants): Avoid ARI warning by adding ARI comment. (parmpy_init): Likewise. commit b319a9de41dbab17e8c4c6cb87ad56b7b6e5c582 Author: Pierre Muller Date: Fri Apr 30 15:38:40 2010 +0000 * windows-tdep.c (windows_get_tlb_type): Remember last GDBARCH and created type for re-use. commit 7b57f4a47be72d3d85cb208a98f5ac386fd7cbfb Author: Tristan Gingold Date: Fri Apr 30 12:44:31 2010 +0000 bfd/ 2010-04-30 Tristan Gingold * vms-lib.c (vms_read_block): New function. (vms_traverse_index): Use vms_read_block. Handle long key names. include/vms/ 2010-04-30 Tristan Gingold * lbr.h (struct vms_kbn): New structure. commit 93d636881f46c4fdd4688adf1f4862debb5970f7 Author: Tristan Gingold Date: Fri Apr 30 12:44:31 2010 +0000 bfd/ 2010-04-30 Tristan Gingold * vms-lib.c (vms_read_block): New function. (vms_traverse_index): Use vms_read_block. Handle long key names. include/vms/ 2010-04-30 Tristan Gingold * lbr.h (struct vms_kbn): New structure. commit f5984db56b3b95ba0ba90570e7e6dff288c56278 Author: Tristan Gingold Date: Fri Apr 30 09:40:41 2010 +0000 bfd/ 2010-04-30 Tristan Gingold * vms-lib.c (struct lib_tdata): Field artdata added, fields nbr_syms and syms removed. (struct carsym_mem): New structure. (vms_add_index): New function. (vms_add_indexes_from_list): New function. (vms_traverse_index): Parameter carsym changed to carsym_mem. Code adjusted to handle elfidx. (vms_lib_read_index): Adjusted for vms_traverse_index changes. Parameter NBREL is now a pointer. (_bfd_vms_lib_archive_p): Adjust for above change. Handle ia64 archives. (_bfd_vms_lib_mkarchive): Adjusted for changes in struct lib_tdata. (_bfd_vms_lib_find_symbol): Ditto. (vms_lib_bopen): Fix two typos: return FALSE in case of error, check MHD id. * vms-alpha.c (alpha_vms_link_add_archive_symbols): Adjust for changes of _bfd_vms_lib_find_symbol. include/vms 2010-04-30 Tristan Gingold * lbr.h (LBR__C_TYP_ISHSTB): Added. (LHD_SANEID4): Renamed to ... (LHD_SANEID6): ... this. (LBR_MAJORID, LBR_ELFMAJORID): New macros. (struct vms_rfa): New structure. (struct vms_idxdef): Renamed to ... (struct vms_idx): ... this. (struct vms_idxdef2): Renamed to ... (struct vms_elfidx): ... this. (ELFIDX__WEAK, ELFIDX__GROUP, ELFIDX__LISTRFA, ELFIDX__SYMESC): New macros. (struct vms_lhs, struct vms_lns): New structures. (struct vms_mhd): Add missing fields. (MHD__C_MHDLEN): New macro. commit c42e51ce369144aaaf29104e654fbbcfe3fa92f7 Author: Pierre Muller Date: Fri Apr 30 07:04:46 2010 +0000 * NEWS: Mention gdbserver support for x86_64 Windows 64-bit. ----------------------------------------------------------------------- Summary of changes: bfd/ChangeLog | 39 +++ bfd/elf-bfd.h | 42 +++ bfd/elf32-i386.c | 11 +- bfd/elf64-x86-64.c | 11 +- bfd/version.h | 2 +- bfd/vms-alpha.c | 8 +- bfd/vms-lib.c | 523 ++++++++++++++++++++++++------- gdb/ChangeLog | 28 ++ gdb/NEWS | 2 + gdb/cli/cli-dump.h | 2 - gdb/gdbserver/ChangeLog | 44 +++ gdb/gdbserver/linux-low.c | 157 ++++++---- gdb/gdbserver/mem-break.c | 14 +- gdb/gdbserver/mem-break.h | 4 + gdb/gdbserver/server.c | 5 +- gdb/gdbserver/thread-db.c | 66 ++++- gdb/infrun.c | 8 + gdb/python/py-param.c | 5 +- gdb/symtab.c | 2 +- gdb/testsuite/ChangeLog | 10 + gdb/testsuite/gdb.base/break-interp.exp | 4 - gdb/testsuite/gdb.base/sepdebug.exp | 17 +- gdb/testsuite/lib/gdb.exp | 36 +-- gdb/version.in | 2 +- gdb/windows-tdep.c | 9 + include/vms/ChangeLog | 21 ++ include/vms/lbr.h | 92 +++++- 27 files changed, 888 insertions(+), 276 deletions(-) First 500 lines of diff: diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 19306b2..74dd28b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,42 @@ +2010-04-30 H.J. Lu + + PR ld/11542 + * elf-bfd.h (RELOC_AGAINST_DISCARDED_SECTION): New. + + * elf32-i386.c (elf_i386_relocate_section): Use it. + * elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise. + +2010-04-30 Tristan Gingold + + * vms-lib.c (vms_read_block): New function. + (vms_traverse_index): Use vms_read_block. Handle long key names. + +2010-04-30 Tristan Gingold + + * vms-lib.c (struct lib_tdata): Field artdata added, fields nbr_syms + and syms removed. + (struct carsym_mem): New structure. + (vms_add_index): New function. + (vms_add_indexes_from_list): New function. + (vms_traverse_index): Parameter carsym changed to carsym_mem. + Code adjusted to handle elfidx. + (vms_lib_read_index): Adjusted for vms_traverse_index changes. + Parameter NBREL is now a pointer. + (_bfd_vms_lib_archive_p): Adjust for above change. Handle ia64 + archives. + (_bfd_vms_lib_mkarchive): Adjusted for changes in struct lib_tdata. + (_bfd_vms_lib_find_symbol): Ditto. + (vms_lib_bopen): Fix two typos: return FALSE in case of error, + check MHD id. + (_bfd_vms_lib_get_module): New function. + (_bfd_vms_lib_get_elt_at_index): Rewritten using the above + function. + (_bfd_vms_lib_openr_next_archived_file): Use _bfd_vms_lib_get_module. + (_bfd_vms_lib_generic_stat_arch_elt): Handle ia64 archives. + (vms_write_index): Adjust for structure renamed. + * vms-alpha.c (alpha_vms_link_add_archive_symbols): Adjust for + changes of _bfd_vms_lib_find_symbol. + 2010-04-28 Kai Tietz * config.bfd: Correct accidential reverted patch diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 0c975dc..226b95f 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2328,6 +2328,48 @@ extern asection _bfd_elf_large_com_section; } \ while (0) +/* This macro is to avoid lots of duplicated code in the body of the + loop over relocations in xxx_relocate_section() in the various + elfxx-xxxx.c files. + + Handle relocations against symbols from removed linkonce sections, + or sections discarded by a linker script. When doing a relocatable + link, we remove such relocations. Otherwise, we just want the + section contents zeroed and avoid any special processing. */ +#define RELOC_AGAINST_DISCARDED_SECTION(info, input_bfd, input_section, \ + rel, relend, howto, contents) \ + { \ + if (info->relocatable \ + && (input_section->flags & SEC_DEBUGGING)) \ + { \ + /* Only remove relocations in debug sections since other \ + sections may require relocations. */ \ + Elf_Internal_Shdr *rel_hdr; \ + \ + rel_hdr = &elf_section_data (input_section->output_section)->rel_hdr; \ + \ + /* Avoid empty output section. */ \ + if (rel_hdr->sh_size > rel_hdr->sh_entsize) \ + { \ + rel_hdr->sh_size -= rel_hdr->sh_entsize; \ + rel_hdr = &elf_section_data (input_section)->rel_hdr; \ + rel_hdr->sh_size -= rel_hdr->sh_entsize; \ + \ + memmove (rel, rel + 1, (relend - rel) * sizeof (*rel)); \ + \ + input_section->reloc_count--; \ + relend--; \ + rel--; \ + continue; \ + } \ + } \ + \ + _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); \ + rel->r_info = 0; \ + rel->r_addend = 0; \ + continue; \ + } + /* Will a symbol be bound to the the definition within the shared library, if any. A unique symbol can never be bound locally. */ #define SYMBOLIC_BIND(INFO, H) \ diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 395a6bb..7964c4f 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2955,15 +2955,8 @@ elf_i386_relocate_section (bfd *output_bfd, } if (sec != NULL && elf_discarded_section (sec)) - { - /* For relocs against symbols from removed linkonce sections, - or sections discarded by a linker script, we just want the - section contents zeroed. Avoid any special processing. */ - _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); - rel->r_info = 0; - rel->r_addend = 0; - continue; - } + RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, + rel, relend, howto, contents); if (info->relocatable) continue; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 3a24cca..21524fa 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -2685,15 +2685,8 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, } if (sec != NULL && elf_discarded_section (sec)) - { - /* For relocs against symbols from removed linkonce sections, - or sections discarded by a linker script, we just want the - section contents zeroed. Avoid any special processing. */ - _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset); - rel->r_info = 0; - rel->r_addend = 0; - continue; - } + RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, + rel, relend, howto, contents); if (info->relocatable) continue; diff --git a/bfd/version.h b/bfd/version.h index 559de31..e8522de 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -1,4 +1,4 @@ -#define BFD_VERSION_DATE 20100430 +#define BFD_VERSION_DATE 20100502 #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/bfd/vms-alpha.c b/bfd/vms-alpha.c index 3013192..294bd90 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -8040,7 +8040,7 @@ alpha_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) for (pundef = &info->hash->undefs; *pundef != NULL; pundef = next_pundef) { struct bfd_link_hash_entry *h; - file_ptr file_offset; + symindex symidx; bfd *element; bfd *orig_element; @@ -8066,14 +8066,14 @@ alpha_vms_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) } /* Look for this symbol in the archive hash table. */ - file_offset = _bfd_vms_lib_find_symbol (abfd, h->root.string); - if (file_offset == 0) + symidx = _bfd_vms_lib_find_symbol (abfd, h->root.string); + if (symidx == BFD_NO_MORE_SYMBOLS) { /* Nothing in this slot. */ continue; } - element = bfd_get_elt_at_index (abfd, file_offset); + element = bfd_get_elt_at_index (abfd, symidx); if (element == NULL) return FALSE; diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c index d05fab7..bd5ecb7 100644 --- a/bfd/vms-lib.c +++ b/bfd/vms-lib.c @@ -62,6 +62,9 @@ enum vms_lib_kind struct lib_tdata { + /* Standard tdata for an archive. But we don't use many fields. */ + struct artdata artdata; + /* Major version. */ unsigned char ver; @@ -79,10 +82,6 @@ struct lib_tdata struct carsym *modules; bfd **cache; - /* Vector of symbols (archive map), already sorted. */ - unsigned int nbr_syms; - struct carsym *syms; - /* DCX (decompression) data. */ unsigned int nbr_dcxsbm; struct dcxsbm_desc *dcxsbm; @@ -94,62 +93,176 @@ struct lib_tdata static const unsigned char eotdesc[] = { 0x03, 0x00, 0x77, 0x00, 0x77, 0x00 }; +/* Describe the current state of carsym entries while building the archive + table of content. Things are simple with Alpha archives as the number + of entries is known, but with IA64 archives a entry can make a reference + to severals members. Therefore we must be able to extend the table on the + fly, but it should be allocated on the bfd - which doesn't support realloc. + To reduce the overhead, the table is initially allocated in the BFD's + objalloc and extended if necessary on the heap. In the later case, it + is finally copied to the BFD's objalloc so that it will automatically be + freed. */ + +struct carsym_mem +{ + /* The table of content. */ + struct carsym *idx; + + /* Number of entries used in the table. */ + unsigned int nbr; + + /* Maximum number of entries. */ + unsigned int max; + + /* If true, the table was reallocated on the heap. If false, it is still + in the BFD's objalloc. */ + bfd_boolean realloced; +}; + +/* Simply add a name to the index. */ + +static bfd_boolean +vms_add_index (struct carsym_mem *cs, char *name, + unsigned int idx_vbn, unsigned int idx_off) +{ + if (cs->nbr == cs->max) + { + struct carsym *n; + + cs->max = 2 * cs->max + 32; + + if (!cs->realloced) + { + n = bfd_malloc2 (cs->max, sizeof (struct carsym)); + if (n == NULL) + return FALSE; + memcpy (n, cs->idx, cs->nbr * sizeof (struct carsym)); + /* And unfortunately we can't free cs->idx. */ + } + else + { + n = bfd_realloc_or_free (cs->idx, cs->nbr * sizeof (struct carsym)); + if (n == NULL) + return FALSE; + } + cs->idx = n; + cs->realloced = TRUE; + } + cs->idx[cs->nbr].file_offset = (idx_vbn - 1) * VMS_BLOCK_SIZE + idx_off; + cs->idx[cs->nbr].name = name; + cs->nbr++; + return TRUE; +} + +/* Follow all member of a lns list (pointed by RFA) and add indexes for + NAME. Return FALSE in case of error. */ + +static bfd_boolean +vms_add_indexes_from_list (bfd *abfd, struct carsym_mem *cs, char *name, + struct vms_rfa *rfa) +{ + struct vms_lns lns; + unsigned int vbn; + file_ptr off; + + while (1) + { + vbn = bfd_getl32 (rfa->vbn); + if (vbn == 0) + return TRUE; + + /* Read the LHS. */ + off = (vbn - 1) * VMS_BLOCK_SIZE + bfd_getl16 (rfa->offset); + if (bfd_seek (abfd, off, SEEK_SET) != 0 + || bfd_bread (&lns, sizeof (lns), abfd) != sizeof (lns)) + return FALSE; + + if (!vms_add_index (cs, name, + bfd_getl32 (lns.modrfa.vbn), + bfd_getl16 (lns.modrfa.offset))) + return FALSE; + + rfa = &lns.nxtrfa; + } +} + +/* Read block VBN from ABFD and store it into BLK. */ + +static bfd_boolean +vms_read_block (bfd *abfd, unsigned int vbn, void *blk) +{ + file_ptr off; + + /* Read the index block. */ + off = (vbn - 1) * VMS_BLOCK_SIZE; + if (bfd_seek (abfd, off, SEEK_SET) != 0 + || bfd_bread (blk, VMS_BLOCK_SIZE, abfd) != VMS_BLOCK_SIZE) + return FALSE; + + return TRUE; +} + /* Read index block VBN and put the entry in **IDX (which is updated). If the entry is indirect, recurse. */ static bfd_boolean -vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym **idx) +vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym_mem *cs) { struct vms_indexdef indexdef; - unsigned int used; file_ptr off; - unsigned int i; + unsigned char *p; + unsigned char *endp; /* Read the index block. */ - off = (vbn - 1) * VMS_BLOCK_SIZE; - if (bfd_seek (abfd, off, SEEK_SET) != 0 - || bfd_bread (&indexdef, sizeof (indexdef), abfd) != sizeof (indexdef)) + BFD_ASSERT (sizeof (indexdef) == VMS_BLOCK_SIZE); + if (!vms_read_block (abfd, vbn, &indexdef)) return FALSE; /* Traverse it. */ - used = bfd_getl16 (indexdef.used); - for (i = 0; i < used;) + p = &indexdef.keys[0]; + endp = p + bfd_getl16 (indexdef.used); + while (p < endp) { unsigned int idx_vbn; unsigned int idx_off; unsigned int keylen; unsigned char *keyname; - unsigned char *ridx = (unsigned char *)&indexdef.keys[i]; - unsigned int len; - - idx_vbn = bfd_getl32 (ridx); - idx_off = bfd_getl16 (ridx + 4); - - /* Illegal value. */ - if (idx_vbn == 0) - return FALSE; + unsigned int flags; /* Extract key length. */ - if (bfd_libdata (abfd)->ver == 3) + if (bfd_libdata (abfd)->ver == LBR_MAJORID) { - keylen = ridx[6]; - len = 7; + struct vms_idx *ridx = (struct vms_idx *)p; + + idx_vbn = bfd_getl32 (ridx->rfa.vbn); + idx_off = bfd_getl16 (ridx->rfa.offset); + + keylen = ridx->keylen; + flags = 0; + keyname = ridx->keyname; } - else if (bfd_libdata (abfd)->ver == 4) + else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID) { - keylen = bfd_getl16 (ridx + 6); - len = 9; + struct vms_elfidx *ridx = (struct vms_elfidx *)p; + + idx_vbn = bfd_getl32 (ridx->rfa.vbn); + idx_off = bfd_getl16 (ridx->rfa.offset); + + keylen = bfd_getl16 (ridx->keylen); + flags = ridx->flags; + keyname = ridx->keyname; } else return FALSE; - keyname = ridx + len; - i += len + keylen; + /* Illegal value. */ + if (idx_vbn == 0) + return FALSE; if (idx_off == RFADEF__C_INDEX) { /* Indirect entry. Recurse. */ - if (!vms_traverse_index (abfd, idx_vbn, idx)) + if (!vms_traverse_index (abfd, idx_vbn, cs)) return FALSE; } else @@ -157,15 +270,89 @@ vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym **idx) /* Add a new entry. */ char *name; - name = bfd_alloc (abfd, keylen + 1); - if (name == NULL) - return FALSE; - memcpy (name, keyname, keylen); + if (flags & ELFIDX__SYMESC) + { + /* Extended key name. */ + unsigned int noff = 0; + unsigned int koff; + unsigned int kvbn; + struct vms_kbn *kbn; + unsigned char kblk[VMS_BLOCK_SIZE]; + + /* Sanity check. */ + if (keylen != sizeof (struct vms_kbn)) + return FALSE; + + kbn = (struct vms_kbn *)keyname; + keylen = bfd_getl16 (kbn->keylen); + + name = bfd_alloc (abfd, keylen + 1); + if (name == NULL) + return FALSE; + kvbn = bfd_getl32 (kbn->rfa.vbn); + koff = bfd_getl16 (kbn->rfa.offset); + + /* Read the key, chunk by chunk. */ + do + { + unsigned int klen; + + if (!vms_read_block (abfd, kvbn, kblk)) + return FALSE; + kbn = (struct vms_kbn *)(kblk + koff); + klen = bfd_getl16 (kbn->keylen); + kvbn = bfd_getl32 (kbn->rfa.vbn); + koff = bfd_getl16 (kbn->rfa.offset); + + memcpy (name + noff, kbn + 1, klen); + noff += klen; + } + while (kvbn != 0); + + /* Sanity check. */ + if (noff != keylen) + return FALSE; + } + else + { + /* Usual key name. */ + name = bfd_alloc (abfd, keylen + 1); + if (name == NULL) + return FALSE; + + memcpy (name, keyname, keylen); + } name[keylen] = 0; - (*idx)->file_offset = (idx_vbn - 1) * VMS_BLOCK_SIZE + idx_off; - (*idx)->name = name; - (*idx)++; + + if (flags & ELFIDX__LISTRFA) + { + struct vms_lhs lhs; + + /* Read the LHS. */ + off = (idx_vbn - 1) * VMS_BLOCK_SIZE + idx_off; + if (bfd_seek (abfd, off, SEEK_SET) != 0 + || bfd_bread (&lhs, sizeof (lhs), abfd) != sizeof (lhs)) + return FALSE; + + /* FIXME: this adds extra entries that were not accounted. */ + if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.ng_g_rfa)) + return FALSE; + if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.ng_wk_rfa)) + return FALSE; + if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.g_g_rfa)) + return FALSE; + if (!vms_add_indexes_from_list (abfd, cs, name, &lhs.g_wk_rfa)) + return FALSE; + } + else + { hooks/post-receive -- Repository for Project Archer.