[PATCH] tile: Fix up corner cases with signed relocations
Rich Felker
dalias@libc.org
Sat Sep 6 01:02:00 GMT 2014
On Fri, Sep 05, 2014 at 11:40:20PM +0200, Andreas Schwab wrote:
> Chris Metcalf <cmetcalf@tilera.com> writes:
>
> > On 9/5/2014 4:33 PM, Andreas Schwab wrote:
> >> Chris Metcalf <cmetcalf@tilera.com> writes:
> >>
> >>> @@ -686,13 +686,17 @@ elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
> >>> tile_bundle_bits *p = (tile_bundle_bits *) reloc_addr;
> >>> tile_bundle_bits bits = *p;
> >>> -#define MUNGE(func) do {
> >>> \
> >>> +#define MUNGE_SIGNED(func, length) do { \
> >>> bits = ((bits & ~create_##func (-1)) | create_##func (value)); \
> >>> - if (get_##func (bits) != value) \
> >>> + ElfW(Addr) result = (long) get_##func (bits) \
> >>> + << (__WORDSIZE - length) >> (__WORDSIZE - length); \
> >> Left shifting a negative value has undefined value.
> >
> > The shift is always a non-negative value less than __WORDSIZE
> > here, by intention. Are you seeing something I'm missing?
>
> I'm talking about the value, not the shift amount.
In general, this issue should always be solvable, in cases where
overflow won't happen, by replacing a<<b with a*(1<<b).
Rich
More information about the Libc-alpha
mailing list