unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: nd <nd@arm.com>, "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>
Subject: Re: [PATCH glibc 2/2] aarch64: handle STO_AARCH64_VARIANT_PCS
Date: Tue, 4 Jun 2019 11:39:03 +0000	[thread overview]
Message-ID: <2d825839-e919-9b4c-dab7-8882bf8ff54e@arm.com> (raw)
In-Reply-To: <1330a818-213a-13a9-3a33-48933cc22c6a@arm.com>

On 23/05/2019 13:31, Szabolcs Nagy wrote:
> On 23/05/2019 12:35, Florian Weimer wrote:
>> * Szabolcs Nagy:
>>
>>>    /* Check for unexpected PLT reloc type.  */
>>>    if (__builtin_expect (r_type == AARCH64_R(JUMP_SLOT), 1))
>>>      {
>>> -      if (__builtin_expect (map->l_mach.plt, 0) == 0)
>>> -	*reloc_addr += l_addr;
>>> -      else
>>> -	*reloc_addr = map->l_mach.plt;
>>> +      if (map->l_mach.plt == 0)
>>> +	{
>>> +	  /* Prelinking.  */
>>> +	  *reloc_addr += l_addr;
>>> +	  return;
>>> +	}
>>> +
>>> +      if (__glibc_unlikely (map->l_mach.variant_pcs))
>>> +	{
>>> +	  /* Check the symbol table for variant PCS symbols.  */
>>> +	  const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info);
>>> +	  const ElfW (Sym) *symtab =
>>> +	    (const void *)D_PTR (map, l_info[DT_SYMTAB]);
>>> +	  const ElfW (Sym) *sym = &symtab[symndx];
>>> +	  if (__glibc_unlikely (sym->st_other & STO_AARCH64_VARIANT_PCS))
>>> +	    {
>>> +	      /* Avoid lazy resolution of variant PCS symbols.  */
>>> +	      const struct r_found_version *version = NULL;
>>> +	      if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
>>> +		{
>>> +		  const ElfW (Half) *vernum =
>>> +		    (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
>>> +		  version = &map->l_versions[vernum[symndx] & 0x7fff];
>>> +		}
>>> +	      elf_machine_rela (map, reloc, sym, version, reloc_addr,
>>> +				skip_ifunc);
>>> +	      return;
>>> +	    }
>>> +	}
>>> +
>>> +      *reloc_addr = map->l_mach.plt;
>>
>> Looking at this, I wonder if it would be more natural to handle this as
>> a new relocation type.  This way, you will get an error from old dynamic
>> linkers.
> 
> yes, but that's a more intrusive change.

to expand a bit: i want old dynamic linkers to
continue to work if they do not use lazy binding.

currently only glibc supports lazy binding as far as
i can tell and even there you can force it to be off
(in which case a new binary with variant pcs calls works
with an old dyn linker).

unfortunately i don't see an easy way to error out in
an old dynamic linker just in case of lazy binding.

a new dyn reloc seems to be more in spirit of the elf
spec and means nicer code (the reloc type is enough
instead of using the reloc sym index to check the symtab),
but i think that is not good enough argument to break
bw compat.

i think the abi can be still changed if it is important to
error out when variant pcs calls are not supported, but
that means it's impossible to run new code on an old system
even with adequate workarounds in place (-Wl,-z,now linking
or no lazy binding support in libc).

do you see other problems with not using a separate dyn reloc?

> 
> R_*_JUMP_SLOT is handled specially at various places
> which require changes if we introduce a new dynamic
> reloc.
> 
> the symbol marking is still required: static linker
> needs to know which symbols are special (could be
> done with static relocations, but then almost all
> relocations would need a 'variant pcs' alternative
> which is a lot of changes in static linkers)
> 
> so it seemed that DT_ tag + st_other marking is
> minimally intrusive and sufficient, but i agree
> that and R_* dynamic reloc + st_other marking
> would be another feasible option (i didnt prototype
> that so i cant tell how much more work that is).
> 


  reply	other threads:[~2019-06-04 11:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 11:17 [PATCH glibc 0/2] aarch64: add STO_AARCH64_VARIANT_PCS support Szabolcs Nagy
2019-05-23 11:19 ` [PATCH glibc 1/2] aarch64: add STO_AARCH64_VARIANT_PCS and DT_AARCH64_VARIANT_PCS Szabolcs Nagy
2019-06-03 15:29   ` Szabolcs Nagy
2019-06-03 17:26     ` Florian Weimer
2019-05-23 11:21 ` [PATCH glibc 2/2] aarch64: handle STO_AARCH64_VARIANT_PCS Szabolcs Nagy
2019-05-23 11:35   ` Florian Weimer
2019-05-23 12:31     ` Szabolcs Nagy
2019-06-04 11:39       ` Szabolcs Nagy [this message]
2019-06-04 17:17         ` Szabolcs Nagy
2019-06-05 14:41           ` Szabolcs Nagy
2019-06-06  8:56             ` Szabolcs Nagy
2019-06-07 11:54               ` Szabolcs Nagy
2019-06-11 10:31                 ` Szabolcs Nagy
2019-06-11 21:15                 ` Florian Weimer
2019-06-12  9:50                   ` Szabolcs Nagy
2019-06-14 17:09                     ` Florian Weimer
2019-05-23 11:21 ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2d825839-e919-9b4c-dab7-8882bf8ff54e@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).