summaryrefslogtreecommitdiff
path: root/ld/ldwrite.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2000-09-20 04:20:26 +0000
committerAlan Modra <amodra@bigpond.net.au>2000-09-20 04:20:26 +0000
commitf463d096ad8efc2f27bdb8d1245717e5fb0ad5a5 (patch)
tree7ba7a5c7e106da8183f2ea262876a786d5c5d713 /ld/ldwrite.c
parent1b405352baf16bfc30e17e6432976f2d2640791f (diff)
downloadbinutils-redhat-f463d096ad8efc2f27bdb8d1245717e5fb0ad5a5.tar.gz
Handle out of memory situations.
Diffstat (limited to 'ld/ldwrite.c')
-rw-r--r--ld/ldwrite.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/ld/ldwrite.c b/ld/ldwrite.c
index 37e258030a..233f2388eb 100644
--- a/ld/ldwrite.c
+++ b/ld/ldwrite.c
@@ -306,23 +306,22 @@ clone_section (abfd, s, name, count)
const char *name;
int *count;
{
- char template[6];
+ char templ[6];
char *sname;
asection *n;
struct bfd_link_hash_entry *h;
/* Invent a section name from the first five chars of the base
section name and a digit suffix. */
- strncpy (template, name, sizeof (template) - 1);
- template[sizeof (template) - 1] = '\0';
- sname = bfd_get_unique_section_name (abfd, template, count);
-
- n = bfd_make_section_anyway (abfd, sname);
-
- /* Create a symbol of the same name. */
-
- h = bfd_link_hash_lookup (link_info.hash,
- sname, true, true, false);
+ strncpy (templ, name, sizeof (templ) - 1);
+ templ[sizeof (templ) - 1] = '\0';
+ if ((sname = bfd_get_unique_section_name (abfd, templ, count)) == NULL
+ || (n = bfd_make_section_anyway (abfd, sname)) == NULL
+ || (h = bfd_link_hash_lookup (link_info.hash,
+ sname, true, true, false)) == NULL)
+ einfo (_("%F%P: clone section failed: %E\n"));
+
+ /* Set up section symbol. */
h->type = bfd_link_hash_defined;
h->u.def.value = 0;
h->u.def.section = n;
@@ -536,7 +535,7 @@ ldwrite ()
out. */
if (bfd_get_error () != bfd_error_no_error)
- einfo (_("%F%P: final link failed: %E\n"), output_bfd);
+ einfo (_("%F%P: final link failed: %E\n"));
else
xexit(1);
}