public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlos at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/27220] Migrate away from nested functions
Date: Tue, 12 Apr 2022 17:55:02 +0000	[thread overview]
Message-ID: <bug-27220-131-4R9sl0iZlG@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27220-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27220

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-04-12
             Status|UNCONFIRMED                 |NEW

--- Comment #6 from Carlos O'Donell <carlos at redhat dot com> ---
In glibc 2.35 we committed this change which fixes all sources and avoid nested
functions.

commit 490e6c62aa31a8aa5c4a059f6e646ede121edf0a
Author: Fangrui Song <maskray@google.com>
Date:   Thu Oct 7 11:55:02 2021 -0700

    elf: Avoid nested functions in the loader [BZ #27220]

    dynamic-link.h is included more than once in some elf/ files (rtld.c,
    dl-conflict.c, dl-reloc.c, dl-reloc-static-pie.c) and uses GCC nested
    functions. This harms readability and the nested functions usage
    is the biggest obstacle prevents Clang build (Clang doesn't support GCC
    nested functions).

    The key idea for unnesting is to add extra parameters (struct link_map
    *and struct r_scope_elm *[]) to RESOLVE_MAP,
    ELF_MACHINE_BEFORE_RTLD_RELOC, ELF_DYNAMIC_RELOCATE, elf_machine_rel[a],
    elf_machine_lazy_rel, and elf_machine_runtime_setup. (This is inspired
    by Stan Shebs' ppc64/x86-64 implementation in the
    google/grte/v5-2.27/master which uses mixed extra parameters and static
    variables.)

    Future simplification:
    * If mips elf_machine_runtime_setup no longer needs RESOLVE_GOTSYM,
      elf_machine_runtime_setup can drop the `scope` parameter.
    * If TLSDESC no longer need to be in elf_machine_lazy_rel,
      elf_machine_lazy_rel can drop the `scope` parameter.

    Tested on aarch64, i386, x86-64, powerpc64le, powerpc64, powerpc32,
    sparc64, sparcv9, s390x, s390, hppa, ia64, armhf, alpha, and mips64.
    In addition, tested build-many-glibcs.py with
{arc,csky,microblaze,nios2}-linux-gnu
    and riscv64-linux-gnu-rv64imafdc-lp64d.

    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>


However this is not yet complete because configure sources still have tests
with nested functions that could fail when using clang during configure. So
this is almost complete, but not quite there. Adhemerval is working on full
clang support in the branch azanella/clang which includes the further required
fixes.

The last part required to fix this bug is here (from azanella/clang):
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b4338da21fc709d408ed2bb0f93f082838de0d1c;hp=2116e8544f0e21767dd0c1b9a97f4d4c09a7a68a

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-04-12 17:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-20 19:33 [Bug dynamic-link/27220] New: " i at maskray dot me
2021-01-20 20:04 ` [Bug dynamic-link/27220] " carlos at redhat dot com
2021-01-21 18:23 ` stanshebs at earthlink dot net
2021-01-21 19:39 ` carlos at redhat dot com
2021-01-22 14:21 ` tbaeder at redhat dot com
2021-08-23  4:37 ` i at maskray dot me
2022-04-12 17:55 ` carlos at redhat dot com [this message]
2023-04-13 20:22 ` carlos at redhat dot com
2023-04-13 20:37 ` adhemerval.zanella at linaro dot org
2023-04-13 23:02 ` i at maskray dot me

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=bug-27220-131-4R9sl0iZlG@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.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).