[lld] r249254 - [ELF2/AArch64] Add support for AARCH64_ABS{16, 32, 64} relocations.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 11:33:06 PDT 2015


On Mon, Oct 5, 2015 at 11:26 AM, Rui Ueyama <ruiu at google.com> wrote:
> On Sat, Oct 3, 2015 at 5:59 PM, Davide Italiano via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: davide
>> Date: Sat Oct  3 19:59:16 2015
>> New Revision: 249254
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=249254&view=rev
>> Log:
>> [ELF2/AArch64] Add support for AARCH64_ABS{16,32,64} relocations.
>>
>> I saw these in the wild while trying to link shared libraries.
>>
>> Added:
>>     lld/trunk/test/elf2/aarch64-data-relocs.s
>> Modified:
>>     lld/trunk/ELF/Target.cpp
>>
>> Modified: lld/trunk/ELF/Target.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=249254&r1=249253&r2=249254&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/ELF/Target.cpp (original)
>> +++ lld/trunk/ELF/Target.cpp Sat Oct  3 19:59:16 2015
>> @@ -267,6 +267,26 @@ static uint64_t AArch64GetPage(uint64_t
>>    return Expr & (~static_cast<uint64_t>(0xFFF));
>>  }
>>
>> +static void handle_ABS16(uint8_t *Location, uint64_t S, int64_t A) {
>> +  uint64_t X = S + A;
>> +  if (!isInt<16>(X)) // -2^15 <= X < 2^16
>> +    error("Relocation R_AARCH64_ABS16 out of range");
>> +  write16le(Location, read32le(Location) | X);
>> +}
>
>
> This reads 32 bits and writes back 16 bits.
>
>>
>> +
>> +static void handle_ABS32(uint8_t *Location, uint64_t S, int64_t A) {
>> +  uint64_t X = S + A;
>> +  if (!isInt<32>(X)) // -2^31 <= X < 2^32
>> +    error("Relocation R_AARCH64_ABS32 out of range");
>> +  write32le(Location, read32le(Location) | X);
>> +}
>> +
>> +static void handle_ABS64(uint8_t *Location, uint64_t S, int64_t A) {
>> +  uint64_t X = S + A;
>> +  // No overflow check.
>> +  write64le(Location, read32le(Location) | X);
>> +}
>
>
> And this is 32 bits and 64 bits. Are these correct?
>

No, thanks for spotting, it's copy/paste bug.
I'll fix. I'll also write some test that spots the error.


More information about the llvm-commits mailing list