From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id B724E3857C44; Tue, 7 Sep 2021 15:18:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B724E3857C44 Received: by mail-pj1-x1036.google.com with SMTP id gp20-20020a17090adf1400b00196b761920aso2334859pjb.3; Tue, 07 Sep 2021 08:18:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vKt9dIgN5Y6tqFN3nUWgbmItHoeobrpC4seGhDKnb3Q=; b=G6efaRincDp2X86mTvSNI49PrphVExLtLbzlvSbzOeAgwx4jQdD9O615g55/cqeusk QFeSFQ49jMoPtFyeEgDqf0W4rKMTxgh67WQqXnPen1Zzzl1TVtcohw2z3fAhRZydu/FB EyL4GuJUvaPOhfQKu60IKUSI6kg1UVc9iN9fTyXvUQiAndhhedndvk0tlg0pCIhWkgLf nLDTngKaIC+1hcwwSFS7g4AHh4tKKm+88AcYInV2P+mz2euDS2TwfySG47wrH7UGBfK4 srSDS5iKAm4KYS0sSPmDAW64RamC6woT5npCKEhXqNw/iyZT6+e4FQpBimQjRnSEGvl8 /fvg== X-Gm-Message-State: AOAM5310IdfpF8JL8e6j5QuB2nyAJ591aN8LP/oG3ZzsHgHv5xp+GGdB j0SwleaG+XDB0cV/hwnmjQN+gTSsCfnLgW8AC+k= X-Google-Smtp-Source: ABdhPJwPncTJTfSlbWfHxTEHPHdgCxjBrTz0+mGhOiGMMgWLi7p3+czNYgIb7D3LzLAmuGhfGk7RsYRGpe/MXsOUSzk= X-Received: by 2002:a17:902:82c1:b0:135:b97d:8e84 with SMTP id u1-20020a17090282c100b00135b97d8e84mr15070732plz.85.1631027919887; Tue, 07 Sep 2021 08:18:39 -0700 (PDT) MIME-Version: 1.0 References: <20210830173844.458727-1-hjl.tools@gmail.com> <20210830173844.458727-3-hjl.tools@gmail.com> <874kay11s3.fsf@oldenburg.str.redhat.com> <87o895ye7k.fsf@oldenburg.str.redhat.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 7 Sep 2021 08:18:04 -0700 Message-ID: Subject: Re: [PATCH v6 2/2] Extend struct r_debug to support multiple namespaces To: Florian Weimer Cc: GNU C Library , GDB , libc-coord@lists.openwall.com, Daniel Walker Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3024.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Sep 2021 15:18:43 -0000 On Mon, Sep 6, 2021 at 7:31 AM H.J. Lu wrote: > > On Mon, Sep 6, 2021 at 7:24 AM Florian Weimer wrote: > > > > * H. J. Lu: > > > > > On Mon, Sep 6, 2021 at 2:39 AM Florian Weimer wrote: > > >> > > >> * H. J. Lu: > > >> > > >> > +* The r_version update in the debugger interface makes the glibc binary > > >> > + incompatible with GDB binaries built without the following commits: > > >> > + > > >> > + c0154a4a21a gdb: Don't assume r_ldsomap when r_version > 1 on Linux > > >> > + 4eb629d50d4 gdbserver: Check r_version < 1 for Linux debugger interface > > >> > > >> Does this incompatibility happen even if audit modules and dlmopen are > > >> not used? > > > > > > Yes. > > > > Why? Can't we keep r_version at 1 in this case? > > r_version is checked in GDB whenever DT_DEBUG is used to access > the rtld debug interface, independent of audit modules and dlmopen. > > We can bump r_version only if a non-default namespace is used. Fixed. > > >> This puts the assember output from the compiler through the > > >> preprocessor. That seems to be brittle. I think you would have to > > >> preprocess the manually written fragment separately. > > >> > > >> However, I think we are overdesigning things here. The following in > > >> dl-debug-symbols-gen.c should work (and the file should have a different > > >> name then): > > >> > > >> /* Alias _r_debug to a prefix of _r_debug_extended. */ > > >> asm (".set _r_debug, _r_debug_extended\n\t" > > >> ".type _r_debug, %object\n\t" > > >> ".symver _r_debug_extended, _r_debug@@" FIRST_VERSION_ld__r_debug_STRING); > > >> #if __WORDSIZE == 64 > > >> _Static_assert (sizeof (struct r_debug) == 40, "sizeof (struct r_debug)"); > > >> asm (".size _r_debug, 40"); > > >> #else > > >> _Static_assert (sizeof (struct r_debug) == 20, "sizeof (struct r_debug)"); > > >> asm (".size _r_debug, 20"); > > >> #endif > > >> > > >> It's not exactly pretty, but at least it's obvious what is going on. > > >> (Extended asm with input operands is not supported outside of functions.) > > > > > > This was the first thing I tried and it didn't work: > > > > > > [hjl@gnu-cfl-2 tmp]$ cat foo.s > > > .set _r_debug, _r_debug_extended > > > .globl _r_debug > > > .type _r_debug, %object > > > .size _r_debug, 40 > > > .data > > > .type _r_debug_extended, %object > > > .size _r_debug_extended, 48 > > > .globl _r_debug_extended > > > _r_debug_extended: > > > .zero 48 > > > [hjl@gnu-cfl-2 tmp]$ gcc -c foo.s > > > [hjl@gnu-cfl-2 tmp]$ readelf -sW foo.o | grep _r_debug > > > 1: 0000000000000000 48 OBJECT GLOBAL DEFAULT 2 _r_debug > > > 2: 0000000000000000 48 OBJECT GLOBAL DEFAULT 2 _r_debug_extended > > > [hjl@gnu-cfl-2 tmp]$ > > > > Huh. Does this mean this depends on the symbol definition order in the > > assembler file? > > > > I really hate the post-processing of compiler output. This isn't GHC. 8-> > > > > Can we write a portable assembler file instead? > > > > Nick Clifton has written down some guidelines: > > > > Tips for writing portable assembler with GNU Assembler (GAS) > > > > > > There's no initializer, so all we need to know is size and alignment. > > Yes, I can do that. Fixed. > > >> Is this necessary? It makes concurrent access to the list harder and > > > > > > When _dl_close_worker is called, it holds GL(dl_load_lock). Why does > > > this change make concurrent access harder? > > > > Something else might want to read the list directly, by starting with > > DT_DEBUG. > > I can add _dl_debug_get and use _dl_debug_initialize only for initialization. > Will it work? > I submitted the v7 patch with: 1. Rewrite dl-debug-symbols.S and remove dl-debug-compat-symbols.c. 2. Bump r_version to 2 only when multiple namespaces are used. 3. Verify r_version == 1 without multiple namespaces. 4. Keep the empty (unused) namespace on the namespace linked list. 5. Use atomic_store_release to update r_version and r_next. 6. Add _dl_debug_update without adding the namespace to the namespace linked list. -- H.J.