aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-06-29 11:17:40 +0100
committerNick Clifton <nickc@redhat.com>2016-06-29 11:17:40 +0100
commitd691934d08a4132506a19ac8d7565f1a0461a80a (patch)
treefe66ef6fe44ace2691c7d25cfbc53a2e860d0eac /bfd
parent6844c0ccea23157d9f965524d02f656a9f89f48e (diff)
downloadgdb-d691934d08a4132506a19ac8d7565f1a0461a80a.zip
gdb-d691934d08a4132506a19ac8d7565f1a0461a80a.tar.gz
gdb-d691934d08a4132506a19ac8d7565f1a0461a80a.tar.bz2
Preserve all mapping symbols in ARM and AArch64 object files.
bfd * elfnn-aarch64.c (is_aarch64_mapping_symbol): New function. Returns TRUE for AArch64 mapping symbols. (elfNN_aarch64_backend_symbol_processing): New function. Marks mapping symbols as precious in object files so that they will not be stripped. (elf_backend_symbol_processing): Define. * elf32-arm.c (is_arm_mapping_symbol): New function. Returns TRUE for ARM mapping symbols. (elf32_arm_backend_symbol_processing): Make use of the new function.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog13
-rw-r--r--bfd/elf32-arm.c27
-rw-r--r--bfd/elfnn-aarch64.c37
3 files changed, 73 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9e2534e..90e34ac 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,16 @@
+2016-06-29 Nick Clifton <nickc@redhat.com>
+
+ * elfnn-aarch64.c (is_aarch64_mapping_symbol): New function.
+ Returns TRUE for AArch64 mapping symbols.
+ (elfNN_aarch64_backend_symbol_processing): New function. Marks
+ mapping symbols as precious in object files so that they will not
+ be stripped.
+ (elf_backend_symbol_processing): Define.
+
+ * elf32-arm.c (is_arm_mapping_symbol): New function. Returns TRUE
+ for ARM mapping symbols.
+ (elf32_arm_backend_symbol_processing): Make use of the new function.
+
2016-06-28 H.J. Lu <hongjiu.lu@intel.com>
PR ld/20306
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 04e776c..3d4a458 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -18266,6 +18266,28 @@ elf32_arm_copy_special_section_fields (const bfd *ibfd ATTRIBUTE_UNUSED,
return FALSE;
}
+/* Returns TRUE if NAME is an ARM mapping symbol.
+ Traditionally the symbols $a, $d and $t have been used.
+ The ARM ELF standard also defines $x (for A64 code). It also allows a
+ period initiated suffix to be added to the symbol: "$[adtx]\.[:sym_char]+".
+ Other tools might also produce $b (Thumb BL), $f, $p, $m and $v, but we do
+ not support them here. $t.x indicates the start of ThumbEE instructions. */
+
+static bfd_boolean
+is_arm_mapping_symbol (const char * name)
+{
+ return name != NULL /* Paranoia. */
+ && name[0] == '$' /* Note: if objcopy --prefix-symbols has been used then
+ the mapping symbols could have acquired a prefix.
+ We do not support this here, since such symbols no
+ longer conform to the ARM ELF ABI. */
+ && (name[1] == 'a' || name[1] == 'd' || name[1] == 't' || name[1] == 'x')
+ && (name[2] == 0 || name[2] == '.');
+ /* FIXME: Strictly speaking the symbol is only a valid mapping symbol if
+ any characters that follow the period are legal characters for the body
+ of a symbol's name. For now we just assume that this is the case. */
+}
+
/* Make sure that mapping symbols in object files are not removed via the
"strip --strip-unneeded" tool. These symbols are needed in order to
correctly generate interworking veneers, and for byte swapping code
@@ -18276,11 +18298,8 @@ static void
elf32_arm_backend_symbol_processing (bfd *abfd, asymbol *sym)
{
if (((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
- && sym->name != NULL
&& sym->section != bfd_abs_section_ptr
- && (strcmp (sym->name, "$a") == 0
- || strcmp (sym->name, "$t") == 0
- || strcmp (sym->name, "$d") == 0))
+ && is_arm_mapping_symbol (sym->name))
sym->flags |= BSF_KEEP;
}
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index fa66b0f..3435a3d 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -9212,6 +9212,40 @@ elfNN_aarch64_plt_sym_val (bfd_vma i, const asection *plt,
return plt->vma + PLT_ENTRY_SIZE + i * PLT_SMALL_ENTRY_SIZE;
}
+/* Returns TRUE if NAME is an AArch64 mapping symbol.
+ The ARM ELF standard defines $x (for A64 code) and $d (for data).
+ It also allows a period initiated suffix to be added to the symbol, ie:
+ "$[adtx]\.[:sym_char]+". */
+
+static bfd_boolean
+is_aarch64_mapping_symbol (const char * name)
+{
+ return name != NULL /* Paranoia. */
+ && name[0] == '$' /* Note: if objcopy --prefix-symbols has been used then
+ the mapping symbols could have acquired a prefix.
+ We do not support this here, since such symbols no
+ longer conform to the ARM ELF ABI. */
+ && (name[1] == 'd' || name[1] == 'x')
+ && (name[2] == 0 || name[2] == '.');
+ /* FIXME: Strictly speaking the symbol is only a valid mapping symbol if
+ any characters that follow the period are legal characters for the body
+ of a symbol's name. For now we just assume that this is the case. */
+}
+
+/* Make sure that mapping symbols in object files are not removed via the
+ "strip --strip-unneeded" tool. These symbols might needed in order to
+ correctly generate linked files. Once an object file has been linked,
+ it should be safe to remove them. */
+
+static void
+elfNN_aarch64_backend_symbol_processing (bfd *abfd, asymbol *sym)
+{
+ if (((abfd->flags & (EXEC_P | DYNAMIC)) == 0)
+ && sym->section != bfd_abs_section_ptr
+ && is_aarch64_mapping_symbol (sym->name))
+ sym->flags |= BSF_KEEP;
+}
+
/* We use this so we can override certain functions
(though currently we don't). */
@@ -9351,6 +9385,9 @@ const struct elf_size_info elfNN_aarch64_size_info =
#define elf_backend_write_section \
elfNN_aarch64_write_section
+#define elf_backend_symbol_processing \
+ elfNN_aarch64_backend_symbol_processing
+
#define elf_backend_can_refcount 1
#define elf_backend_can_gc_sections 1
#define elf_backend_plt_readonly 1