Support dead-stripping in ELF objects

Robinson, Paul Paul_Robinson at playstation.sony.com
Thu Apr 4 14:51:56 PDT 2013


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.]

But if you do write this code, it will produce a relocation that violates 
the requirements that Michael stated, and my patch doesn't check for that.
Hmmmm.
I'll have to check with my linker people to see what they think.

--paulr

P.S. I am also reading the other replies, but not ready to say anything
quite yet.






More information about the llvm-commits mailing list