This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Another GLIBC build error with GCC6


On Wed, 2015-07-22 at 13:39 -0700, Paul Eggert wrote:
> Steve Ellcey wrote:
> > the macro isn't going to result in the
> > same results for all inputs.
> 
> Why not?  For which input would the patch change behavior?  I don't see how it 
> could happen.  The same pattern already works for DT_VERSIONTAGIDX and for 
> DT_VALTAGIDX, which suggests it shouldn't be a problem for DT_EXTRATAGIDX.

It looks like it works for any value where the most significant bit is
set to 1.  Otherwise it gives a different value.  I don't know if we can
count on that bit always being set or not.

Steve Ellcey



#include <stdint.h>
#include <stdio.h>

typedef uint32_t Elf32_Word;
typedef	int32_t  Elf32_Sword;

#define DT_AUXILIARY    0x7ffffffd
#define DT_FILTER       0x7fffffff

#define DT_EXTRATAGIDX_OLD(tag)    ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
#define DT_EXTRATAGIDX_NEW(tag)    ((Elf32_Sword) (DT_FILTER - (tag)))

inputs[] = {DT_AUXILIARY, DT_FILTER, 0x70000000, 0x70001000, 0x7fffff00,
                0, 1, 99, 100000, -1, -99, -100000};
int main()
{
 int i;
 for (i = 0; i < sizeof(inputs)/sizeof(int); i++)
   printf("%d %d %d\n", inputs[i], DT_EXTRATAGIDX_OLD(inputs[i]), DT_EXTRATAGIDX
_NEW(inputs[i]));
}


% gcc x.c -o x
% ./x
2147483645 2 2
2147483647 0 0
1879048192 268435455 268435455
1879052288 268431359 268431359
2147483392 255 255
0 -1 2147483647
1 -2 2147483646
99 -100 2147483548
100000 -100001 2147383647
-1 0 -2147483648
-99 98 -2147483550
-100000 99999 -2147383649



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]