This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Do sign extend for addends of R_386_8, R_386_16 relocations
ClosedPublic

Authored by grimar on Feb 8 2017, 4:50 AM.

Details

Summary

The same we did earlier for PC ones,
currenly LLD fails to link kernel, reporting relocation out of range because of this.

I prepared separate test, because had to involve -Ttext option and
that would change currect pc8/pc16 test significantly , what probably not worth to do.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Feb 8 2017, 4:50 AM
ruiu edited edge metadata.Feb 8 2017, 12:02 PM

Maybe we need to sign extend everything? In other words, is there any relocation that we shouldn't sign extend?

In D29714#671060, @ruiu wrote:

Maybe we need to sign extend everything? In other words, is there any relocation that we shouldn't sign extend?

From my understanding we should extend only relocations that have addend value shorter than target size.

I mean we return 64 bit value from getImplicitAddend(), it is then assigned to uintX_t. So for i386 case for example we want to extend all relocations that are not reading 32 bits,
as anyways value is truncated later.
So I believe, for i386 this patch is all what else needed for it's relocations, all other ones are working with 32 bits already.

grimar added a comment.Feb 9 2017, 1:00 AM
In D29714#671060, @ruiu wrote:

Maybe we need to sign extend everything? In other words, is there any relocation that we shouldn't sign extend?

So just to be clear - we sure can extend everything, but there is no point to do that, its excessive job, so I would probably extend only "short" addends.

tpimh added a subscriber: tpimh.Feb 9 2017, 1:32 AM
This revision was automatically updated to reflect the committed changes.