[PATCH] D157365: [lld][PPC64] Fix location of the least significant byte when fixing up R_PPC64_ADDR14 for little-endian target
Kai Luo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 8 20:10:43 PDT 2023
lkail added inline comments.
================
Comment at: lld/ELF/Arch/PPC64.cpp:1224
+ uint8_t aalk = loc[config->isLE ? 0 : 3];
+ write16(config->isLE ? loc : loc + 2, (aalk & 3) | (val & 0xfffc));
break;
----------------
lkail wrote:
> nemanjai wrote:
> > Is this backwards? Shouldn't it be offset by 2 bytes for LE?
> We should agree with `aalk` is at `loc[0]` for LE. Then we should also agree with `loc[1]` contains the most significant 8-bits of the intermediate number. `write16(loc, ...)` writes `loc[0]` and `loc[1]` while `write(loc + 2, ...)` writes `loc[2]` and `loc[3]`. IIUC, when it's LE, where we want to write at should be `loc[0]` and `loc[1]`.
Here's an example
```
t_be.o: file format elf64-powerpc
Disassembly of section .text:
0000000000000000 <bca_target>:
0: 4e 80 00 20 blr
0000000000000004 <check_reloc_addr14>:
4: 42 9f 00 02 bca 20, 31, 0
```
```
t_le.o: file format elf64-powerpcle
Disassembly of section .text:
0000000000000000 <bca_target>:
0: 20 00 80 4e blr
0000000000000004 <check_reloc_addr14>:
4: 02 00 9f 42 bca 20, 31, 0
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157365/new/
https://reviews.llvm.org/D157365
More information about the llvm-commits
mailing list