[2/2] z/OS Support: Catching segfaults

Message ID 20200126113329.1731-3-leviathan@libresilicon.com
State Superseded
Headers show
Series
  • Introducing support for cross compiling/linking for the z/OS platform
Related show

Commit Message

David Lanzendörfer Jan. 26, 2020, 11:33 a.m.
From: David Lanzendörfer <david.lanzendoerfer@o2s.ch>


When handling the z/OS object files in F4SA format certain fields
are blank which caused segfaults in ld during linking.
---
 bfd/linker.c | 2 +-
 ld/ldlang.c  | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

-- 
2.25.0

Patch

diff --git a/bfd/linker.c b/bfd/linker.c
index d8703179e5..9711951ea7 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -508,7 +508,7 @@  bfd_link_hash_lookup (struct bfd_link_hash_table *table,
 {
   struct bfd_link_hash_entry *ret;
 
-  if (table == NULL || string == NULL)
+  if (table == NULL || string == NULL || string[0]=='\0' )
     return NULL;
 
   ret = ((struct bfd_link_hash_entry *)
diff --git a/ld/ldlang.c b/ld/ldlang.c
index e100c0533c..5fbba7e723 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -6521,6 +6521,8 @@  foreach_start_stop (void (*func) (struct bfd_link_hash_entry *))
 static void
 undef_start_stop (struct bfd_link_hash_entry *h)
 {
+  if (h==-1)
+    return;
   if (h->ldscript_def)
     return;
 
@@ -6586,6 +6588,8 @@  lang_init_startof_sizeof (void)
 static void
 set_start_stop (struct bfd_link_hash_entry *h)
 {
+  if(h==-1)
+    return;
   if (h->ldscript_def
       || h->type != bfd_link_hash_defined)
     return;