[AArch64] Factor stub creation code into _bfd_aarch64_create_stub_section.
authorMarcus Shawcroft <marcus.shawcroft@arm.com>
Tue, 10 Mar 2015 13:16:28 +0000 (13:16 +0000)
committerMarcus Shawcroft <marcus.shawcroft@arm.com>
Mon, 23 Mar 2015 16:06:55 +0000 (16:06 +0000)
bfd/ChangeLog
bfd/elfnn-aarch64.c

index 386cff99ee8bca616ec90e7d494d0099c41f1264..e281c7fe9d4339e5a8cd34e689590a8476f92bb6 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-23  Marcus Shawcroft  <marcus.shawcroft@arm.com>
+
+       * elfnn-aarch64.c (_bfd_aarch64_create_or_find_stub_sec): Factor stub
+       creation code into...
+       (bfd_aarch64_create_stub_section): Define.
+
 2015-03-23  Marcus Shawcroft  <marcus.shawcroft@arm.com>
 
        * elfnn-aarch64.c (_bfd_aarch64_create_or_find_stub_sec): Rename
index 1db5942d30980776a4f4cc7de9f90f83ecd28291..5f80a2d7d7e71185eec639ad181b1bc285d6fe3e 100644 (file)
@@ -2327,6 +2327,28 @@ elfNN_aarch64_get_stub_entry (const asection *input_section,
 }
 
 
+/* Create a stub section.  */
+
+static asection *
+_bfd_aarch64_create_stub_section (asection *section,
+                                 struct elf_aarch64_link_hash_table *htab)
+{
+  size_t namelen;
+  bfd_size_type len;
+  char *s_name;
+
+  namelen = strlen (section->name);
+  len = namelen + sizeof (STUB_SUFFIX);
+  s_name = bfd_alloc (htab->stub_bfd, len);
+  if (s_name == NULL)
+    return NULL;
+
+  memcpy (s_name, section->name, namelen);
+  memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
+  return (*htab->add_stub_section) (s_name, section);
+}
+
+
 /* Find or create a stub section in the stub group for an input
    section.  */
 
@@ -2346,20 +2368,7 @@ _bfd_aarch64_create_or_find_stub_sec (asection *section,
       stub_sec = htab->stub_group[link_sec->id].stub_sec;
       if (stub_sec == NULL)
        {
-         size_t namelen;
-         bfd_size_type len;
-         char *s_name;
-
-         namelen = strlen (link_sec->name);
-         len = namelen + sizeof (STUB_SUFFIX);
-         s_name = bfd_alloc (htab->stub_bfd, len);
-         if (s_name == NULL)
-           return NULL;
-
-         memcpy (s_name, link_sec->name, namelen);
-         memcpy (s_name + namelen, STUB_SUFFIX, sizeof (STUB_SUFFIX));
-         stub_sec = (*htab->add_stub_section) (s_name, link_sec);
-
+         stub_sec = _bfd_aarch64_create_stub_section (link_sec, htab)
          if (stub_sec == NULL)
            return NULL;
          htab->stub_group[link_sec->id].stub_sec = stub_sec;