[PATCH] D78741: [LLD][ELF][AVR] Implement the missing relocation types

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 12:47:26 PDT 2020


aykevl added a comment.

I actually wrote a patch very similar to this one (but not implementing as many relocations). It's here: https://gist.github.com/aykevl/ce3c04e1175d9602c9dfaf0cf91298ba
I wanted to hold off on submitting it before the AVR disassembler was a bit more reliable, to make proper tests.

It's heavily documented. Feel free to use it however you wish. I have an inline comment for what I suspect is a bug in this patch.



================
Comment at: lld/ELF/Arch/AVR.cpp:78
+  case R_AVR_16:
+    checkUInt(loc, val, 16, rel);
+    write16le(loc, val);
----------------
The comment I wrote on my patch is the following:

> Note: this relocation is often used between code and data space, which are 0x800000 apart in the output ELF file. The bitmask cuts off the high bit.

I'm not sure when it would trigger, perhaps with debug info. Did you test that?

Also, what does the MEMORY part of your linker script look like? For me it looks like this:

```
MEMORY
{
    FLASH_TEXT (rw) : ORIGIN = 0,                      LENGTH = __flash_size - _bootloader_size
    RAM (xrw)       : ORIGIN = 0x800000 + __ram_start, LENGTH = __ram_size
}
```

In other words, code and data are 0x800000 apart (in the ELF file). This is also the convention followed by the avr-gcc toolchain.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78741/new/

https://reviews.llvm.org/D78741





More information about the llvm-commits mailing list