[PATCH] elf: Support DT_RELR relative relocation format [BZ #27924]
Fangrui Song
maskray@google.com
Sat Oct 16 20:22:55 GMT 2021
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>
>>
>
More information about the Libc-alpha
mailing list