summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2002-02-15 02:10:35 +0000
committerAlan Modra <amodra@gmail.com>2002-02-15 02:10:35 +0000
commitfd96f80fc8159f92a6d80a36ddbcfd274c4ef96a (patch)
tree8f36b132e9d43be2ec7eb231e177bfc8f5d71c65
parent9a1b9f826d080723e5ffabaab8f4f2dbf76bc3cf (diff)
downloadppe42-binutils-fd96f80fc8159f92a6d80a36ddbcfd274c4ef96a.tar.gz
ppe42-binutils-fd96f80fc8159f92a6d80a36ddbcfd274c4ef96a.zip
Support arbitrary length fill patterns.
* linker.c (bfd_new_link_order): Zero all fields with bfd_zalloc. (_bfd_default_link_order): Remove bfd_fill_link_order code. Call default_data_link_order. (default_fill_link_order): Delete. (default_data_link_order): New function. * elf32-mips.c (_bfd_mips_elf_final_link): Replace occurrences of bfd_fill_link_order with bfd_data_link_order. * elf64-alpha.c (elf64_alpha_final_link): Likewise. * elf64-mips.c (mips_elf64_final_link): Likewise.
-rw-r--r--bfd/ChangeLog11
-rw-r--r--bfd/elf32-mips.c8
-rw-r--r--bfd/elf64-alpha.c2
-rw-r--r--bfd/elf64-mips.c6
-rw-r--r--bfd/linker.c72
5 files changed, 57 insertions, 42 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 68618604bc..8b43bfff70 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,16 @@
2002-02-15 Alan Modra <amodra@bigpond.net.au>
+ Support arbitrary length fill patterns.
+ * linker.c (bfd_new_link_order): Zero all fields with bfd_zalloc.
+ (_bfd_default_link_order): Remove bfd_fill_link_order code.
+ Call default_data_link_order.
+ (default_fill_link_order): Delete.
+ (default_data_link_order): New function.
+ * elf32-mips.c (_bfd_mips_elf_final_link): Replace occurrences
+ of bfd_fill_link_order with bfd_data_link_order.
+ * elf64-alpha.c (elf64_alpha_final_link): Likewise.
+ * elf64-mips.c (mips_elf64_final_link): Likewise.
+
* bfd.c (bfd_scan_vma): Clamp overflows to max bfd_vma value.
Correct value returned in "end" for "0x<non-hex>".
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 73eba75de9..c62c5db213 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -5271,7 +5271,7 @@ _bfd_mips_elf_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
@@ -5398,7 +5398,7 @@ _bfd_mips_elf_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
@@ -5554,7 +5554,7 @@ _bfd_mips_elf_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
@@ -5634,7 +5634,7 @@ _bfd_mips_elf_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 6df126a4d1..d0d325176c 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -4105,7 +4105,7 @@ elf64_alpha_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 75d456ac37..f20d15bc07 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -6518,7 +6518,7 @@ mips_elf64_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
@@ -6655,7 +6655,7 @@ mips_elf64_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
@@ -6734,7 +6734,7 @@ mips_elf64_final_link (abfd, info)
if (p->type != bfd_indirect_link_order)
{
- if (p->type == bfd_fill_link_order)
+ if (p->type == bfd_data_link_order)
continue;
abort ();
}
diff --git a/bfd/linker.c b/bfd/linker.c
index e3828957da..727be336b1 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -1,5 +1,5 @@
/* linker.c -- BFD linker routines
- Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support
@@ -426,7 +426,7 @@ static void set_symbol_from_hash
PARAMS ((asymbol *, struct bfd_link_hash_entry *));
static boolean generic_add_output_symbol
PARAMS ((bfd *, size_t *psymalloc, asymbol *));
-static boolean default_fill_link_order
+static boolean default_data_link_order
PARAMS ((bfd *, struct bfd_link_info *, asection *,
struct bfd_link_order *));
static boolean default_indirect_link_order
@@ -2608,14 +2608,13 @@ bfd_new_link_order (abfd, section)
asection *section;
{
bfd_size_type amt = sizeof (struct bfd_link_order);
- struct bfd_link_order *new = (struct bfd_link_order *) bfd_alloc (abfd, amt);
+ struct bfd_link_order *new;
+
+ new = (struct bfd_link_order *) bfd_zalloc (abfd, amt);
if (!new)
return NULL;
new->type = bfd_undefined_link_order;
- new->offset = 0;
- new->size = 0;
- new->next = (struct bfd_link_order *) NULL;
if (section->link_order_tail != (struct bfd_link_order *) NULL)
section->link_order_tail->next = new;
@@ -2637,8 +2636,6 @@ _bfd_default_link_order (abfd, info, sec, link_order)
asection *sec;
struct bfd_link_order *link_order;
{
- file_ptr loc;
-
switch (link_order->type)
{
case bfd_undefined_link_order:
@@ -2649,29 +2646,23 @@ _bfd_default_link_order (abfd, info, sec, link_order)
case bfd_indirect_link_order:
return default_indirect_link_order (abfd, info, sec, link_order,
false);
- case bfd_fill_link_order:
- return default_fill_link_order (abfd, info, sec, link_order);
case bfd_data_link_order:
- loc = link_order->offset * bfd_octets_per_byte (abfd);
- return bfd_set_section_contents (abfd, sec,
- (PTR) link_order->u.data.contents,
- loc, link_order->size);
+ return default_data_link_order (abfd, info, sec, link_order);
}
}
-/* Default routine to handle a bfd_fill_link_order. */
+/* Default routine to handle a bfd_data_link_order. */
static boolean
-default_fill_link_order (abfd, info, sec, link_order)
+default_data_link_order (abfd, info, sec, link_order)
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
asection *sec;
struct bfd_link_order *link_order;
{
bfd_size_type size;
- unsigned char *space;
- size_t i;
- unsigned int fill;
+ size_t fill_size;
+ bfd_byte *fill;
file_ptr loc;
boolean result;
@@ -2681,24 +2672,37 @@ default_fill_link_order (abfd, info, sec, link_order)
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 += 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 = 3; i < size; i += 4)
- space[i] = fill;
+ fill = link_order->u.data.contents;
+ fill_size = link_order->u.data.size;
+ if (fill_size != 0 && fill_size < size)
+ {
+ bfd_byte *p;
+ fill = (bfd_byte *) bfd_malloc (size);
+ if (fill == NULL)
+ return false;
+ p = fill;
+ if (fill_size == 1)
+ memset (p, (int) link_order->u.data.contents[0], (size_t) size);
+ else
+ {
+ do
+ {
+ memcpy (p, link_order->u.data.contents, fill_size);
+ p += fill_size;
+ size -= fill_size;
+ }
+ while (size >= fill_size);
+ if (size != 0)
+ memcpy (p, link_order->u.data.contents, (size_t) size);
+ size = link_order->size;
+ }
+ }
loc = link_order->offset * bfd_octets_per_byte (abfd);
- result = bfd_set_section_contents (abfd, sec, space, loc, size);
+ result = bfd_set_section_contents (abfd, sec, fill, loc, size);
- free (space);
+ if (fill != link_order->u.data.contents)
+ free (fill);
return result;
}
OpenPOWER on IntegriCloud