summaryrefslogtreecommitdiffstats
path: root/binutils-2.25
diff options
context:
space:
mode:
authorMarcus Shawcroft <marcus.shawcroft@arm.com>2015-02-28 00:10:21 +0000
committerAndrew Hsieh <andrewhsieh@google.com>2015-03-30 21:38:53 -0700
commit907fd75eaa23fe589a47d1168a58989a4621d732 (patch)
tree5892c297ae338f21ef3bf045a86123fab2c0a5e1 /binutils-2.25
parentf0c15889b01b2505368776123956e308b610fb48 (diff)
downloadtoolchain_binutils-907fd75eaa23fe589a47d1168a58989a4621d732.tar.gz
toolchain_binutils-907fd75eaa23fe589a47d1168a58989a4621d732.tar.bz2
toolchain_binutils-907fd75eaa23fe589a47d1168a58989a4621d732.zip
[AArch64] Factor out common behaviour between elf_aarch64_create_or_find_stub_sec and elfNN_aarch64_add_stub
Change-Id: I8e5ce0f4dd3aa322f97fa09d42c6f95e0d45118d
Diffstat (limited to 'binutils-2.25')
-rw-r--r--binutils-2.25/bfd/elfnn-aarch64.c84
1 files changed, 32 insertions, 52 deletions
diff --git a/binutils-2.25/bfd/elfnn-aarch64.c b/binutils-2.25/bfd/elfnn-aarch64.c
index 0e47f272..9e58594f 100644
--- a/binutils-2.25/bfd/elfnn-aarch64.c
+++ b/binutils-2.25/bfd/elfnn-aarch64.c
@@ -2303,20 +2303,21 @@ elfNN_aarch64_get_stub_entry (const asection *input_section,
return stub_entry;
}
-/* Add a new stub entry to the stub hash. Not all fields of the new
- stub entry are initialised. */
-static struct elf_aarch64_stub_hash_entry *
-elfNN_aarch64_add_stub (const char *stub_name,
- asection *section,
- struct elf_aarch64_link_hash_table *htab)
+/* Find or create a stub section in the stub group for an input
+ section. */
+
+static asection *
+_bfd_aarch64_create_or_find_stub_sec (asection *section,
+ struct elf_aarch64_link_hash_table *htab)
{
asection *link_sec;
asection *stub_sec;
- struct elf_aarch64_stub_hash_entry *stub_entry;
link_sec = htab->stub_group[section->id].link_sec;
+ BFD_ASSERT (link_sec != NULL);
stub_sec = htab->stub_group[section->id].stub_sec;
+
if (stub_sec == NULL)
{
stub_sec = htab->stub_group[link_sec->id].stub_sec;
@@ -2335,6 +2336,7 @@ elfNN_aarch64_add_stub (const char *stub_name,
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);
+
if (stub_sec == NULL)
return NULL;
htab->stub_group[link_sec->id].stub_sec = stub_sec;
@@ -2342,6 +2344,26 @@ elfNN_aarch64_add_stub (const char *stub_name,
htab->stub_group[section->id].stub_sec = stub_sec;
}
+ return stub_sec;
+}
+
+
+/* Add a new stub entry in the stub group associated with an input
+ section to the stub hash. Not all fields of the new stub entry are
+ initialised. */
+
+static struct elf_aarch64_stub_hash_entry *
+_bfd_aarch64_add_stub_entry_in_group (const char *stub_name,
+ asection *section,
+ struct elf_aarch64_link_hash_table *htab)
+{
+ asection *link_sec;
+ asection *stub_sec;
+ struct elf_aarch64_stub_hash_entry *stub_entry;
+
+ link_sec = htab->stub_group[section->id].link_sec;
+ stub_sec = _bfd_aarch64_create_or_find_stub_sec (section, htab);
+
/* Enter this entry into the linker stub hash table. */
stub_entry = aarch64_stub_hash_lookup (&htab->stub_hash_table, stub_name,
TRUE, FALSE);
@@ -3060,48 +3082,6 @@ erratum_835769_scan (bfd *input_bfd,
return TRUE;
}
-/* Find or create a stub section. */
-
-static asection *
-elf_aarch64_create_or_find_stub_sec (asection *section,
- struct elf_aarch64_link_hash_table *htab)
-{
- asection *link_sec;
- asection *stub_sec;
-
- link_sec = htab->stub_group[section->id].link_sec;
- BFD_ASSERT (link_sec != NULL);
- stub_sec = htab->stub_group[section->id].stub_sec;
-
- if (stub_sec == NULL)
- {
- 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 = (char *) 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);
-
- if (stub_sec == NULL)
- return NULL;
- htab->stub_group[link_sec->id].stub_sec = stub_sec;
- }
- htab->stub_group[section->id].stub_sec = stub_sec;
- }
-
- return stub_sec;
-}
-
/* Determine and set the size of the stub section for a final link.
The basic idea here is to examine all the relocations looking for
@@ -3386,8 +3366,8 @@ elfNN_aarch64_size_stubs (bfd *output_bfd,
continue;
}
- stub_entry = elfNN_aarch64_add_stub (stub_name, section,
- htab);
+ stub_entry = _bfd_aarch64_add_stub_entry_in_group
+ (stub_name, section, htab);
if (stub_entry == NULL)
{
free (stub_name);
@@ -3454,7 +3434,7 @@ elfNN_aarch64_size_stubs (bfd *output_bfd,
if (htab->fix_erratum_835769)
for (i = 0; i < num_erratum_835769_fixes; i++)
{
- stub_sec = elf_aarch64_create_or_find_stub_sec
+ stub_sec = _bfd_aarch64_create_or_find_stub_sec
(erratum_835769_fixes[i].section, htab);
if (stub_sec == NULL)