This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch/committed]: vms: fix pad byte
- From: Tristan Gingold <gingold at adacore dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Fri, 16 Apr 2010 16:23:57 +0200
- Subject: [patch/committed]: vms: fix pad byte
Hi,
contrary to what I thought, I have found pad bytes that were not 0 (in libraries). So I now always assume
that the pad byte is present for alignment purpose.
This patch also fixes a stupid typo that made some binary files unknown and add a few comments.
Committed on trunk.
Tristan.
bfd/
2010-04-16 Tristan Gingold <gingold@adacore.com>
* vms-alpha.c (_bfd_vms_slurp_eihd): Fix typo.
(_bfd_vms_get_object_record): Always assume there is a pad byte
for alignment.
* vms-lib.c: Add a few comments.
*** vms-alpha.c 14 Apr 2010 09:24:59 -0000 1.1
--- vms-alpha.c 16 Apr 2010 14:19:24 -0000
***************
*** 492,498 ****
size, imgtype, (unsigned long)symvva,
*eisd_offset, *eihs_offset));
! return FALSE;
}
/* Read & process EISD record.
--- 492,498 ----
size, imgtype, (unsigned long)symvva,
*eisd_offset, *eihs_offset));
! return TRUE;
}
/* Read & process EISD record.
***************
*** 753,767 ****
static int
_bfd_vms_get_object_record (bfd *abfd)
{
! unsigned int test_len;
int type;
- int off = 0;
vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
! test_len = 6;
!
! /* Skip odd alignment byte. */
if (bfd_tell (abfd) & 1)
{
if (bfd_bread (PRIV (recrd.buf), 1, abfd) != 1)
--- 753,764 ----
static int
_bfd_vms_get_object_record (bfd *abfd)
{
! unsigned int test_len = 6;
int type;
vms_debug2 ((8, "_bfd_vms_get_obj_record\n"));
! /* Skip alignment byte if the current position is odd. */
if (bfd_tell (abfd) & 1)
{
if (bfd_bread (PRIV (recrd.buf), 1, abfd) != 1)
***************
*** 769,784 ****
bfd_set_error (bfd_error_file_truncated);
return -1;
}
- /* Alignment byte may be present or not. This is not easy to
- detect but all object record types are not 0 (on Alpha VMS).
- We also hope that pad byte is 0. */
- if (PRIV (recrd.buf)[0])
- off = 1;
}
/* Read the record header */
! if (bfd_bread (PRIV (recrd.buf) + off, test_len - off, abfd)
! != test_len - off)
{
bfd_set_error (bfd_error_file_truncated);
return -1;
--- 766,775 ----
bfd_set_error (bfd_error_file_truncated);
return -1;
}
}
/* Read the record header */
! if (bfd_bread (PRIV (recrd.buf), test_len, abfd) != test_len)
{
bfd_set_error (bfd_error_file_truncated);
return -1;
Index: vms-lib.c
===================================================================
RCS file: /cvs/src/src/bfd/vms-lib.c,v
retrieving revision 1.2
diff -c -r1.2 vms-lib.c
*** vms-lib.c 6 Apr 2010 13:55:38 -0000 1.2
--- vms-lib.c 16 Apr 2010 14:19:24 -0000
***************
*** 557,562 ****
--- 557,563 ----
if (!vms_lib_read_block (abfd))
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;
***************
*** 564,574 ****
--- 565,577 ----
return 0;
if (buf != NULL)
{
+ /* 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;
}
***************
*** 818,823 ****
--- 821,827 ----
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