From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 6DDE7385E010 for ; Fri, 28 Jan 2022 21:21:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DDE7385E010 Received: by mail-pj1-x102b.google.com with SMTP id h12so7593328pjq.3 for ; Fri, 28 Jan 2022 13:21:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=288AaPsszBEvzoTIG5P+WGDrZpNOJO1Xr8L5JdbaN+0=; b=hjrf2IPWTyu/7QGuK0ODMkyIsVGbVWpb+Lwyh1K3Wt1giLUYnovpm6wq3pg4O0pScb C/FhXrOr1aEgx3xHp8T1N40kB9pjm66b8K3nRpK3zMgxW2QPK7TzbckOBeldihUc/Dvw YDbqm69BEIAIs+ZlLR7/GmQbabd2DHFjFlUQOvB/06cTNAFeE/pdK/KQnKhsQfShL/TD iZNv3M6qVo7gAomsICzPYxc/aDFtZ3Dwo9HDkVs31wC7UNFr3gNAnZBOKBriEUOiMryl hNUQXIznHHt79wrEoqi5L4gLjDc/VhL27YWgy1dK2il/+9NmJYMv3eKkdbVichBt8AjQ 11kA== X-Gm-Message-State: AOAM532FeclmIulIaL/GpmQPzVo1/hzS+AOtWJ04VvHZRGXmq+fcgoeA 6E5+Cf+AaULAPgAtzTWtfYPPTkmtoBSOtIAb+Lg= X-Google-Smtp-Source: ABdhPJyQkMF2rGUHVBScCpRB4IGnaF6DvTS81lk9iHnXOkiLgg4j9SdbEudk5KWXBp5+sLgjCMzPLZtXQfNtIMNfek4= X-Received: by 2002:a17:902:a708:: with SMTP id w8mr10623090plq.101.1643404881238; Fri, 28 Jan 2022 13:21:21 -0800 (PST) MIME-Version: 1.0 References: <9dff16aac870a046c7cc768eef84bcbd6fd4d65c.camel@mengyan1223.wang> <6f282a6a-c7cb-191a-31ca-1e719824a81f@redhat.com> In-Reply-To: <6f282a6a-c7cb-191a-31ca-1e719824a81f@redhat.com> From: "H.J. Lu" Date: Fri, 28 Jan 2022 13:20:45 -0800 Message-ID: Subject: Re: [PATCH] mips: fix elf/tst-dlmopen4 To: "Carlos O'Donell" Cc: Xi Ruoyao , GNU C Library , syq@debian.org, Jiaxun Yang , Joseph Myers Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3027.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 21:21:24 -0000 On Fri, Jan 28, 2022 at 12:49 PM Carlos O'Donell wrote: > > On 1/28/22 15:41, H.J. Lu wrote: > > On Fri, Jan 28, 2022 at 11:04 AM Carlos O'Donell via Libc-alpha > > wrote: > >> > >> On 1/28/22 13:54, Xi Ruoyao via Libc-alpha wrote: > >>> MIPS uses DT_MIPS_RLD_MAP and DT_MIPS_RLD_MAP_REL instead of DT_DEBUG, > >>> to provide access to r_debug. > >> > >> This looks correct to me. OK for glibc 2.35. > >> > >> I'm going to push this today if there are no other objections. > >> > >> Reviewed-by: Carlos O'Donell > >> > >>> --- > >>> elf/tst-dlmopen4.c | 29 +++++++++++++++++++---------- > >>> 1 file changed, 19 insertions(+), 10 deletions(-) > >>> > >>> diff --git a/elf/tst-dlmopen4.c b/elf/tst-dlmopen4.c > >>> index d8bcf7e9d5..de67a30a4b 100644 > >>> --- a/elf/tst-dlmopen4.c > >>> +++ b/elf/tst-dlmopen4.c > >>> @@ -25,17 +25,26 @@ > >>> #include > >>> #include > >>> > >>> -#ifndef ELF_MACHINE_GET_R_DEBUG > >>> -# define ELF_MACHINE_GET_R_DEBUG(d) \ > >>> - (__extension__ ({ \ > >>> - struct r_debug_extended *debug; \ > >>> - if ((d)->d_tag == DT_DEBUG) \ > >>> - debug = (struct r_debug_extended *) (d)->d_un.d_ptr; \ > >>> - else \ > >>> - debug = NULL; \ > >>> - debug; })) > >>> +static struct r_debug_extended * > >>> +elf_get_r_debug (ElfW(Dyn) *d) > >>> +{ > >>> +#ifdef __mips__ > > > > Shouldn't MIPS simply define a proper ELF_MACHINE_GET_R_DEBUG? > > It can be done with a header file. > > The only use of ELF_MACHINE_GET_R_DEBUG is in the test, and the static function > is easier to read, edit, and debug, all of which is better for a test? I don't think __mips__ should be in generic code. There another place where we need to handle _r_debug differences. A single header file can cover both. > > >>> + if (d->d_tag == DT_MIPS_RLD_MAP_REL) > >>> + { > >>> + char *ptr = (char *) d; > >>> + ptr += d->d_un.d_val; > >>> + return *(struct r_debug_extended **) ptr; > >>> + } > >>> + else if (d->d_tag == DT_MIPS_RLD_MAP) > >>> + return *(struct r_debug_extended **) d->d_un.d_ptr; > >> > >> OK. Matches the logic in sysdeps/mips/dl-debug.h > >> > >>> +#else > >>> + if (d->d_tag == DT_DEBUG) > >>> + return (struct r_debug_extended *) d->d_un.d_ptr; > >> > >> OK. > >> > >>> #endif > >>> > >>> + return NULL; > >> > >> OK. > >> > >>> +} > >>> + > >>> static int > >>> do_test (void) > >>> { > >>> @@ -44,7 +53,7 @@ do_test (void) > >>> > >>> for (d = _DYNAMIC; d->d_tag != DT_NULL; ++d) > >>> { > >>> - debug = ELF_MACHINE_GET_R_DEBUG (d); > >>> + debug = elf_get_r_debug (d); > >> > >> OK. > >> > >>> if (debug != NULL) > >>> break; > >>> } > >> > >> > >> -- > >> Cheers, > >> Carlos. > >> > > > > > > > -- > Cheers, > Carlos. > -- H.J.