Message ID | 1429608058.1938.53.camel@bordewijk.wildebeest.org |
---|---|
State | New |
Headers | show |
On 04/21/2015 11:20 AM, Mark Wielaard wrote: > -#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless > +#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless I think the safer change is to use -0x80000000 as the value of the constant, without making it unsigned. Otherwise my previous objections apply. I'm sorry it has come to this, I can empathize with your struggles to get patches applied to glibc.
Florian Weimer <fweimer@redhat.com> writes: > I think the safer change is to use -0x80000000 as the value of the > constant, without making it unsigned. -0x80000000 has unsigned type. Andreas.
On 04/22/2015 10:25 AM, Andreas Schwab wrote: > Florian Weimer <fweimer@redhat.com> writes: > >> I think the safer change is to use -0x80000000 as the value of the >> constant, without making it unsigned. > > -0x80000000 has unsigned type. Ugh. The joys of C. Using a cast would rely on a GCC extension, so one has to write (-2147483647 - 1) to get the desired value. Wow.
On 2015-04-22 11:33, Florian Weimer wrote: > On 04/22/2015 10:25 AM, Andreas Schwab wrote: >> Florian Weimer <fweimer@redhat.com> writes: >> >>> I think the safer change is to use -0x80000000 as the value of the >>> constant, without making it unsigned. >> >> -0x80000000 has unsigned type. > > Ugh. The joys of C. > > Using a cast would rely on a GCC extension, so one has to write > (-2147483647 - 1) to get the desired value. Wow. Given that stdint.h is already included it's perhaps easier to just use INT32_MIN? I've replied about it and other issues in the previous thread but I'm afraid I'm lost all Cc there. Here it is: https://sourceware.org/ml/libc-alpha/2015-04/msg00257.html
On Wed, 2015-04-22 at 10:33 +0200, Florian Weimer wrote: > On 04/22/2015 10:25 AM, Andreas Schwab wrote: > > Florian Weimer <fweimer@redhat.com> writes: > > > >> I think the safer change is to use -0x80000000 as the value of the > >> constant, without making it unsigned. > > > > -0x80000000 has unsigned type. > > Ugh. The joys of C. > > Using a cast would rely on a GCC extension, so one has to write > (-2147483647 - 1) to get the desired value. Wow. What is your objection to having the constant unsigned? Note that other ELF based systems like android or bsd just define the constant as 0x80000000 (with or without UL). And the other SHF_ constants are also defined with their 0x... values in gABI. They are flag values you combine with | or mask with &, not compare directly. If you objection is that it isn't consistent with the other flag value defines then my other proposal was to just define all these SHF constants with their hex value: https://sourceware.org/ml/libc-alpha/2015-03/msg00793.html Cheers, Mark
On 04/22/2015 10:14 AM, Florian Weimer wrote: > On 04/21/2015 11:20 AM, Mark Wielaard wrote: >> -#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless >> +#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless > > I think the safer change is to use -0x80000000 as the value of the > constant, without making it unsigned. Otherwise my previous objections > apply. I thought some more about this, and have changed my opinion completely. Making the constant unsigned is less risky than making it negative because of potential sign extension issues. It's the lesser of two evils. The proposed patch is okay with me.
diff --git a/elf/elf.h b/elf/elf.h index 496f08d..960a3c3 100644 --- a/elf/elf.h +++ b/elf/elf.h @@ -371,7 +371,7 @@ typedef struct #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ #define SHF_ORDERED (1 << 30) /* Special ordering requirement (Solaris). */ -#define SHF_EXCLUDE (1 << 31) /* Section is excluded unless +#define SHF_EXCLUDE (1U << 31) /* Section is excluded unless referenced or allocated (Solaris).*/ /* Section group handling. */