* [PATCH] objcopy: Fix for pr19005 on machines for more than one octet per byte. @ 2020-02-16 10:00 Christian Eggers 2020-02-19 9:30 ` Alan Modra 0 siblings, 1 reply; 4+ messages in thread From: Christian Eggers @ 2020-02-16 10:00 UTC (permalink / raw) To: binutils; +Cc: Christian Eggers On machines with more than one octet per byte, objcopy fills only a part of the gap between sections. * objcopy.c (copy_object): Convert from bytes to octets for --gap-fill. Signed-off-by: Christian Eggers <ceggers@gmx.de> --- binutils/objcopy.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/binutils/objcopy.c b/binutils/objcopy.c index fd94d63773e..f8ca0843937 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -3101,8 +3101,10 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) for (i = 0; i < c - 1; i++) { flagword flags; - bfd_size_type size; - bfd_vma gap_start, gap_stop; + bfd_size_type size; /* octets */ + bfd_vma gap_start, gap_stop; /* octets */ + unsigned int opb1 = bfd_octets_per_byte (obfd, osections[i]); + unsigned int opb2 = bfd_octets_per_byte (obfd, osections[i+1]); flags = bfd_section_flags (osections[i]); if ((flags & SEC_HAS_CONTENTS) == 0 @@ -3110,8 +3112,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) continue; size = bfd_section_size (osections[i]); - gap_start = bfd_section_lma (osections[i]) + size; - gap_stop = bfd_section_lma (osections[i + 1]); + gap_start = bfd_section_lma (osections[i]) * opb1 + size; + gap_stop = bfd_section_lma (osections[i + 1]) * opb2; if (gap_start < gap_stop) { if (!bfd_set_section_size (osections[i], -- 2.16.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] objcopy: Fix for pr19005 on machines for more than one octet per byte. 2020-02-16 10:00 [PATCH] objcopy: Fix for pr19005 on machines for more than one octet per byte Christian Eggers @ 2020-02-19 9:30 ` Alan Modra 2020-03-02 21:08 ` Christian Eggers 0 siblings, 1 reply; 4+ messages in thread From: Alan Modra @ 2020-02-19 9:30 UTC (permalink / raw) To: Christian Eggers; +Cc: binutils On Sun, Feb 16, 2020 at 11:00:22AM +0100, Christian Eggers wrote: > On machines with more than one octet per byte, objcopy fills only a part > of the gap between sections. > > * objcopy.c (copy_object): Convert from bytes to octets for > --gap-fill. OK. I think to --pad-to support needs a similar octets_per_byte fix. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] objcopy: Fix for pr19005 on machines for more than one octet per byte. 2020-02-19 9:30 ` Alan Modra @ 2020-03-02 21:08 ` Christian Eggers 2020-03-04 1:18 ` Alan Modra 0 siblings, 1 reply; 4+ messages in thread From: Christian Eggers @ 2020-03-02 21:08 UTC (permalink / raw) To: binutils, Alan Modra; +Cc: Christian Eggers On Wednesday, February 19 2020, Alan Modra wrote: > OK. I think to --pad-to support needs a similar octets_per_byte fix. Yes, I added this and wrote a small unit test for SDMA. --- On machines with more than one octet per byte, objcopy fills only a part of the gap between sections. * objcopy.c (copy_object): Convert from bytes to octets for --gap-fill and --pad-to. Patch changelog: v2: - Fix additionally --pad-to. - GNU coding style for comments. Signed-off-by: Christian Eggers <ceggers@gmx.de> --- binutils/objcopy.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/binutils/objcopy.c b/binutils/objcopy.c index fd94d63773e..daee5707637 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -3101,8 +3101,10 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) for (i = 0; i < c - 1; i++) { flagword flags; - bfd_size_type size; - bfd_vma gap_start, gap_stop; + bfd_size_type size; /* Octets. */ + bfd_vma gap_start, gap_stop; /* Octets. */ + unsigned int opb1 = bfd_octets_per_byte (obfd, osections[i]); + unsigned int opb2 = bfd_octets_per_byte (obfd, osections[i+1]); flags = bfd_section_flags (osections[i]); if ((flags & SEC_HAS_CONTENTS) == 0 @@ -3110,8 +3112,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) continue; size = bfd_section_size (osections[i]); - gap_start = bfd_section_lma (osections[i]) + size; - gap_stop = bfd_section_lma (osections[i + 1]); + gap_start = bfd_section_lma (osections[i]) * opb1 + size; + gap_stop = bfd_section_lma (osections[i + 1]) * opb2; if (gap_start < gap_stop) { if (!bfd_set_section_size (osections[i], @@ -3131,14 +3133,16 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) if (pad_to_set) { - bfd_vma lma; - bfd_size_type size; + bfd_vma lma; /* Octets. */ + bfd_size_type size; /* Octets. */ + unsigned int opb = bfd_octets_per_byte (obfd, osections[c - 1]); + bfd_vma _pad_to = pad_to * opb; - lma = bfd_section_lma (osections[c - 1]); + lma = bfd_section_lma (osections[c - 1]) * opb; size = bfd_section_size (osections[c - 1]); - if (lma + size < pad_to) + if (lma + size < _pad_to) { - if (!bfd_set_section_size (osections[c - 1], pad_to - lma)) + if (!bfd_set_section_size (osections[c - 1], _pad_to - lma)) { bfd_nonfatal_message (NULL, obfd, osections[c - 1], _("can't add padding")); @@ -3146,9 +3150,9 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch) } else { - gaps[c - 1] = pad_to - (lma + size); - if (max_gap < pad_to - (lma + size)) - max_gap = pad_to - (lma + size); + gaps[c - 1] = _pad_to - (lma + size); + if (max_gap < _pad_to - (lma + size)) + max_gap = _pad_to - (lma + size); } } } -- 2.16.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] objcopy: Fix for pr19005 on machines for more than one octet per byte. 2020-03-02 21:08 ` Christian Eggers @ 2020-03-04 1:18 ` Alan Modra 0 siblings, 0 replies; 4+ messages in thread From: Alan Modra @ 2020-03-04 1:18 UTC (permalink / raw) To: Christian Eggers; +Cc: binutils On Mon, Mar 02, 2020 at 10:08:20PM +0100, Christian Eggers wrote: > * objcopy.c (copy_object): Convert from bytes to octets for > --gap-fill and --pad-to. Applied, thanks. -- Alan Modra Australia Development Lab, IBM ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-03-04 1:18 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-02-16 10:00 [PATCH] objcopy: Fix for pr19005 on machines for more than one octet per byte Christian Eggers 2020-02-19 9:30 ` Alan Modra 2020-03-02 21:08 ` Christian Eggers 2020-03-04 1:18 ` Alan Modra
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).