* Re: 64-bit support for srec
@ 2012-02-02 0:35 Joel Sherrill
2012-02-02 1:57 ` Mike Stump
0 siblings, 1 reply; 7+ messages in thread
From: Joel Sherrill @ 2012-02-02 0:35 UTC (permalink / raw)
To: Mike Stump, binutils
Lol.. who would have thought this day would come?
Can anything on the receiving end read these?
--joel
Mike Stump <mikestump@comcast.net> wrote:
>So, I'm sure I will anger the gods, for I am a heretic, but, here is support for writing 64-bit srecs.
>
>Ok?
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* 64-bit support for srec
@ 2012-02-01 23:55 Mike Stump
2012-02-02 3:23 ` Alan Modra
0 siblings, 1 reply; 7+ messages in thread
From: Mike Stump @ 2012-02-01 23:55 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
So, I'm sure I will anger the gods, for I am a heretic, but, here is support for writing 64-bit srecs.
Ok?
[-- Attachment #2: binutils-1.diffs.txt --]
[-- Type: text/plain, Size: 2549 bytes --]
2012-02-01 Mike Stump <mikestump@comcast.net>
* srec.c (srec_set_section_contents): Add 64-bit output support.
(srec_write_record): Likewise.
(srec_write_section): Likewise.
Index: binutils/bfd/srec.c
===================================================================
*** binutils/bfd/srec.c (revision 2070)
--- binutils/bfd/srec.c (working copy)
*************** srec_set_section_contents (bfd *abfd,
*** 897,904 ****
else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
&& tdata->type <= 2)
tdata->type = 2;
! else
tdata->type = 3;
entry->data = data;
entry->where = section->lma + offset;
--- 897,907 ----
else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
&& tdata->type <= 2)
tdata->type = 2;
! else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffffff
! && tdata->type <= 2)
tdata->type = 3;
+ else
+ tdata->type = 4;
entry->data = data;
entry->where = section->lma + offset;
*************** srec_write_record (bfd *abfd,
*** 956,961 ****
--- 959,973 ----
switch (type)
{
+ case 4:
+ TOHEX (dst, (address >> 56), check_sum);
+ dst += 2;
+ TOHEX (dst, (address >> 48), check_sum);
+ dst += 2;
+ TOHEX (dst, (address >> 40), check_sum);
+ dst += 2;
+ TOHEX (dst, (address >> 32), check_sum);
+ dst += 2;
case 3:
case 7:
TOHEX (dst, (address >> 24), check_sum);
*************** srec_write_section (bfd *abfd,
*** 1019,1027 ****
/* Validate number of data bytes to write. The srec length byte
counts the address, data and crc bytes. S1 (tdata->type == 1)
records have two address bytes, S2 (tdata->type == 2) records
! have three, and S3 (tdata->type == 3) records have four.
! The total length can't exceed 255, and a zero data length will
! spin for a long time. */
if (Chunk == 0)
Chunk = 1;
else if (Chunk > MAXCHUNK - tdata->type - 2)
--- 1031,1039 ----
/* Validate number of data bytes to write. The srec length byte
counts the address, data and crc bytes. S1 (tdata->type == 1)
records have two address bytes, S2 (tdata->type == 2) records
! have three, S3 (tdata->type == 3) records have four and S4
! (tdata->type == 4) records have eight. The total length can't
! exceed 255, and a zero data length will spin for a long time. */
if (Chunk == 0)
Chunk = 1;
else if (Chunk > MAXCHUNK - tdata->type - 2)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 64-bit support for srec
2012-02-01 23:55 Mike Stump
@ 2012-02-02 3:23 ` Alan Modra
2012-02-03 0:37 ` Mike Stump
0 siblings, 1 reply; 7+ messages in thread
From: Alan Modra @ 2012-02-02 3:23 UTC (permalink / raw)
To: Mike Stump; +Cc: binutils
On Wed, Feb 01, 2012 at 03:55:11PM -0800, Mike Stump wrote:
> --- 897,907 ----
> else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
> && tdata->type <= 2)
> tdata->type = 2;
> ! else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffffff
> ! && tdata->type <= 2)
Probably ought to be <= 3 here. Presumably the idea of the existing
code is that once you've used S3 records, don't drop back to S2.
> + case 4:
> + TOHEX (dst, (address >> 56), check_sum);
> + dst += 2;
What if "address" is only a 32-bit type? I think you need to
conditionalize all your new code on BFD64. And it would be sad if we
can't read back our own output..
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 64-bit support for srec
2012-02-02 3:23 ` Alan Modra
@ 2012-02-03 0:37 ` Mike Stump
2012-02-03 1:35 ` Alan Modra
0 siblings, 1 reply; 7+ messages in thread
From: Mike Stump @ 2012-02-03 0:37 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On Feb 1, 2012, at 7:22 PM, Alan Modra wrote:
> On Wed, Feb 01, 2012 at 03:55:11PM -0800, Mike Stump wrote:
>> --- 897,907 ----
>> else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
>> && tdata->type <= 2)
>> tdata->type = 2;
>> ! else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffffff
>> ! && tdata->type <= 2)
>
> Probably ought to be <= 3 here. Presumably the idea of the existing
> code is that once you've used S3 records, don't drop back to S2.
Agreed:
Index: bfd/srec.c
===================================================================
--- bfd/srec.c (revision 2081)
+++ bfd/srec.c (working copy)
@@ -898,7 +898,7 @@ srec_set_section_contents (bfd *abfd,
&& tdata->type <= 2)
tdata->type = 2;
else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffffff
- && tdata->type <= 2)
+ && tdata->type <= 3)
tdata->type = 3;
else
tdata->type = 4;
>> + case 4:
>> + TOHEX (dst, (address >> 56), check_sum);
>> + dst += 2;
>
> What if "address" is only a 32-bit type?
The optimizer removes the 64-bit code, since it can never be true.
> I think you need to conditionalize all your new code on BFD64.
I think it is safe to rely upon the optimizer to remove it. I don't see any advantages to peppering the code with #ifdef.
> And it would be sad if we can't read back our own output..
It would be even sadder if we silently dropped address bits and couldn't handle 64-bit addresses... oh, wait, we already do that. I'll see about doing up a reader, though, I can't say if or when I will get time to do it.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 64-bit support for srec
2012-02-03 0:37 ` Mike Stump
@ 2012-02-03 1:35 ` Alan Modra
2012-02-03 1:40 ` Mike Stump
0 siblings, 1 reply; 7+ messages in thread
From: Alan Modra @ 2012-02-03 1:35 UTC (permalink / raw)
To: Mike Stump; +Cc: binutils
On Thu, Feb 02, 2012 at 04:36:46PM -0800, Mike Stump wrote:
> The optimizer removes the 64-bit code, since it can never be true.
Without any warnings that cause -Werror builds to fail?
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: 64-bit support for srec
2012-02-03 1:35 ` Alan Modra
@ 2012-02-03 1:40 ` Mike Stump
0 siblings, 0 replies; 7+ messages in thread
From: Mike Stump @ 2012-02-03 1:40 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On Feb 2, 2012, at 5:35 PM, Alan Modra wrote:
> On Thu, Feb 02, 2012 at 04:36:46PM -0800, Mike Stump wrote:
>> The optimizer removes the 64-bit code, since it can never be true.
>
> Without any warnings that cause -Werror builds to fail?
Yeah, I thought it might complain about that, but I tested it out with a similar test appropriate for 64-bit machines, and it didn't complain. Love to hear if it complains for others.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-02-03 1:40 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-02 0:35 64-bit support for srec Joel Sherrill
2012-02-02 1:57 ` Mike Stump
-- strict thread matches above, loose matches on Subject: below --
2012-02-01 23:55 Mike Stump
2012-02-02 3:23 ` Alan Modra
2012-02-03 0:37 ` Mike Stump
2012-02-03 1:35 ` Alan Modra
2012-02-03 1:40 ` Mike Stump
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).