diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2025-06-21 06:36:56 +0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2025-06-23 22:30:53 +0800 |
commit | 08c3cbe5926e4d355b5cb70bbec2b1eeb40c2944 (patch) | |
tree | 237467853a05ce59be9dff840371323f43bb14ae | |
parent | 41461010eb7c79fee7a9d5f6209accdaac66cc6b (diff) | |
download | binutils-08c3cbe5926e4d355b5cb70bbec2b1eeb40c2944.zip binutils-08c3cbe5926e4d355b5cb70bbec2b1eeb40c2944.tar.gz binutils-08c3cbe5926e4d355b5cb70bbec2b1eeb40c2944.tar.bz2 |
objcopy: Don't extend the output section size
Since the output section contents are copied from the input, don't
extend the output section size beyond the input section size.
PR binutils/33049
* objcopy.c (copy_section): Don't extend the output section
size beyond the input section size.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
-rw-r--r-- | binutils/objcopy.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 366e107..2e98ba4 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -4650,6 +4650,7 @@ copy_section (bfd *ibfd, sec_ptr isection, bfd *obfd) char *to = (char *) memhunk; char *end = (char *) memhunk + size; int i; + bfd_size_type memhunk_size = size; /* If the section address is not exactly divisible by the interleave, then we must bias the from address. If the copy_byte is less than @@ -4669,6 +4670,11 @@ copy_section (bfd *ibfd, sec_ptr isection, bfd *obfd) } size = (size + interleave - 1 - copy_byte) / interleave * copy_width; + + /* Don't extend the output section size. */ + if (size > memhunk_size) + size = memhunk_size; + osection->lma /= interleave; if (copy_byte < extra) osection->lma++; |