Support dead-stripping in ELF objects

Robinson, Paul Paul_Robinson at playstation.sony.com
Thu Apr 4 15:05:25 PDT 2013


From: Shankar Easwaran [mailto:shankare at codeaurora.org]
> On 4/4/2013 4:51 PM, Robinson, Paul wrote:
> > From: Nick Kledzik [mailto:kledzik at apple.com]
> >>> On Apr 2, 2013, at 6:23 PM, Michael Spencer <bigcheesegs at gmail.com>
> wrote:
> >>>    * If a relocation in this section has a target symbol which is in
> a
> >>> section with this flag set, r_addend must be less than st_size.
> >> I assume you mean the st_size of the target symbol.  But that would
> disallow
> >> valid C code.  You can write:
> >>
> >>        char* x = &foo + 100;
> >> or
> >>        char* y = &foo - 50;
> >>
> >> where 100 > sizeof(foo).
> > Actually this isn't valid C code, computing a pointer that lies
> outside
> > the allocated size of an object/array is undefined.
> > [6.5.6 Additive Operators, p8: If both the pointer
> > operand and the result point to elements of the same array object, or
> one past the last
> > element of the array object, the evaluation shall not produce an
> overflow; otherwise, the
> > behavior is undefined.]
> Why is it not valid, its valid C code which would may/maynot run.

It is syntactically correct but semantically invalid.

> 
> Thanks
> 
> Shankar Easwaran
> 
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by the Linux Foundation






More information about the llvm-commits mailing list