From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Fangrui Song <maskray@google.com>,
libc-alpha@sourceware.org, Andreas Schwab <schwab@linux-m68k.org>
Subject: Re: [PATCH] m68k: Handle fewer relocations for RTLD_BOOTSTRAP (#BZ29071)
Date: Wed, 20 Apr 2022 13:47:51 -0300 [thread overview]
Message-ID: <fc07cc25-0248-d04c-5683-0f3add54245a@linaro.org> (raw)
In-Reply-To: <20220420023532.367055-1-maskray@google.com>
On 19/04/2022 23:35, Fangrui Song wrote:
> m68k is a non-PI_STATIC_AND_HIDDEN arch which uses a GOT relocation when
> loading a jump table. The GOT load may be reordered before processing
> R_68K_RELATIVE relocations, leading to an unrelocated/incorrect jump
> table. The foolproof approach is to add an optimization barrier (e.g.
> calling a function after relative relocations are resolved). That isn't
> suitable given the current code structure, so just use the simple
> approach to avoid the jump table: handle only the essential reloctions
> for RTLD_BOOTSTRAP code.
>
> This is based on Andreas Schwab's patch and fixed ld.so crash on m68k.
LGTM, thanks. The loader does not triggers a segfault anymore.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> sysdeps/m68k/dl-machine.h | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/sysdeps/m68k/dl-machine.h b/sysdeps/m68k/dl-machine.h
> index c44ab055aa..bb51b4198c 100644
> --- a/sysdeps/m68k/dl-machine.h
> +++ b/sysdeps/m68k/dl-machine.h
> @@ -234,6 +234,11 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
>
> switch (r_type)
> {
> + case R_68K_GLOB_DAT:
> + case R_68K_JMP_SLOT:
> + *reloc_addr = value;
> + break;
> +#ifndef RTLD_BOOTSTRAP
> case R_68K_COPY:
> if (sym == NULL)
> /* This can happen in trace mode if an object could not be
> @@ -252,10 +257,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
> memcpy (reloc_addr_arg, (void *) value,
> MIN (sym->st_size, refsym->st_size));
> break;
> - case R_68K_GLOB_DAT:
> - case R_68K_JMP_SLOT:
> - *reloc_addr = value;
> - break;
> case R_68K_8:
> *(char *) reloc_addr = value + reloc->r_addend;
> break;
> @@ -276,7 +277,6 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
> case R_68K_PC32:
> *reloc_addr = value + reloc->r_addend - (Elf32_Addr) reloc_addr;
> break;
> -#ifndef RTLD_BOOTSTRAP
> case R_68K_TLS_DTPMOD32:
> /* Get the information from the link map returned by the
> resolv function. */
> @@ -294,9 +294,9 @@ elf_machine_rela (struct link_map *map, struct r_scope_elem *scope[],
> *reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc);
> }
> break;
> -#endif /* !RTLD_BOOTSTRAP */
> case R_68K_NONE: /* Alright, Wilbur. */
> break;
> +#endif /* !RTLD_BOOTSTRAP */
> default:
> _dl_reloc_bad_type (map, r_type, 0);
> break;
prev parent reply other threads:[~2022-04-20 16:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 2:35 Fangrui Song
2022-04-20 16:47 ` Adhemerval Zanella [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fc07cc25-0248-d04c-5683-0f3add54245a@linaro.org \
--to=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
--cc=maskray@google.com \
--cc=schwab@linux-m68k.org \
/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).