From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id D626B3858C60 for ; Sat, 16 Oct 2021 20:23:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D626B3858C60 Received: by mail-pl1-x631.google.com with SMTP id n11so8607104plf.4 for ; Sat, 16 Oct 2021 13:23:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ScNSbWSlkeyXeFEA9vUcxAdNnzjQV5CUWJED/Ds0jQM=; b=LKqu4VM8we4+2uq5yQSlloJiYlSOTv0OtIL04+/vgfbsKHscws9NbPhrd/EODXhaLn 9hYwmdkZVMODCfGAhjUae/X9VsS/Z8T667oU/TI+i7TdYbk4PIgdM0leutmaxIDKht1O gtPg/k0uYXCVtQ8Z+XyjuueUDOPQctyJs1nzevmdPgwYlL7pVPa8Du/UQVvqZ0rwrZ01 1pojrUx8l2WYkwHgdboN1/wGTdHeOKTAJFwU0jp7qDjrGqPouKqfR/tqw7t+9V5MI23o nvAowLbZYLJiO2HPrBCFhU1Z+7fWHN/P+bnmQJ+zId5ER8ZuLw8H/vKFasW/XybB+2+o T6TQ== X-Gm-Message-State: AOAM532HsheC+c8l/Egr/3CWNo2f7e6SbeAajHOLl0GrJYoc1EJmG+0h 9VaMLAYnZVE81gwsQxcDzAqMDm9k7OLzcQ== X-Google-Smtp-Source: ABdhPJxz+Nu7+pfK77MaJSh3gndC1pYPUUXjprrX8N7JMzpaNl5beK8867HhJS9rpw4wepzo/Ug8Ag== X-Received: by 2002:a17:90a:f415:: with SMTP id ch21mr36060590pjb.235.1634415779402; Sat, 16 Oct 2021 13:22:59 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:1d42:3a53:f2e6:ae05]) by smtp.gmail.com with ESMTPSA id s8sm8184319pfh.186.2021.10.16.13.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Oct 2021 13:22:59 -0700 (PDT) Date: Sat, 16 Oct 2021 13:22:55 -0700 From: Fangrui Song To: Jan Beulich Cc: binutils@sourceware.org, libc-alpha@sourceware.org Subject: Re: [PATCH] elf: Support DT_RELR relative relocation format [BZ #27924] Message-ID: <20211016202255.4bvzod7lxso4rny7@google.com> References: <20211008065740.1485737-1-maskray@google.com> <3368ef30-eb8c-8828-1af0-1a227d99dc93@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <3368ef30-eb8c-8828-1af0-1a227d99dc93@suse.com> X-Spam-Status: No, score=-18.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable 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: Sat, 16 Oct 2021 20:23:02 -0000 On 2021-10-11, Jan Beulich wrote: >On 08.10.2021 08:57, Fangrui Song via Binutils wrote: >> --- /dev/null >> +++ b/elf/tst-relr.c >> @@ -0,0 +1,20 @@ >> +static int o, x; >> +void *arr[] = { >> + &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, &o, >> + 0, >> + &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, &x, >> +}; > >Personally I consider this overly simplistic a testcase. The two >sequences are fully identical, have no gaps except for the one in >the middle, and there's also no interleaving / mixing of pointers. >None of this should matter as the specific symbol the relocation >is for is not supposed to be of interest, but in a testcase you >want to make sure none of this has an effect. > >I also wonder whether it is a good idea to have a testcase with >"fundamentally" different behavior on 32-bit vs 64-bit: The former >will require two RELR entries afaict, while the latter will get >away with one here. > >Jan In https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/maskray/relr I enhanced the test to this form: #define ELEMS O O O O O O O O X X X X X X X O O X O O X X X E X E E O X O E #define E 0, #define O &o, #define X &x, void *arr[] = { ELEMS }; #undef O #undef X #define O 1, #define X 2, static char val[] = { ELEMS }; static int do_test (void) { for (int i = 0; i < sizeof (arr) / sizeof (arr[0]); i++) if (!((arr[i] == 0 && val[i] == 0) || (arr[i] == &o && val[i] == 1) || (arr[i] == &x && val[i] == 2))) return 1; return 0; } >> +static int >> +do_test (void) >> +{ >> + for (int i = 0; i < 16; i++) >> + if (arr[i] != &o) >> + return 1; >> + for (int i = 17; i < 33; i++) >> + if (arr[i] != &x) >> + return 1; >> + return 0; >> +} >> + >> +#include >> >