public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Fangrui Song <maskray@google.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: binutils@sourceware.org, libc-alpha@sourceware.org
Subject: Re: [PATCH] elf: Support DT_RELR relative relocation format [BZ #27924]
Date: Sat, 16 Oct 2021 13:22:55 -0700	[thread overview]
Message-ID: <20211016202255.4bvzod7lxso4rny7@google.com> (raw)
In-Reply-To: <3368ef30-eb8c-8828-1af0-1a227d99dc93@suse.com>

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 <support/test-driver.c>
>>
>

  parent reply	other threads:[~2021-10-16 20:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08  6:57 Fangrui Song
2021-10-08 15:39 ` Florian Weimer
2021-10-08 16:36   ` Fangrui Song
2021-10-08 19:41     ` Cary Coutant
2021-10-08 16:51 ` H.J. Lu
2021-10-08 17:37   ` Fangrui Song
2021-10-08 17:43     ` H.J. Lu
2021-10-08 18:46       ` Fangrui Song
2021-10-11  7:48 ` Jan Beulich
2021-10-11 18:43   ` Fāng-ruì Sòng
2021-10-11 22:08     ` Joseph Myers
2021-10-12  8:14       ` Jan Beulich
2021-10-12  8:18     ` Jan Beulich
2021-10-12 14:09       ` H.J. Lu
2021-10-12 16:07         ` Fāng-ruì Sòng
2021-10-13  6:00           ` Jan Beulich
2021-10-13  6:13             ` Fāng-ruì Sòng
2021-10-13  6:18               ` Fāng-ruì Sòng
2021-10-18  7:59                 ` Jan Beulich
2021-10-16 20:22   ` Fangrui Song [this message]
2021-10-26 23:28   ` Cary Coutant
2021-10-11 21:47 ` Joseph Myers

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=20211016202255.4bvzod7lxso4rny7@google.com \
    --to=maskray@google.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=libc-alpha@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).