This is the mail archive of the
mailing list for the binutils project.
Re: ARM mapping symbols and --strip-unneeded
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: "Richard Earnshaw (lists)" <Richard dot Earnshaw at arm dot com>, Michael Weiser <michael at weiser dot dinsnail dot net>, binutils <binutils at sourceware dot org>
- Date: Wed, 29 Jun 2016 02:26:14 -0700
- Subject: Re: ARM mapping symbols and --strip-unneeded
- Authentication-results: sourceware.org; auth=none
- References: <20160626221336 dot GB1916 at weiser dot dinsnail dot net> <e7fff803-6244-4782-2768-6b301387aed8 at redhat dot com> <577132D2 dot 9090903 at arm dot com> <1aa007dc-68eb-2d6f-d731-561564a1e3da at redhat dot com> <5772A892 dot 2000208 at arm dot com> <b24a6c7e-f657-9529-e27a-de61604cabd2 at redhat dot com>
On Wed, Jun 29, 2016 at 2:24 AM, Nick Clifton <email@example.com> wrote:
> Hi Richard,
>> Might be safer to use strncmp (sym, type, 2) since 'extended' mapping
>> symbols can be produced by some tools.
> We might as well extract mapping symbol determination into a separate
> function - I have a feeling that it is going to be needed again in the
> future. So what do you think of this patch ?
We should check aarch64 target as it might have the same issue too as
it uses $d and $t too.
> diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
> index 04e776c..105e3cc 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_mapping_symbol (const char * name)
> + return name != NULL /* Paranoia. */
> + && name == '$' /* 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 == 'a' || name == 'd' || name == 't' || name == 'x')
> + && (name == 0 || name == '.');
> + /* 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_mapping_symbol (sym->name))
> sym->flags |= BSF_KEEP;