[lld] r288581 - [ELF] - Implemented R_386_16 and R_386PC16 relocations

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 05:50:18 PST 2016


Rafael Avila de Espindola <rafael.espindola at gmail.com> writes:

> George Rimar <grimar at accesssoftek.com> writes:
>> Then logic implemented in the patch will work anyways as it truncates
>> the output to 16 bits.
>>
>> At least that was my logic when I implemented that. Was I wrong ?
>
> I think it is still wrong. I will try to write a testcase.

So, given 2 complement and the fact the x86 is little endian it does
look like the current code produces the right result, but it is fairly
confusing. When given

.short foo
.short 0xffff

it will report having and addend of 0xffff0000. I guess it is still
theoretically incorrect if the section is at the very end of the file as
that will read pass the end.

Would you mind changing the code to read only 16 bits for 16 bit
relocations? It would make it a lot easier to understand.

Cheers,
Rafael


More information about the llvm-commits mailing list