diff options
author | Alan Modra <amodra@gmail.com> | 2017-12-06 09:26:00 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-12-06 17:51:43 +1030 |
commit | 07d6d2b8345ef3dc82eab49635acac9ee67dbb18 (patch) | |
tree | 380d1e08ae32b2a37d5f9610f1811bb98299ac09 /bfd/vms-lib.c | |
parent | 65281396861dfcfa993eb5af4769d6837104890d (diff) | |
download | gdb-07d6d2b8345ef3dc82eab49635acac9ee67dbb18.zip gdb-07d6d2b8345ef3dc82eab49635acac9ee67dbb18.tar.gz gdb-07d6d2b8345ef3dc82eab49635acac9ee67dbb18.tar.bz2 |
BFD whitespace fixes
Binutils is supposed to use tabs. In my git config I have
whitespace = indent-with-non-tab,space-before-tab,trailing-space
and I got annoyed enough seeing red in "git diff" output to fix
the problems.
* doc/header.sed: Trim trailing space when splitting lines.
* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-cris.c,
* aout-ns32k.c, * aout-target.h, * aout-tic30.c, * aoutf1.h, * aoutx.h,
* arc-got.h, * arc-plt.def, * arc-plt.h, * archive.c, * archive64.c,
* archures.c, * armnetbsd.c, * bfd-in.h, * bfd.c, * bfdio.c, * binary.c,
* bout.c, * cache.c, * cisco-core.c, * coff-alpha.c, * coff-apollo.c,
* coff-arm.c, * coff-h8300.c, * coff-i386.c, * coff-i860.c,
* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mcore.c,
* coff-mips.c, * coff-ppc.c, * coff-rs6000.c, * coff-sh.c,
* coff-stgo32.c, * coff-tic4x.c, * coff-tic54x.c, * coff-tic80.c,
* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
* coffswap.h, * compress.c, * corefile.c, * cpu-alpha.c, * cpu-arm.c,
* cpu-avr.c, * cpu-bfin.c, * cpu-cr16.c, * cpu-cr16c.c, * cpu-crx.c,
* cpu-d10v.c, * cpu-frv.c, * cpu-ft32.c, * cpu-i370.c, * cpu-i960.c,
* cpu-ia64-opc.c, * cpu-ip2k.c, * cpu-lm32.c, * cpu-m32r.c,
* cpu-mcore.c, * cpu-microblaze.c, * cpu-mips.c, * cpu-moxie.c,
* cpu-mt.c, * cpu-nios2.c, * cpu-ns32k.c, * cpu-or1k.c, * cpu-powerpc.c,
* cpu-pru.c, * cpu-sh.c, * cpu-spu.c, * cpu-v850.c, * cpu-v850_rh850.c,
* cpu-xgate.c, * cpu-z80.c, * dwarf1.c, * dwarf2.c, * ecoff.c,
* ecofflink.c, * ecoffswap.h, * elf-bfd.h, * elf-eh-frame.c,
* elf-hppa.h, * elf-m10200.c, * elf-m10300.c, * elf-s390-common.c,
* elf-strtab.c, * elf-vxworks.c, * elf.c, * elf32-am33lin.c,
* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-avr.h,
* elf32-bfin.c, * elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c,
* elf32-crx.c, * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c,
* elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c,
* elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c, * elf32-i860.c,
* elf32-i960.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32c.c,
* elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68hc1x.c,
* elf32-m68hc1x.h, * elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c,
* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c,
* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
* elf32-nds32.h, * elf32-nios2.c, * elf32-or1k.c, * elf32-pj.c,
* elf32-ppc.c, * elf32-ppc.h, * elf32-pru.c, * elf32-rl78.c,
* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-score.h,
* elf32-score7.c, * elf32-sh-symbian.c, * elf32-sh.c, * elf32-sh64.c,
* elf32-sparc.c, * elf32-spu.c, * elf32-tic6x.c, * elf32-tilegx.c,
* elf32-tilegx.h, * elf32-tilepro.c, * elf32-tilepro.h, * elf32-v850.c,
* elf32-vax.c, * elf32-wasm32.c, * elf32-xc16x.c, * elf32-xgate.c,
* elf32-xgate.h, * elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c,
* elf64-ppc.c, * elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c,
* elf64-tilegx.c, * elf64-tilegx.h, * elf64-x86-64.c, * elfcore.h,
* elflink.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
* elfnn-riscv.c, * elfxx-aarch64.c, * elfxx-aarch64.h, * elfxx-ia64.c,
* elfxx-ia64.h, * elfxx-mips.c, * elfxx-riscv.c, * elfxx-sparc.c,
* elfxx-tilegx.c, * elfxx-x86.c, * elfxx-x86.h, * freebsd.h, * hash.c,
* host-aout.c, * hp300hpux.c, * hppabsd-core.c, * hpux-core.c,
* i386aout.c, * i386linux.c, * i386lynx.c, * i386mach3.c, * i386msdos.c,
* i386netbsd.c, * ieee.c, * ihex.c, * irix-core.c, * libaout.h,
* libbfd-in.h, * libbfd.c, * libcoff-in.h, * libnlm.h, * libpei.h,
* libxcoff.h, * linker.c, * lynx-core.c, * m68k4knetbsd.c,
* m68klinux.c, * m68knetbsd.c, * m88kmach3.c, * mach-o-aarch64.c,
* mach-o-arm.c, * mach-o-i386.c, * mach-o-target.c, * mach-o-x86-64.c,
* mach-o.c, * mach-o.h, * merge.c, * mipsbsd.c, * mmo.c, * netbsd.h,
* netbsd-core.c, * newsos3.c, * nlm-target.h, * nlm32-ppc.c,
* nlm32-sparc.c, * nlmcode.h, * ns32k.h, * ns32knetbsd.c, * oasys.c,
* opncls.c, * pc532-mach.c, * pdp11.c, * pe-arm.c, * pe-i386.c,
* pe-mcore.c, * pe-mips.c, * pe-x86_64.c, * peXXigen.c, * pef.c,
* pef.h, * pei-arm.c, * pei-i386.c, * pei-mcore.c, * pei-x86_64.c,
* peicode.h, * plugin.c, * ppcboot.c, * ptrace-core.c, * reloc.c,
* riscix.c, * rs6000-core.c, * section.c, * som.c, * som.h,
* sparclinux.c, * sparcnetbsd.c, * srec.c, * stabs.c, * sunos.c,
* syms.c, * targets.c, * tekhex.c, * trad-core.c, * vax1knetbsd.c,
* vaxnetbsd.c, * verilog.c, * versados.c, * vms-alpha.c, * vms-lib.c,
* vms-misc.c, * wasm-module.c, * wasm-module.h, * xcofflink.c,
* xsym.c, * xsym.h: Whitespace fixes.
* bfd-in2.h, * libbfd.h, * libcoff.h: Regenerate.
Diffstat (limited to 'bfd/vms-lib.c')
-rw-r--r-- | bfd/vms-lib.c | 1600 |
1 files changed, 800 insertions, 800 deletions
diff --git a/bfd/vms-lib.c b/bfd/vms-lib.c index 27f07e1..1b2e22e 100644 --- a/bfd/vms-lib.c +++ b/bfd/vms-lib.c @@ -129,7 +129,7 @@ struct carsym_mem static bfd_boolean vms_add_index (struct carsym_mem *cs, char *name, - unsigned int idx_vbn, unsigned int idx_off) + unsigned int idx_vbn, unsigned int idx_off) { if (cs->nbr == cs->max) { @@ -138,19 +138,19 @@ vms_add_index (struct carsym_mem *cs, char *name, 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. */ - } + { + 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; - } + { + n = bfd_realloc_or_free (cs->idx, cs->nbr * sizeof (struct carsym)); + if (n == NULL) + return FALSE; + } cs->idx = n; cs->realloced = TRUE; } @@ -165,7 +165,7 @@ vms_add_index (struct carsym_mem *cs, char *name, static bfd_boolean vms_add_indexes_from_list (bfd *abfd, struct carsym_mem *cs, char *name, - struct vms_rfa *rfa) + struct vms_rfa *rfa) { struct vms_lns lns; unsigned int vbn; @@ -175,18 +175,18 @@ vms_add_indexes_from_list (bfd *abfd, struct carsym_mem *cs, char *name, { vbn = bfd_getl32 (rfa->vbn); if (vbn == 0) - return TRUE; + 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; + || 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; + bfd_getl32 (lns.modrfa.vbn), + bfd_getl16 (lns.modrfa.offset))) + return FALSE; rfa = &lns.nxtrfa; } @@ -251,128 +251,128 @@ vms_traverse_index (bfd *abfd, unsigned int vbn, struct carsym_mem *cs) /* Extract key length. */ if (bfd_libdata (abfd)->ver == LBR_MAJORID) - { - struct vms_idx *ridx = (struct vms_idx *)p; + { + struct vms_idx *ridx = (struct vms_idx *)p; - idx_vbn = bfd_getl32 (ridx->rfa.vbn); - idx_off = bfd_getl16 (ridx->rfa.offset); + idx_vbn = bfd_getl32 (ridx->rfa.vbn); + idx_off = bfd_getl16 (ridx->rfa.offset); - keylen = ridx->keylen; - flags = 0; - keyname = ridx->keyname; - } + keylen = ridx->keylen; + flags = 0; + keyname = ridx->keyname; + } else if (bfd_libdata (abfd)->ver == LBR_ELFMAJORID) - { - struct vms_elfidx *ridx = (struct vms_elfidx *)p; + { + struct vms_elfidx *ridx = (struct vms_elfidx *)p; - idx_vbn = bfd_getl32 (ridx->rfa.vbn); - idx_off = bfd_getl16 (ridx->rfa.offset); + 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; - } + keylen = bfd_getl16 (ridx->keylen); + flags = ridx->flags; + keyname = ridx->keyname; + } else - return FALSE; + return FALSE; /* Illegal value. */ if (idx_vbn == 0) - return FALSE; + return FALSE; /* Point to the next index entry. */ p = keyname + keylen; if (idx_off == RFADEF__C_INDEX) - { - /* Indirect entry. Recurse. */ - if (!vms_traverse_index (abfd, idx_vbn, cs)) - return FALSE; - } + { + /* Indirect entry. Recurse. */ + if (!vms_traverse_index (abfd, idx_vbn, cs)) + return FALSE; + } else - { - /* Add a new entry. */ - char *name; - - 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; - - 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 - { - if (!vms_add_index (cs, name, idx_vbn, idx_off)) - return FALSE; - } - } + { + /* Add a new entry. */ + char *name; + + 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; + + 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 + { + if (!vms_add_index (cs, name, idx_vbn, idx_off)) + return FALSE; + } + } } return TRUE; @@ -414,10 +414,10 @@ vms_lib_read_index (bfd *abfd, int idx, unsigned int *nbrel) if (vbn != 0 && !vms_traverse_index (abfd, vbn, &csm)) { if (csm.realloced && csm.idx != NULL) - free (csm.idx); + free (csm.idx); /* Note: in case of error, we can free what was allocated on the - BFD's objalloc. */ + BFD's objalloc. */ bfd_release (abfd, csbuf); return NULL; } @@ -425,10 +425,10 @@ vms_lib_read_index (bfd *abfd, int idx, unsigned int *nbrel) if (csm.realloced) { /* There are more entries than the first estimate. Allocate on - the BFD's objalloc. */ + the BFD's objalloc. */ csbuf = bfd_alloc (abfd, csm.nbr * sizeof (struct carsym)); if (csbuf == NULL) - return NULL; + return NULL; memcpy (csbuf, csm.idx, csm.nbr * sizeof (struct carsym)); free (csm.idx); *nbrel = csm.nbr; @@ -460,8 +460,8 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind) /* Check sanity (= magic) number. */ sanity = bfd_getl32 (lhd.sanity); if (!(sanity == LHD_SANEID3 - || sanity == LHD_SANEID6 - || sanity == LHD_SANEID_DCX)) + || sanity == LHD_SANEID6 + || sanity == LHD_SANEID_DCX)) { bfd_set_error (bfd_error_wrong_format); return NULL; @@ -473,32 +473,32 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind) { case vms_lib_alpha: if ((lhd.type != LBR__C_TYP_EOBJ && lhd.type != LBR__C_TYP_ESHSTB) - || majorid != LBR_MAJORID - || lhd.nindex != 2) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } + || majorid != LBR_MAJORID + || lhd.nindex != 2) + { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } break; case vms_lib_ia64: if ((lhd.type != LBR__C_TYP_IOBJ && lhd.type != LBR__C_TYP_ISHSTB) - || majorid != LBR_ELFMAJORID - || lhd.nindex != 2) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } + || majorid != LBR_ELFMAJORID + || lhd.nindex != 2) + { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } break; case vms_lib_txt: if ((lhd.type != LBR__C_TYP_TXT - && lhd.type != LBR__C_TYP_MLB - && lhd.type != LBR__C_TYP_HLP) - || majorid != LBR_MAJORID - || lhd.nindex != 1) - { - bfd_set_error (bfd_error_wrong_format); - return NULL; - } + && lhd.type != LBR__C_TYP_MLB + && lhd.type != LBR__C_TYP_HLP) + || majorid != LBR_MAJORID + || lhd.nindex != 1) + { + bfd_set_error (bfd_error_wrong_format); + return NULL; + } break; default: abort (); @@ -529,12 +529,12 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind) nbr_ent = tdata->artdata.symdef_count; tdata->artdata.symdefs = vms_lib_read_index (abfd, 1, &nbr_ent); if (tdata->artdata.symdefs == NULL) - goto err; + goto err; /* Only IA64 archives may have more entries in the index that what - was declared. */ + was declared. */ if (nbr_ent != tdata->artdata.symdef_count - && kind != vms_lib_ia64) - goto err; + && kind != vms_lib_ia64) + goto err; tdata->artdata.symdef_count = nbr_ent; } tdata->cache = bfd_zalloc (abfd, sizeof (bfd *) * tdata->nbr_modules); @@ -553,68 +553,68 @@ _bfd_vms_lib_archive_p (bfd *abfd, enum vms_lib_kind kind) unsigned int i; if (bfd_seek (abfd, (dcxvbn - 1) * VMS_BLOCK_SIZE, SEEK_SET) != 0 - || bfd_bread (buf_reclen, sizeof (buf_reclen), abfd) - != sizeof (buf_reclen)) - goto err; + || bfd_bread (buf_reclen, sizeof (buf_reclen), abfd) + != sizeof (buf_reclen)) + goto err; reclen = bfd_getl32 (buf_reclen); buf = bfd_malloc (reclen); if (buf == NULL) - goto err; + goto err; if (bfd_bread (buf, reclen, abfd) != reclen) - { - free (buf); - goto err; - } + { + free (buf); + goto err; + } map = (struct vms_dcxmap *)buf; tdata->nbr_dcxsbm = bfd_getl16 (map->nsubs); sbm_off = bfd_getl16 (map->sub0); tdata->dcxsbm = (struct dcxsbm_desc *)bfd_alloc - (abfd, tdata->nbr_dcxsbm * sizeof (struct dcxsbm_desc)); + (abfd, tdata->nbr_dcxsbm * sizeof (struct dcxsbm_desc)); for (i = 0; i < tdata->nbr_dcxsbm; i++) - { - struct vms_dcxsbm *sbm = (struct vms_dcxsbm *) (buf + sbm_off); - struct dcxsbm_desc *sbmdesc = &tdata->dcxsbm[i]; - unsigned int sbm_len; - unsigned int sbm_sz; - unsigned int off; - unsigned char *data = (unsigned char *)sbm; - unsigned char *buf1; - unsigned int l, j; - - sbm_sz = bfd_getl16 (sbm->size); - sbm_off += sbm_sz; - BFD_ASSERT (sbm_off <= reclen); - - sbmdesc->min_char = sbm->min_char; - BFD_ASSERT (sbmdesc->min_char == 0); - sbmdesc->max_char = sbm->max_char; - sbm_len = sbmdesc->max_char - sbmdesc->min_char + 1; - l = (2 * sbm_len + 7) / 8; - BFD_ASSERT - (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len - || (tdata->nbr_dcxsbm == 1 - && sbm_sz >= sizeof (struct vms_dcxsbm) + l + sbm_len)); - sbmdesc->flags = (unsigned char *)bfd_alloc (abfd, l); - memcpy (sbmdesc->flags, data + bfd_getl16 (sbm->flags), l); - sbmdesc->nodes = (unsigned char *)bfd_alloc (abfd, 2 * sbm_len); - memcpy (sbmdesc->nodes, data + bfd_getl16 (sbm->nodes), 2 * sbm_len); - off = bfd_getl16 (sbm->next); - if (off != 0) - { - /* Read the 'next' array. */ - sbmdesc->next = (unsigned short *)bfd_alloc - (abfd, sbm_len * sizeof (unsigned short)); - buf1 = data + off; - for (j = 0; j < sbm_len; j++) - sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2); - } - else - { - /* There is no next array if there is only one submap. */ - BFD_ASSERT (tdata->nbr_dcxsbm == 1); - sbmdesc->next = NULL; - } - } + { + struct vms_dcxsbm *sbm = (struct vms_dcxsbm *) (buf + sbm_off); + struct dcxsbm_desc *sbmdesc = &tdata->dcxsbm[i]; + unsigned int sbm_len; + unsigned int sbm_sz; + unsigned int off; + unsigned char *data = (unsigned char *)sbm; + unsigned char *buf1; + unsigned int l, j; + + sbm_sz = bfd_getl16 (sbm->size); + sbm_off += sbm_sz; + BFD_ASSERT (sbm_off <= reclen); + + sbmdesc->min_char = sbm->min_char; + BFD_ASSERT (sbmdesc->min_char == 0); + sbmdesc->max_char = sbm->max_char; + sbm_len = sbmdesc->max_char - sbmdesc->min_char + 1; + l = (2 * sbm_len + 7) / 8; + BFD_ASSERT + (sbm_sz >= sizeof (struct vms_dcxsbm) + l + 3 * sbm_len + || (tdata->nbr_dcxsbm == 1 + && sbm_sz >= sizeof (struct vms_dcxsbm) + l + sbm_len)); + sbmdesc->flags = (unsigned char *)bfd_alloc (abfd, l); + memcpy (sbmdesc->flags, data + bfd_getl16 (sbm->flags), l); + sbmdesc->nodes = (unsigned char *)bfd_alloc (abfd, 2 * sbm_len); + memcpy (sbmdesc->nodes, data + bfd_getl16 (sbm->nodes), 2 * sbm_len); + off = bfd_getl16 (sbm->next); + if (off != 0) + { + /* Read the 'next' array. */ + sbmdesc->next = (unsigned short *)bfd_alloc + (abfd, sbm_len * sizeof (unsigned short)); + buf1 = data + off; + for (j = 0; j < sbm_len; j++) + sbmdesc->next[j] = bfd_getl16 (buf1 + j * 2); + } + else + { + /* There is no next array if there is only one submap. */ + BFD_ASSERT (tdata->nbr_dcxsbm == 1); + sbmdesc->next = NULL; + } + } free (buf); } else @@ -731,13 +731,13 @@ _bfd_vms_lib_find_symbol (bfd *abfd, const char *name) diff = (char)(name[0] - syms[mid].name[0]); if (diff == 0) - diff = strcmp (name, syms[mid].name); + diff = strcmp (name, syms[mid].name); if (diff == 0) - return mid; + return mid; else if (diff < 0) - hi = mid - 1; + hi = mid - 1; else - lo = mid + 1; + lo = mid + 1; } return BFD_NO_MORE_SYMBOLS; } @@ -821,9 +821,9 @@ vms_lib_read_block (struct bfd *abfd) /* Read next block. */ if (bfd_seek (abfd->my_archive, vec->next_block, SEEK_SET) != 0) - return FALSE; + return FALSE; if (bfd_bread (hdr, sizeof (hdr), abfd->my_archive) != sizeof (hdr)) - return FALSE; + return FALSE; vec->next_block = (bfd_getl32 (hdr + 2) - 1) * VMS_BLOCK_SIZE; vec->blk_off = sizeof (hdr); } @@ -847,29 +847,29 @@ vms_lib_bread_raw (struct bfd *abfd, unsigned char *buf, file_ptr nbytes) /* Be sure the current data block is read. */ if (!vms_lib_read_block (abfd)) - return -1; + return -1; /* Do not read past the data block, do not read more than requested. */ l = DATA__LENGTH - vec->blk_off; if (l > nbytes) - l = nbytes; + l = nbytes; if (l == 0) - return 0; + return 0; if (buf != NULL) - { - /* Really read into BUF. */ - if (bfd_bread (buf, l, abfd->my_archive) != l) - return -1; - } + { + /* Really read into BUF. */ + if (bfd_bread (buf, l, abfd->my_archive) != l) + return -1; + } else - { - /* Make as if we are reading. */ - if (bfd_seek (abfd->my_archive, l, SEEK_CUR) != 0) - return -1; - } + { + /* Make as if we are reading. */ + if (bfd_seek (abfd->my_archive, l, SEEK_CUR) != 0) + return -1; + } if (buf != NULL) - buf += l; + buf += l; vec->blk_off += l; nbytes -= l; res += l; @@ -902,49 +902,49 @@ vms_lib_dcx (struct vms_lib_iovec *vec, unsigned char *buf, file_ptr nbytes) unsigned char b = vec->dcx_buf[i]; for (; j < 8; j++) - { - if (b & (1 << j)) - offset++; - if (!(sbm->flags[offset >> 3] & (1 << (offset & 7)))) - { - unsigned int n_offset = sbm->nodes[offset]; - if (n_offset == 0) - { - /* End of buffer. Stay where we are. */ - vec->dcx_pos = (i << 3) + j; - if (b & (1 << j)) - offset--; - vec->dcx_offset = offset; - vec->dcx_sbm = sbm; - return res; - } - offset = 2 * n_offset; - } - else - { - unsigned char v = sbm->nodes[offset]; - - if (sbm->next != NULL) - sbm = vec->dcxsbms + sbm->next[v]; - offset = 0; - res++; - - if (buf) - { - *buf++ = v; - nbytes--; - - if (nbytes == 0) - { - vec->dcx_pos = (i << 3) + j + 1; - vec->dcx_offset = offset; - vec->dcx_sbm = sbm; - - return res; - } - } - } - } + { + if (b & (1 << j)) + offset++; + if (!(sbm->flags[offset >> 3] & (1 << (offset & 7)))) + { + unsigned int n_offset = sbm->nodes[offset]; + if (n_offset == 0) + { + /* End of buffer. Stay where we are. */ + vec->dcx_pos = (i << 3) + j; + if (b & (1 << j)) + offset--; + vec->dcx_offset = offset; + vec->dcx_sbm = sbm; + return res; + } + offset = 2 * n_offset; + } + else + { + unsigned char v = sbm->nodes[offset]; + + if (sbm->next != NULL) + sbm = vec->dcxsbms + sbm->next[v]; + offset = 0; + res++; + + if (buf) + { + *buf++ = v; + nbytes--; + + if (nbytes == 0) + { + vec->dcx_pos = (i << 3) + j + 1; + vec->dcx_offset = offset; + vec->dcx_sbm = sbm; + + return res; + } + } + } + } j = 0; } return -1; @@ -968,177 +968,177 @@ vms_lib_bread (struct bfd *abfd, void *vbuf, file_ptr nbytes) while (nbytes > 0) { if (vec->rec_rem == 0) - { - unsigned char blen[2]; - - /* Read record length. */ - if (vms_lib_bread_raw (abfd, blen, sizeof (blen)) != sizeof (blen)) - return -1; - vec->rec_len = bfd_getl16 (blen); - if (bfd_libdata (abfd->my_archive)->kind == vms_lib_txt) - { - /* Discard record size and align byte. */ - vec->rec_pos = 0; - vec->rec_rem = vec->rec_len; - } - else - { - /* Prepend record size. */ - vec->rec_pos = REC_POS_LEN0; - vec->rec_rem = (vec->rec_len + 1) & ~1; /* With align byte. */ - } - if (vec->rec_len == 3) - { - /* Possibly end of file. Check the pattern. */ - if (vms_lib_bread_raw (abfd, vec->pattern, 4) != 4) - return -1; - if (!memcmp (vec->pattern, eotdesc + 2, 3)) - { - /* This is really an EOF. */ - vec->where += res; - vec->file_len = vec->where; - return res; - } - } - - if (vec->dcxsbms != NULL) - { - /* This is a compressed member. */ - unsigned int len; - file_ptr elen; - - /* Be sure there is enough room for the expansion. */ - len = (vec->rec_len + 1) & ~1; - if (len > vec->dcx_max) - { - while (len > vec->dcx_max) - vec->dcx_max *= 2; - vec->dcx_buf = bfd_alloc (abfd, vec->dcx_max); - if (vec->dcx_buf == NULL) - return -1; - } - - /* Read the compressed record. */ - vec->dcx_rlen = len; - if (vec->rec_len == 3) - { - /* Already read. */ - memcpy (vec->dcx_buf, vec->pattern, 3); - } - else - { - elen = vms_lib_bread_raw (abfd, vec->dcx_buf, len); - if (elen != len) - return -1; - } - - /* Dummy expansion to get the expanded length. */ - vec->dcx_offset = 0; - vec->dcx_sbm = vec->dcxsbms; - vec->dcx_pos = 0; - elen = vms_lib_dcx (vec, NULL, 0x10000); - if (elen < 0) - return -1; - vec->rec_len = elen; - vec->rec_rem = elen; - - /* Reset the state. */ - vec->dcx_offset = 0; - vec->dcx_sbm = vec->dcxsbms; - vec->dcx_pos = 0; - } - } + { + unsigned char blen[2]; + + /* Read record length. */ + if (vms_lib_bread_raw (abfd, blen, sizeof (blen)) != sizeof (blen)) + return -1; + vec->rec_len = bfd_getl16 (blen); + if (bfd_libdata (abfd->my_archive)->kind == vms_lib_txt) + { + /* Discard record size and align byte. */ + vec->rec_pos = 0; + vec->rec_rem = vec->rec_len; + } + else + { + /* Prepend record size. */ + vec->rec_pos = REC_POS_LEN0; + vec->rec_rem = (vec->rec_len + 1) & ~1; /* With align byte. */ + } + if (vec->rec_len == 3) + { + /* Possibly end of file. Check the pattern. */ + if (vms_lib_bread_raw (abfd, vec->pattern, 4) != 4) + return -1; + if (!memcmp (vec->pattern, eotdesc + 2, 3)) + { + /* This is really an EOF. */ + vec->where += res; + vec->file_len = vec->where; + return res; + } + } + + if (vec->dcxsbms != NULL) + { + /* This is a compressed member. */ + unsigned int len; + file_ptr elen; + + /* Be sure there is enough room for the expansion. */ + len = (vec->rec_len + 1) & ~1; + if (len > vec->dcx_max) + { + while (len > vec->dcx_max) + vec->dcx_max *= 2; + vec->dcx_buf = bfd_alloc (abfd, vec->dcx_max); + if (vec->dcx_buf == NULL) + return -1; + } + + /* Read the compressed record. */ + vec->dcx_rlen = len; + if (vec->rec_len == 3) + { + /* Already read. */ + memcpy (vec->dcx_buf, vec->pattern, 3); + } + else + { + elen = vms_lib_bread_raw (abfd, vec->dcx_buf, len); + if (elen != len) + return -1; + } + + /* Dummy expansion to get the expanded length. */ + vec->dcx_offset = 0; + vec->dcx_sbm = vec->dcxsbms; + vec->dcx_pos = 0; + elen = vms_lib_dcx (vec, NULL, 0x10000); + if (elen < 0) + return -1; + vec->rec_len = elen; + vec->rec_rem = elen; + + /* Reset the state. */ + vec->dcx_offset = 0; + vec->dcx_sbm = vec->dcxsbms; + vec->dcx_pos = 0; + } + } if (vec->rec_pos < 0) - { - unsigned char c; - switch (vec->rec_pos) - { - case REC_POS_LEN0: - c = vec->rec_len & 0xff; - vec->rec_pos = REC_POS_LEN1; - break; - case REC_POS_LEN1: - c = (vec->rec_len >> 8) & 0xff; - vec->rec_pos = 0; - break; - case REC_POS_PAD: - c = 0; - vec->rec_rem = 0; - break; - case REC_POS_NL: - c = '\n'; - vec->rec_rem = 0; - break; - default: - abort (); - } - if (buf != NULL) - { - *buf = c; - buf++; - } - nbytes--; - res++; - continue; - } + { + unsigned char c; + switch (vec->rec_pos) + { + case REC_POS_LEN0: + c = vec->rec_len & 0xff; + vec->rec_pos = REC_POS_LEN1; + break; + case REC_POS_LEN1: + c = (vec->rec_len >> 8) & 0xff; + vec->rec_pos = 0; + break; + case REC_POS_PAD: + c = 0; + vec->rec_rem = 0; + break; + case REC_POS_NL: + c = '\n'; + vec->rec_rem = 0; + break; + default: + abort (); + } + if (buf != NULL) + { + *buf = c; + buf++; + } + nbytes--; + res++; + continue; + } if (nbytes > vec->rec_rem) - chunk = vec->rec_rem; + chunk = vec->rec_rem; else - chunk = nbytes; + chunk = nbytes; if (vec->dcxsbms != NULL) - { - /* Optimize the stat() case: no need to decompress again as we - know the length. */ - if (!(buf == NULL && chunk == vec->rec_rem)) - chunk = vms_lib_dcx (vec, buf, chunk); - } + { + /* Optimize the stat() case: no need to decompress again as we + know the length. */ + if (!(buf == NULL && chunk == vec->rec_rem)) + chunk = vms_lib_dcx (vec, buf, chunk); + } else - { - if (vec->rec_len == 3) - { - if (buf != NULL) - memcpy (buf, vec->pattern + vec->rec_pos, chunk); - } - else - chunk = vms_lib_bread_raw (abfd, buf, chunk); - } + { + if (vec->rec_len == 3) + { + if (buf != NULL) + memcpy (buf, vec->pattern + vec->rec_pos, chunk); + } + else + chunk = vms_lib_bread_raw (abfd, buf, chunk); + } if (chunk < 0) - return -1; + return -1; res += chunk; if (buf != NULL) - buf += chunk; + buf += chunk; nbytes -= chunk; vec->rec_pos += chunk; vec->rec_rem -= chunk; if (vec->rec_rem == 0) - { - /* End of record reached. */ - if (bfd_libdata (abfd->my_archive)->kind == vms_lib_txt) - { - if ((vec->rec_len & 1) == 1 - && vec->rec_len != 3 - && vec->dcxsbms == NULL) - { - /* Eat the pad byte. */ - unsigned char pad; - if (vms_lib_bread_raw (abfd, &pad, 1) != 1) - return -1; - } - vec->rec_pos = REC_POS_NL; - vec->rec_rem = 1; - } - else - { - if ((vec->rec_len & 1) == 1 && vec->dcxsbms != NULL) - { - vec->rec_pos = REC_POS_PAD; - vec->rec_rem = 1; - } - } - } + { + /* End of record reached. */ + if (bfd_libdata (abfd->my_archive)->kind == vms_lib_txt) + { + if ((vec->rec_len & 1) == 1 + && vec->rec_len != 3 + && vec->dcxsbms == NULL) + { + /* Eat the pad byte. */ + unsigned char pad; + if (vms_lib_bread_raw (abfd, &pad, 1) != 1) + return -1; + } + vec->rec_pos = REC_POS_NL; + vec->rec_rem = 1; + } + else + { + if ((vec->rec_len & 1) == 1 && vec->dcxsbms != NULL) + { + vec->rec_pos = REC_POS_PAD; + vec->rec_rem = 1; + } + } + } } vec->where += res; return res; @@ -1160,7 +1160,7 @@ vms_lib_bseek (struct bfd *abfd, file_ptr offset, int whence) vec->next_block = vec->init_next_block; if (bfd_seek (abfd->my_archive, vec->first_block, SEEK_SET) != 0) - return -1; + return -1; } else abort (); @@ -1190,7 +1190,7 @@ vms_lib_bflush (struct bfd *abfd ATTRIBUTE_UNUSED) static int vms_lib_bstat (struct bfd *abfd ATTRIBUTE_UNUSED, - struct stat *sb ATTRIBUTE_UNUSED) + struct stat *sb ATTRIBUTE_UNUSED) { /* Not supported. */ return 0; @@ -1198,13 +1198,13 @@ vms_lib_bstat (struct bfd *abfd ATTRIBUTE_UNUSED, static void * vms_lib_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED, - void *addr ATTRIBUTE_UNUSED, - bfd_size_type len ATTRIBUTE_UNUSED, - int prot ATTRIBUTE_UNUSED, - int flags ATTRIBUTE_UNUSED, - file_ptr offset ATTRIBUTE_UNUSED, - void **map_addr ATTRIBUTE_UNUSED, - bfd_size_type *map_len ATTRIBUTE_UNUSED) + void *addr ATTRIBUTE_UNUSED, + bfd_size_type len ATTRIBUTE_UNUSED, + int prot ATTRIBUTE_UNUSED, + int flags ATTRIBUTE_UNUSED, + file_ptr offset ATTRIBUTE_UNUSED, + void **map_addr ATTRIBUTE_UNUSED, + bfd_size_type *map_len ATTRIBUTE_UNUSED) { return (void *) -1; } @@ -1284,7 +1284,7 @@ vms_lib_bopen (bfd *el, file_ptr filepos) vec->dcx_buf = bfd_alloc (el, vec->dcx_max); vec->dcx_pos = -1; if (vec->dcx_buf == NULL) - return -1; + return -1; } return TRUE; } @@ -1313,11 +1313,11 @@ _bfd_vms_lib_get_module (bfd *abfd, unsigned int modidx) { res = _bfd_create_empty_archive_element_shell (abfd); if (res == NULL) - return NULL; + return NULL; /* Special reader to deal with data blocks. */ if (!vms_lib_bopen (res, file_off)) - return NULL; + return NULL; } else { @@ -1327,35 +1327,35 @@ _bfd_vms_lib_get_module (bfd *abfd, unsigned int modidx) /* Sanity check. The MHD must be big enough to contain module size. */ if (tdata->mhd_size < offsetof (struct vms_mhd, modsize) + 4) - return NULL; + return NULL; /* Read the MHD now. */ if (bfd_seek (abfd, file_off, SEEK_SET) != 0) - return NULL; + return NULL; if (bfd_bread (buf, tdata->mhd_size, abfd) != tdata->mhd_size) - return NULL; + return NULL; res = _bfd_create_empty_archive_element_shell (abfd); if (res == NULL) - return NULL; + return NULL; arelt = bfd_zmalloc (sizeof (*arelt)); if (arelt == NULL) - return NULL; + return NULL; res->arelt_data = arelt; /* Get info from mhd. */ mhd = (struct vms_mhd *)buf; if (mhd->id != MHD__C_MHDID) - return NULL; + return NULL; if (tdata->mhd_size >= offsetof (struct vms_mhd, objstat) + 1) - res->selective_search = (mhd->objstat & MHD__M_SELSRC) ? 1 : 0; + res->selective_search = (mhd->objstat & MHD__M_SELSRC) ? 1 : 0; res->mtime = vms_rawtime_to_time_t (mhd->datim); res->mtime_set = TRUE; arelt->parsed_size = bfd_getl32 (mhd->modsize); /* No need for a special reader as members are stored linearly. - Just skip the MHD. */ + Just skip the MHD. */ res->origin = file_off + tdata->mhd_size; } @@ -1402,7 +1402,7 @@ _bfd_vms_lib_get_elt_at_index (bfd *abfd, symindex symidx) for (modidx = 0; modidx < tdata->nbr_modules; modidx++) { if (tdata->modules[modidx].file_offset == file_off) - break; + break; } if (modidx >= tdata->nbr_modules) return NULL; @@ -1456,7 +1456,7 @@ _bfd_vms_lib_get_imagelib_file (bfd *el) bfd * _bfd_vms_lib_openr_next_archived_file (bfd *archive, - bfd *last_file) + bfd *last_file) { unsigned int idx; bfd *res; @@ -1499,14 +1499,14 @@ _bfd_vms_lib_generic_stat_arch_elt (bfd *abfd, struct stat *st) struct vms_lib_iovec *vec = (struct vms_lib_iovec *) abfd->iostream; if (vec->file_len == (ufile_ptr)-1) - { - if (vms_lib_bseek (abfd, 0, SEEK_SET) != 0) - return -1; - - /* Compute length. */ - while (vms_lib_bread (abfd, NULL, 1 << 20) > 0) - ; - } + { + if (vms_lib_bseek (abfd, 0, SEEK_SET) != 0) + return -1; + + /* Compute length. */ + while (vms_lib_bread (abfd, NULL, 1 << 20) > 0) + ; + } st->st_size = vec->file_len; } else @@ -1566,9 +1566,9 @@ get_idxlen (struct lib_index *idx, bfd_boolean is_elfidx) { /* 9 is the size of struct vms_elfidx without keyname. */ if (idx->namlen > MAX_KEYLEN) - return 9 + sizeof (struct vms_kbn); + return 9 + sizeof (struct vms_kbn); else - return 9 + idx->namlen; + return 9 + idx->namlen; } else { @@ -1586,8 +1586,8 @@ get_idxlen (struct lib_index *idx, bfd_boolean is_elfidx) static bfd_boolean vms_write_index (bfd *abfd, - struct lib_index *idx, unsigned int nbr, unsigned int *vbn, - unsigned int *topvbn, bfd_boolean is_elfidx) + struct lib_index *idx, unsigned int nbr, unsigned int *vbn, + unsigned int *topvbn, bfd_boolean is_elfidx) { /* The index is organized as a tree. This function implements a naive algorithm to balance the tree: it fills the leaves, and create a new @@ -1617,7 +1617,7 @@ vms_write_index (bfd *abfd, { /* No entries. Very easy to handle. */ if (topvbn != NULL) - *topvbn = 0; + *topvbn = 0; return TRUE; } @@ -1645,204 +1645,204 @@ vms_write_index (bfd *abfd, idxlen = get_idxlen (idx, is_elfidx); if (is_elfidx && idx->namlen > MAX_KEYLEN) - { - /* If the key (ie name) is too long, write it in the kbn block. */ - unsigned int kl = idx->namlen; - unsigned int kl_chunk; - const char *key = idx->name; - - /* Write the key in the kbn, chunk after chunk. */ - do - { - if (kbn_sz < sizeof (struct vms_kbn)) - { - /* Not enough room in the kbn block. */ - if (abfd != NULL) - { - /* Write it to the disk (if there is one). */ - if (kbn_vbn != 0) - { - if (!vms_write_block (abfd, kbn_vbn, kbn_blk)) - return FALSE; - } - else - { - kbn_blk = bfd_malloc (VMS_BLOCK_SIZE); - if (kbn_blk == NULL) - return FALSE; - } - *(unsigned short *)kbn_blk = 0; - } - /* Allocate a new block for the keys. */ - kbn_vbn = (*vbn)++; - kbn_sz = VMS_BLOCK_SIZE - 2; - } - /* Size of the chunk written to the current key block. */ - if (kl + sizeof (struct vms_kbn) > kbn_sz) - kl_chunk = kbn_sz - sizeof (struct vms_kbn); - else - kl_chunk = kl; - - if (kbn_blk != NULL) - { - struct vms_kbn *kbn; - - kbn = (struct vms_kbn *)(kbn_blk + VMS_BLOCK_SIZE - kbn_sz); - - if (key_vbn == 0) - { - /* Save the rfa of the first chunk. */ - key_vbn = kbn_vbn; - key_off = VMS_BLOCK_SIZE - kbn_sz; - } - - bfd_putl16 (kl_chunk, kbn->keylen); - if (kl_chunk == kl) - { - /* No next chunk. */ - bfd_putl32 (0, kbn->rfa.vbn); - bfd_putl16 (0, kbn->rfa.offset); - } - else - { - /* Next chunk will be at the start of the next block. */ - bfd_putl32 (*vbn, kbn->rfa.vbn); - bfd_putl16 (2, kbn->rfa.offset); - } - memcpy ((char *)(kbn + 1), key, kl_chunk); - key += kl_chunk; - } - kl -= kl_chunk; - kl_chunk = (kl_chunk + 1) & ~1; /* Always align. */ - kbn_sz -= kl_chunk + sizeof (struct vms_kbn); - } - while (kl > 0); - } + { + /* If the key (ie name) is too long, write it in the kbn block. */ + unsigned int kl = idx->namlen; + unsigned int kl_chunk; + const char *key = idx->name; + + /* Write the key in the kbn, chunk after chunk. */ + do + { + if (kbn_sz < sizeof (struct vms_kbn)) + { + /* Not enough room in the kbn block. */ + if (abfd != NULL) + { + /* Write it to the disk (if there is one). */ + if (kbn_vbn != 0) + { + if (!vms_write_block (abfd, kbn_vbn, kbn_blk)) + return FALSE; + } + else + { + kbn_blk = bfd_malloc (VMS_BLOCK_SIZE); + if (kbn_blk == NULL) + return FALSE; + } + *(unsigned short *)kbn_blk = 0; + } + /* Allocate a new block for the keys. */ + kbn_vbn = (*vbn)++; + kbn_sz = VMS_BLOCK_SIZE - 2; + } + /* Size of the chunk written to the current key block. */ + if (kl + sizeof (struct vms_kbn) > kbn_sz) + kl_chunk = kbn_sz - sizeof (struct vms_kbn); + else + kl_chunk = kl; + + if (kbn_blk != NULL) + { + struct vms_kbn *kbn; + + kbn = (struct vms_kbn *)(kbn_blk + VMS_BLOCK_SIZE - kbn_sz); + + if (key_vbn == 0) + { + /* Save the rfa of the first chunk. */ + key_vbn = kbn_vbn; + key_off = VMS_BLOCK_SIZE - kbn_sz; + } + + bfd_putl16 (kl_chunk, kbn->keylen); + if (kl_chunk == kl) + { + /* No next chunk. */ + bfd_putl32 (0, kbn->rfa.vbn); + bfd_putl16 (0, kbn->rfa.offset); + } + else + { + /* Next chunk will be at the start of the next block. */ + bfd_putl32 (*vbn, kbn->rfa.vbn); + bfd_putl16 (2, kbn->rfa.offset); + } + memcpy ((char *)(kbn + 1), key, kl_chunk); + key += kl_chunk; + } + kl -= kl_chunk; + kl_chunk = (kl_chunk + 1) & ~1; /* Always align. */ + kbn_sz -= kl_chunk + sizeof (struct vms_kbn); + } + while (kl > 0); + } /* Check if a block might overflow. In this case we will flush this - block and all the blocks below it. */ + block and all the blocks below it. */ for (j = 0; j < level; j++) - if (blk[j].len + blk[j].lastlen + idxlen > INDEXDEF__BLKSIZ) + if (blk[j].len + blk[j].lastlen + idxlen > INDEXDEF__BLKSIZ) flush = j + 1; for (j = 0; j < level; j++) - { - if (j < flush) - { - /* There is not enough room to write the new entry in this - block or in a parent block. */ - - if (j + 1 == level) - { - BFD_ASSERT (level < MAX_LEVEL); - - /* Need to create a parent. */ - if (abfd != NULL) - { - rblk[level] = bfd_zmalloc (sizeof (struct vms_indexdef)); - bfd_putl32 (*vbn, rblk[j]->parent); - } - blk[level].vbn = (*vbn)++; - blk[level].len = 0; - blk[level].lastlen = blk[j].lastlen; - - level++; - } - - /* Update parent block: write the last entry from the current + { + if (j < flush) + { + /* There is not enough room to write the new entry in this + block or in a parent block. */ + + if (j + 1 == level) + { + BFD_ASSERT (level < MAX_LEVEL); + + /* Need to create a parent. */ + if (abfd != NULL) + { + rblk[level] = bfd_zmalloc (sizeof (struct vms_indexdef)); + bfd_putl32 (*vbn, rblk[j]->parent); + } + blk[level].vbn = (*vbn)++; + blk[level].len = 0; + blk[level].lastlen = blk[j].lastlen; + + level++; + } + + /* Update parent block: write the last entry from the current block. */ - if (abfd != NULL) - { - struct vms_rfa *rfa; + if (abfd != NULL) + { + struct vms_rfa *rfa; /* Pointer to the last entry in parent block. */ rfa = (struct vms_rfa *)(rblk[j + 1]->keys + blk[j + 1].len); - /* Copy the whole entry. */ + /* Copy the whole entry. */ BFD_ASSERT (blk[j + 1].lastlen == blk[j].lastlen); - memcpy (rfa, rblk[j]->keys + blk[j].len, blk[j].lastlen); - /* Fix the entry (which in always the first field of an + memcpy (rfa, rblk[j]->keys + blk[j].len, blk[j].lastlen); + /* Fix the entry (which in always the first field of an entry. */ - bfd_putl32 (blk[j].vbn, rfa->vbn); - bfd_putl16 (RFADEF__C_INDEX, rfa->offset); - } - - if (j + 1 == flush) - { - /* And allocate it. Do it only on the block that won't be - flushed (so that the parent of the parent can be - updated too). */ - blk[j + 1].len += blk[j + 1].lastlen; - blk[j + 1].lastlen = 0; - } - - /* Write this block on the disk. */ - if (abfd != NULL) - { - bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used); - if (!vms_write_block (abfd, blk[j].vbn, rblk[j])) - return FALSE; - } - - /* Reset this block. */ - blk[j].len = 0; - blk[j].lastlen = 0; - blk[j].vbn = (*vbn)++; - } - - /* Append it to the block. */ - if (j == 0) - { + bfd_putl32 (blk[j].vbn, rfa->vbn); + bfd_putl16 (RFADEF__C_INDEX, rfa->offset); + } + + if (j + 1 == flush) + { + /* And allocate it. Do it only on the block that won't be + flushed (so that the parent of the parent can be + updated too). */ + blk[j + 1].len += blk[j + 1].lastlen; + blk[j + 1].lastlen = 0; + } + + /* Write this block on the disk. */ + if (abfd != NULL) + { + bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used); + if (!vms_write_block (abfd, blk[j].vbn, rblk[j])) + return FALSE; + } + + /* Reset this block. */ + blk[j].len = 0; + blk[j].lastlen = 0; + blk[j].vbn = (*vbn)++; + } + + /* Append it to the block. */ + if (j == 0) + { /* Keep the previous last entry. */ - blk[j].len += blk[j].lastlen; - - if (abfd != NULL) - { - struct vms_rfa *rfa; - - rfa = (struct vms_rfa *)(rblk[j]->keys + blk[j].len); - bfd_putl32 ((idx->abfd->proxy_origin / VMS_BLOCK_SIZE) + 1, - rfa->vbn); - bfd_putl16 - ((idx->abfd->proxy_origin % VMS_BLOCK_SIZE) - + (is_elfidx ? 0 : DATA__DATA), - rfa->offset); - - if (is_elfidx) - { - /* Use elfidx format. */ - struct vms_elfidx *en = (struct vms_elfidx *)rfa; - - en->flags = 0; - if (key_vbn != 0) - { - /* Long symbol name. */ - struct vms_kbn *k = (struct vms_kbn *)(en->keyname); - bfd_putl16 (sizeof (struct vms_kbn), en->keylen); - bfd_putl16 (idx->namlen, k->keylen); - bfd_putl32 (key_vbn, k->rfa.vbn); - bfd_putl16 (key_off, k->rfa.offset); - en->flags |= ELFIDX__SYMESC; - } - else - { - bfd_putl16 (idx->namlen, en->keylen); - memcpy (en->keyname, idx->name, idx->namlen); - } - } - else - { - /* Use idx format. */ - struct vms_idx *en = (struct vms_idx *)rfa; - en->keylen = idx->namlen; - memcpy (en->keyname, idx->name, idx->namlen); - } - } + blk[j].len += blk[j].lastlen; + + if (abfd != NULL) + { + struct vms_rfa *rfa; + + rfa = (struct vms_rfa *)(rblk[j]->keys + blk[j].len); + bfd_putl32 ((idx->abfd->proxy_origin / VMS_BLOCK_SIZE) + 1, + rfa->vbn); + bfd_putl16 + ((idx->abfd->proxy_origin % VMS_BLOCK_SIZE) + + (is_elfidx ? 0 : DATA__DATA), + rfa->offset); + + if (is_elfidx) + { + /* Use elfidx format. */ + struct vms_elfidx *en = (struct vms_elfidx *)rfa; + + en->flags = 0; + if (key_vbn != 0) + { + /* Long symbol name. */ + struct vms_kbn *k = (struct vms_kbn *)(en->keyname); + bfd_putl16 (sizeof (struct vms_kbn), en->keylen); + bfd_putl16 (idx->namlen, k->keylen); + bfd_putl32 (key_vbn, k->rfa.vbn); + bfd_putl16 (key_off, k->rfa.offset); + en->flags |= ELFIDX__SYMESC; + } + else + { + bfd_putl16 (idx->namlen, en->keylen); + memcpy (en->keyname, idx->name, idx->namlen); + } + } + else + { + /* Use idx format. */ + struct vms_idx *en = (struct vms_idx *)rfa; + en->keylen = idx->namlen; + memcpy (en->keyname, idx->name, idx->namlen); + } + } } /* The last added key can now be the last one all blocks in the path. */ blk[j].lastlen = idxlen; - } + } } /* Save VBN of the root. */ @@ -1874,7 +1874,7 @@ vms_write_index (bfd *abfd, /* Write this block on the disk. */ bfd_putl16 (blk[j].len + blk[j].lastlen, rblk[j]->used); if (!vms_write_block (abfd, blk[j].vbn, rblk[j])) - return FALSE; + return FALSE; free (rblk[j]); } @@ -1883,7 +1883,7 @@ vms_write_index (bfd *abfd, if (kbn_vbn != 0) { if (!vms_write_block (abfd, kbn_vbn, kbn_blk)) - return FALSE; + return FALSE; free (kbn_blk); } @@ -1894,7 +1894,7 @@ vms_write_index (bfd *abfd, static bfd_boolean vms_write_data_block (bfd *arch, struct vms_datadef *data, file_ptr *off, - const unsigned char *buf, unsigned int len, int pad) + const unsigned char *buf, unsigned int len, int pad) { while (len > 0 || pad) { @@ -1910,19 +1910,19 @@ vms_write_data_block (bfd *arch, struct vms_datadef *data, file_ptr *off, *off += l; if (doff == (DATA__LENGTH - DATA__DATA) || (len == 0 && pad)) - { - data->recs = 0; - data->fill_1 = 0; - bfd_putl32 ((*off / VMS_BLOCK_SIZE) + 2, data->link); + { + data->recs = 0; + data->fill_1 = 0; + bfd_putl32 ((*off / VMS_BLOCK_SIZE) + 2, data->link); - if (bfd_bwrite (data, sizeof (*data), arch) != sizeof (*data)) - return FALSE; + if (bfd_bwrite (data, sizeof (*data), arch) != sizeof (*data)) + return FALSE; - *off += DATA__LENGTH - doff; + *off += DATA__LENGTH - doff; - if (len == 0) - break; - } + if (len == 0) + break; + } } return TRUE; } @@ -1931,9 +1931,9 @@ vms_write_data_block (bfd *arch, struct vms_datadef *data, file_ptr *off, static bfd_boolean _bfd_vms_lib_build_map (unsigned int nbr_modules, - struct lib_index *modules, - unsigned int *res_cnt, - struct lib_index **res) + struct lib_index *modules, + unsigned int *res_cnt, + struct lib_index **res) { unsigned int i; asymbol **syms = NULL; @@ -1955,60 +1955,60 @@ _bfd_vms_lib_build_map (unsigned int nbr_modules, bfd *current = modules[i].abfd; if ((bfd_get_file_flags (current) & HAS_SYMS) == 0) - continue; + continue; storage = bfd_get_symtab_upper_bound (current); if (storage < 0) - goto error_return; + goto error_return; if (storage != 0) - { - if (storage > syms_max) - { - if (syms_max > 0) - free (syms); - syms_max = storage; - syms = (asymbol **) bfd_malloc (syms_max); - if (syms == NULL) - goto error_return; - } - symcount = bfd_canonicalize_symtab (current, syms); - if (symcount < 0) - goto error_return; - - /* Now map over all the symbols, picking out the ones we - want. */ - for (src_count = 0; src_count < symcount; src_count++) - { - flagword flags = (syms[src_count])->flags; - asection *sec = syms[src_count]->section; - - if ((flags & BSF_GLOBAL - || flags & BSF_WEAK - || flags & BSF_INDIRECT - || bfd_is_com_section (sec)) - && ! bfd_is_und_section (sec)) - { - struct lib_index *new_map; - - /* This symbol will go into the archive header. */ - if (map_count == map_max) - { - map_max *= 2; - new_map = (struct lib_index *) - bfd_realloc (map, map_max * sizeof (struct lib_index)); - if (new_map == NULL) - goto error_return; - map = new_map; - } - - map[map_count].abfd = current; - map[map_count].namlen = strlen (syms[src_count]->name); - map[map_count].name = syms[src_count]->name; - map_count++; - modules[i].ref++; - } - } + { + if (storage > syms_max) + { + if (syms_max > 0) + free (syms); + syms_max = storage; + syms = (asymbol **) bfd_malloc (syms_max); + if (syms == NULL) + goto error_return; + } + symcount = bfd_canonicalize_symtab (current, syms); + if (symcount < 0) + goto error_return; + + /* Now map over all the symbols, picking out the ones we + want. */ + for (src_count = 0; src_count < symcount; src_count++) + { + flagword flags = (syms[src_count])->flags; + asection *sec = syms[src_count]->section; + + if ((flags & BSF_GLOBAL + || flags & BSF_WEAK + || flags & BSF_INDIRECT + || bfd_is_com_section (sec)) + && ! bfd_is_und_section (sec)) + { + struct lib_index *new_map; + + /* This symbol will go into the archive header. */ + if (map_count == map_max) + { + map_max *= 2; + new_map = (struct lib_index *) + bfd_realloc (map, map_max * sizeof (struct lib_index)); + if (new_map == NULL) + goto error_return; + map = new_map; + } + + map[map_count].abfd = current; + map[map_count].namlen = strlen (syms[src_count]->name); + map[map_count].name = syms[src_count]->name; + map_count++; + modules[i].ref++; + } + } } } @@ -2118,13 +2118,13 @@ _bfd_vms_lib_write_archive_contents (bfd *arch) current->proxy_origin = off; if (is_elfidx) - sz = 0; + sz = 0; else - { - /* Write the MHD as a record (ie, size first). */ - sz = 2; - bfd_putl16 (tdata->mhd_size, blk); - } + { + /* Write the MHD as a record (ie, size first). */ + sz = 2; + bfd_putl16 (tdata->mhd_size, blk); + } mhd = (struct vms_mhd *)(blk + sz); memset (mhd, 0, sizeof (struct vms_mhd)); mhd->lbrflag = 0; @@ -2139,86 +2139,86 @@ _bfd_vms_lib_write_archive_contents (bfd *arch) /* Rewind the member to be put into the archive. */ if (bfd_seek (current, 0, SEEK_SET) != 0) - goto input_err; + goto input_err; /* Copy the member into the archive. */ if (is_elfidx) - { - unsigned int modsize = 0; - bfd_size_type amt; - file_ptr off_hdr = off; - - /* Read to complete the first block. */ - amt = bfd_bread (blk + sz, VMS_BLOCK_SIZE - sz, current); - if (amt == (bfd_size_type)-1) - goto input_err; - modsize = amt; - if (amt < VMS_BLOCK_SIZE - sz) - { - /* The member size is less than a block. Pad the block. */ - memset (blk + sz + amt, 0, VMS_BLOCK_SIZE - sz - amt); - } - bfd_putl32 (modsize, mhd->modsize); - - /* Write the first block (which contains an mhd). */ - if (bfd_bwrite (blk, VMS_BLOCK_SIZE, arch) != VMS_BLOCK_SIZE) - goto input_err; - off += VMS_BLOCK_SIZE; - - if (amt == VMS_BLOCK_SIZE - sz) - { - /* Copy the remaining. */ - char buffer[DEFAULT_BUFFERSIZE]; - - while (1) - { - amt = bfd_bread (buffer, sizeof (buffer), current); - if (amt == (bfd_size_type)-1) - goto input_err; - if (amt == 0) - break; - modsize += amt; - if (amt != sizeof (buffer)) - { - /* Clear the padding. */ - memset (buffer + amt, 0, sizeof (buffer) - amt); - amt = (amt + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1); - } - if (bfd_bwrite (buffer, amt, arch) != amt) - goto input_err; - off += amt; - } - - /* Now that the size is known, write the first block (again). */ - bfd_putl32 (modsize, mhd->modsize); - if (bfd_seek (arch, off_hdr, SEEK_SET) != 0 - || bfd_bwrite (blk, VMS_BLOCK_SIZE, arch) != VMS_BLOCK_SIZE) - goto input_err; - if (bfd_seek (arch, off, SEEK_SET) != 0) - goto input_err; - } - } + { + unsigned int modsize = 0; + bfd_size_type amt; + file_ptr off_hdr = off; + + /* Read to complete the first block. */ + amt = bfd_bread (blk + sz, VMS_BLOCK_SIZE - sz, current); + if (amt == (bfd_size_type)-1) + goto input_err; + modsize = amt; + if (amt < VMS_BLOCK_SIZE - sz) + { + /* The member size is less than a block. Pad the block. */ + memset (blk + sz + amt, 0, VMS_BLOCK_SIZE - sz - amt); + } + bfd_putl32 (modsize, mhd->modsize); + + /* Write the first block (which contains an mhd). */ + if (bfd_bwrite (blk, VMS_BLOCK_SIZE, arch) != VMS_BLOCK_SIZE) + goto input_err; + off += VMS_BLOCK_SIZE; + + if (amt == VMS_BLOCK_SIZE - sz) + { + /* Copy the remaining. */ + char buffer[DEFAULT_BUFFERSIZE]; + + while (1) + { + amt = bfd_bread (buffer, sizeof (buffer), current); + if (amt == (bfd_size_type)-1) + goto input_err; + if (amt == 0) + break; + modsize += amt; + if (amt != sizeof (buffer)) + { + /* Clear the padding. */ + memset (buffer + amt, 0, sizeof (buffer) - amt); + amt = (amt + VMS_BLOCK_SIZE) & ~(VMS_BLOCK_SIZE - 1); + } + if (bfd_bwrite (buffer, amt, arch) != amt) + goto input_err; + off += amt; + } + + /* Now that the size is known, write the first block (again). */ + bfd_putl32 (modsize, mhd->modsize); + if (bfd_seek (arch, off_hdr, SEEK_SET) != 0 + || bfd_bwrite (blk, VMS_BLOCK_SIZE, arch) != VMS_BLOCK_SIZE) + goto input_err; + if (bfd_seek (arch, off, SEEK_SET) != 0) + goto input_err; + } + } else - { - /* Write the MHD. */ - if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0) - goto input_err; - - /* Write the member. */ - while (1) - { - sz = bfd_bread (blk, sizeof (blk), current); - if (sz == 0) - break; - if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0) - goto input_err; - } - - /* Write the end of module marker. */ - if (vms_write_data_block (arch, &data, &off, - eotdesc, sizeof (eotdesc), 1) < 0) - goto input_err; - } + { + /* Write the MHD. */ + if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0) + goto input_err; + + /* Write the member. */ + while (1) + { + sz = bfd_bread (blk, sizeof (blk), current); + if (sz == 0) + break; + if (vms_write_data_block (arch, &data, &off, blk, sz, 0) < 0) + goto input_err; + } + + /* Write the end of module marker. */ + if (vms_write_data_block (arch, &data, &off, + eotdesc, sizeof (eotdesc), 1) < 0) + goto input_err; + } } /* Write the indexes. */ @@ -2245,22 +2245,22 @@ _bfd_vms_lib_write_archive_contents (bfd *arch) switch (tdata->kind) { case vms_lib_alpha: - saneid = LHD_SANEID3; - break; + saneid = LHD_SANEID3; + break; case vms_lib_ia64: - saneid = LHD_SANEID6; - break; + saneid = LHD_SANEID6; + break; default: - abort (); + abort (); } bfd_putl32 (saneid, lhd->sanity); bfd_putl16 (tdata->ver, lhd->majorid); bfd_putl16 (0, lhd->minorid); snprintf ((char *)lhd->lbrver + 1, sizeof (lhd->lbrver) - 1, - "GNU ar %u.%u.%u", - (unsigned)(BFD_VERSION / 100000000UL), - (unsigned)(BFD_VERSION / 1000000UL) % 100, - (unsigned)(BFD_VERSION / 10000UL) % 100); + "GNU ar %u.%u.%u", + (unsigned)(BFD_VERSION / 100000000UL), + (unsigned)(BFD_VERSION / 1000000UL) % 100, + (unsigned)(BFD_VERSION / 10000UL) % 100); lhd->lbrver[sizeof (lhd->lbrver) - 1] = 0; lhd->lbrver[0] = strlen ((char *)lhd->lbrver + 1); |