aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2000-09-20 04:20:26 +0000
committerAlan Modra <amodra@gmail.com>2000-09-20 04:20:26 +0000
commitb3ea35849fbbdfb9a2396e4e9369d28f8597338a (patch)
tree5e660b2b5007cb997e3f609c349ee48a32c6de54 /ld
parent6091b433d78be72dd7970fcd91822ae2b9db7a81 (diff)
downloadgdb-b3ea35849fbbdfb9a2396e4e9369d28f8597338a.zip
gdb-b3ea35849fbbdfb9a2396e4e9369d28f8597338a.tar.gz
gdb-b3ea35849fbbdfb9a2396e4e9369d28f8597338a.tar.bz2
Handle out of memory situations.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog9
-rw-r--r--ld/emultempl/elf32.em10
-rw-r--r--ld/ldwrite.c23
3 files changed, 27 insertions, 15 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 5c5b0a6..c6fef18 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,12 @@
+2000-09-20 Alan Modra <alan@linuxcare.com.au>
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Handle
+ out of memory failure.
+
+ * ldwrite.c (ldwrite): Remove unnecessary einfo arg.
+ (clone_section): Handle out of memory failures. Rename var to
+ avoid c++ reserved word.
+
2000-09-18 Alan Modra <alan@linuxcare.com.au>
* emultempl/hppaelf.em (hppaelf_add_stub_section): Rename
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index c7ba497..fe4966d 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1092,9 +1092,13 @@ gld${EMULATION_NAME}_place_orphan (file, s)
loadable or allocateable characteristics. */
outsecname = secname;
if (bfd_get_section_by_name (output_bfd, outsecname) != NULL)
- outsecname = bfd_get_unique_section_name (output_bfd,
- outsecname,
- &count);
+ {
+ outsecname = bfd_get_unique_section_name (output_bfd,
+ outsecname,
+ &count);
+ if (outsecname == NULL)
+ einfo ("%F%P: place_orphan failed: %E\n");
+ }
/* Start building a list of statements for this section.
First save the current statement pointer. */
diff --git a/ld/ldwrite.c b/ld/ldwrite.c
index 37e2580..233f238 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);
}