aboutsummaryrefslogtreecommitdiff
path: root/bfd/linker.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2001-08-17 09:50:05 +0000
committerAlan Modra <amodra@gmail.com>2001-08-17 09:50:05 +0000
commit0ac450b689f758b9ff145ae4b0cf910f6686f12f (patch)
tree5bf4a16bf7b24bd53fa0b6329db164ce1c714901 /bfd/linker.c
parent5d964dfa3eeb841f9df66cf73e0b26a21edfa7fa (diff)
downloadgdb-0ac450b689f758b9ff145ae4b0cf910f6686f12f.zip
gdb-0ac450b689f758b9ff145ae4b0cf910f6686f12f.tar.gz
gdb-0ac450b689f758b9ff145ae4b0cf910f6686f12f.tar.bz2
* linker.c (default_fill_link_order): Handle four byte fill value.
Diffstat (limited to 'bfd/linker.c')
-rw-r--r--bfd/linker.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/bfd/linker.c b/bfd/linker.c
index 1144e92..00389ac 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -2655,28 +2655,35 @@ default_fill_link_order (abfd, info, sec, link_order)
struct bfd_link_order *link_order;
{
size_t size;
- char *space;
+ unsigned char *space;
size_t i;
- int fill;
+ unsigned int fill;
+ file_ptr loc;
boolean result;
BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
size = (size_t) link_order->size;
- space = (char *) bfd_malloc (size);
- if (space == NULL && size != 0)
+ if (size == 0)
+ return true;
+
+ space = (unsigned char *) bfd_malloc (size);
+ if (space == NULL)
return false;
fill = link_order->u.fill.value;
- for (i = 0; i < size; i += 2)
+ for (i = 0; i < size; i += 4)
+ space[i] = fill >> 24;
+ for (i = 1; i < size; i += 4)
+ space[i] = fill >> 16;
+ for (i = 2; i < size; i += 4)
space[i] = fill >> 8;
- for (i = 1; i < size; i += 2)
+ for (i = 3; i < size; i += 4)
space[i] = fill;
- result = bfd_set_section_contents (abfd, sec, space,
- (file_ptr)
- (link_order->offset *
- bfd_octets_per_byte (abfd)),
- link_order->size);
+
+ loc = (file_ptr) (link_order->offset * bfd_octets_per_byte (abfd));
+ result = bfd_set_section_contents (abfd, sec, space, loc, link_order->size);
+
free (space);
return result;
}