This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Committed, MMIX: Fix bug in bfd/mmo.c:mmo_write_loc_chunk withsection sizes not multiple of four
- From: Hans-Peter Nilsson <hp at bitrange dot com>
- To: <binutils at sources dot redhat dot com>
- Date: Sat, 29 Jun 2002 17:47:15 -0400 (EDT)
- Subject: Committed, MMIX: Fix bug in bfd/mmo.c:mmo_write_loc_chunk withsection sizes not multiple of four
Spotted as g++.eh/catch5.C at some time regressed and then the
regression disappeared when I added a "return" pattern in the
GCC port.
bfd:
* mmo.c (mmo_write_loc_chunk): Don't eliminate leading and
trailing zero-sequences when there's previous left-over data.
ld/testsuite:
* ld-mmix/sec-8m.d, ld-mmix/sec-8m.s, ld-mmix/sec-8a.s,
ld-mmix/sec-8b.s, ld-mmix/sec-8d.s: New test.
Index: sec-8m.d
===================================================================
RCS file: sec-8m.d
diff -N sec-8m.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- sec-8m.d 29 Jun 2002 21:21:41 -0000
***************
*** 0 ****
--- 1,30 ----
+ #source: start.s
+ #source: sec-8a.s
+ #source: sec-8b.s
+ #source: sec-8m.s
+ #source: sec-8d.s
+ #ld: -m mmo
+ #objdump: -s
+
+ # Distantly related to sec-7m.s in that section lengths mattered for the
+ # bug. When one input-section (seen in mmo.c as a chunk of data to
+ # output) had a length not a multiple of four, the last bytes were saved
+ # to be concatenated with the next chunk. If it was followed by a chunk
+ # with a leading multiple-of-four number of zero bytes, those zero bytes
+ # would be omitted, and the "saved" bytes would be concatenated with the
+ # following (not-all-zeros) bytes. Hence a shift of the last bytes of the
+ # first chunk. Note that the section will be padded in the output.
+
+ .*: file format mmo
+
+ Contents of section \.text:
+ 0000 e3fd0001 2a000000 00000000 00000000 .*
+ #...
+ 7ff0 00000000 00000000 00000000 2b2c0000 .*
+ #...
+ fff0 00000000 00000000 00002d00 00000000 .*
+ 10000 00000000 00000000 0000002e 2f303132 .*
+ 10010 33000000 00000000 00000000 00000000 .*
+ 10020 00300000 00000000 00000000 00000000 .*
+ #...
+ 18020 31000000 .*
Index: sec-8b.s
===================================================================
RCS file: sec-8b.s
diff -N sec-8b.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- sec-8b.s 29 Jun 2002 21:21:46 -0000
***************
*** 0 ****
--- 1,4 ----
+ .section .text.1
+ .byte 44
+ .space 32764
+ .byte 45
Index: sec-8d.s
===================================================================
RCS file: sec-8d.s
diff -N sec-8d.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- sec-8d.s 29 Jun 2002 21:21:50 -0000
***************
*** 0 ****
--- 1,4 ----
+ .section .text.1
+ .byte 48
+ .space 32766
+ .byte 49
Index: sec-8m.s
===================================================================
RCS file: sec-8m.s
diff -N sec-8m.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- sec-8m.s 29 Jun 2002 21:21:55 -0000
***************
*** 0 ****
--- 1,4 ----
+ .section .text.1
+ .byte 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
+ .byte 46, 47, 48, 49, 50, 51
+ .byte 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0
Index: sec-8a.s
===================================================================
RCS file: sec-8a.s
diff -N sec-8a.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- sec-8a.s 29 Jun 2002 21:21:59 -0000
***************
*** 0 ****
--- 1,4 ----
+ .section .text.1
+ .byte 42
+ .space 32759
+ .byte 43
Index: mmo.c
===================================================================
RCS file: /cvs/src/src/bfd/mmo.c,v
retrieving revision 1.11
diff -p -c -r1.11 mmo.c
*** mmo.c 25 Jun 2002 06:21:54 -0000 1.11
--- mmo.c 29 Jun 2002 21:04:11 -0000
*************** mmo_write_loc_chunk (abfd, vma, loc, len
*** 913,928 ****
/* Find an initial and trailing section of zero tetras; we don't need to
write out zeros. FIXME: When we do this, we should emit section size
and address specifiers, else objcopy can't always perform an identity
! translation. */
! while (len >= 4 && bfd_get_32 (abfd, loc) == 0)
{
! vma += 4;
! len -= 4;
! loc += 4;
! }
! while (len >= 4 && bfd_get_32 (abfd, loc + len - 4) == 0)
! len -= 4;
/* Only write out the location if it's different than the one the caller
(supposedly) previously handled, accounting for omitted leading zeros. */
--- 913,935 ----
/* Find an initial and trailing section of zero tetras; we don't need to
write out zeros. FIXME: When we do this, we should emit section size
and address specifiers, else objcopy can't always perform an identity
! translation. Only do this if we *don't* have left-over data from a
! previous write or the vma of this chunk is *not* the next address,
! because then data isn't tetrabyte-aligned and we're concatenating to
! that left-over data. */
!
! if (abfd->tdata.mmo_data->byte_no == 0 || vma != *last_vmap)
{
! while (len >= 4 && bfd_get_32 (abfd, loc) == 0)
! {
! vma += 4;
! len -= 4;
! loc += 4;
! }
! while (len >= 4 && bfd_get_32 (abfd, loc + len - 4) == 0)
! len -= 4;
! }
/* Only write out the location if it's different than the one the caller
(supposedly) previously handled, accounting for omitted leading zeros. */
brgds, H-P