-
Notifications
You must be signed in to change notification settings - Fork 58
Conversation
docs/LoongArch-ELF-ABI-CN.adoc
Outdated
|67 | ||
|R_LARCH_ABS_HI20 | ||
|32 位绝对地址的[12:31]位 | ||
|`(*(uint32_t *) PC) [24 ... 5] = (S+A) [31 ... 12]+` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does these extra +
mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have modified
docs/LoongArch-ELF-ABI-CN.adoc
Outdated
|
||
|71 | ||
|R_LARCH_PCALA_HI20 | ||
|32位相对PC偏移的[12:31]位 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description seems different than the symbolic definition below. Say PC is 0x0f00 and (S + A) is 0x1000, (((S+A) & ~0xfff) - (PC & ~0xfff)) [31 ... 12]
will be 0x1000 but the PC-relative offset will be 0x0100, and "the [12:31] bits of PC-relative offset" will be zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added additional explanation: "all PC-relative offset calculations do not include the lowest 12 bits".
docs/LoongArch-ELF-ABI-CN.adoc
Outdated
|
||
|100 | ||
|R_LARCH_RELAX | ||
|暂未实现 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if it's not implemented, you should give it a definition. Otherwise you should just leave it undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This relocation is expected to do some optimizations, do or not won't affect correctness.
The linker has implemented some specific instructions, but the assembler still has some support that has not been completed.
If it is deleted, the current version linker can not to link next version object (maybe soon to be patched).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe a simple description like "mark a instruction suitable for link-time relaxation" or something (does @xen0n have a better idea?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if sym - pc >= 0xffe00000 && sym -pc <= 0x1ffffc
can do relax:
pcalau12i $r12, sym
addi.d $r12, $r12, sym
=>
pcaddi $r12, sym
nop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we ignore the debateful naming part, and we don't care "human ego" of reviewers outside Loongson, I don't think we can merge this in status quo. If you allow me to speak candidly: this just seems like a scratch paper where somebody wrote some random thoughts, instead of a formal technical documentation.
docs/LoongArch-ELF-ABI-CN.adoc
Outdated
|72 | ||
|R_LARCH_PCALA_LO12 | ||
|32位相对PC偏移的[0:11]位 | ||
|`(*(uint32_t *) PC) [21 ... 10] = (S+A) [11 ... 0]+` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text description is completely different than the symbolic definition. The symbolic description is exactly same as R_LARCH_ABS_LO12
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you want to use something like:
pcalau12i $t0, %pcala_hi20(something)
ld.d $t0, $t0, %lo12(something)
to load something
, if I interpret @SixWeining's comment in https://reviews.llvm.org/D128427 correctly. Then, (1) you don't need a separate "%pcala_lo12" (it's same as "%abs_lo12" so only one "%lo12" is enough); (2) you need to alter the definition of %pcala_hi20 to account the carry from %lo12 into consideration. Like:
R_LARCH_PCALA_HI20
::= (*(u32 *)PC) [24..5] = (((S+A+0x800) & ~0xfff) - (PC & ~0xfff))[31..12]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R_LARCH_ABS_LO12 and R_LARCH_PCALA_LO12 are calculated in the same way. Only take the lower 12 bits without other operations. In earlier versions it was the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an error and has been modified.
It's better to consistently use [a..b] or [a:b] notion, instead of mixing up Python-style [a:b] notion with Rust-style [a..b] notion. |
|
0056438
to
2800362
Compare
On a related note, what does the "ALA" in "PCALA" mean? I don't think we've seen any full form anywhere for this abbreviation. |
|[31 ... 12] bits of 32/64-bit PC-relative offset | ||
|`+(*(uint32_t *) PC) [24 ... 5] = (((S+A) & ~0xfff) - (PC & ~0xfff)) [31 ... 12]+` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|[31 ... 12] bits of 32/64-bit PC-relative offset | |
|`+(*(uint32_t *) PC) [24 ... 5] = (((S+A) & ~0xfff) - (PC & ~0xfff)) [31 ... 12]+` | |
|[31 ... 12] bits of 32/64-bit PC-relative offset to the nearest 4KB bounary for the target | |
|`+(*(uint32_t *) PC) [24 ... 5] = (((S+A+0x800) & ~0xfff) - (PC & ~0xfff)) [31 ... 12]+` |
For example, S+A = 0x12001800 and PC = 0x12000010. We want:
pcalau12i $t0, 0x2 # 0x2000 >> 12
addi.d $t0, $t0, 0x800 # -2048
to get S+A. Without +0x800
we get pcalau12i $t0, $0x1
then we can't use addi.d
(ori
is needed for a positive offset >= 2048). But the binutils patch uses addi.d
, not ori
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pcalau12i $t0, 0x2 # (S+A+0x800)&(~0xfff) - (PC & (~0xfff))
|79 | ||
|R_LARCH_GOT_HI20 | ||
|GOT 表项 32/64 位绝对地址的 [31 ... 12] 位 | ||
|`+(*(uint32_t *) PC) [24 ... 5] = (GP+G) [31 ... 12]+` | ||
|
||
|80 | ||
|R_LARCH_GOT_LO12 | ||
|GOT 表项 32/64 位绝对地址的 [11 ... 0] 位 | ||
|`+(*(uint32_t *) PC) [21 ... 10] = (GP+G) [11 ... 0]+` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names of 79 and 80 are not the same as in the code, which is correct?
The names in the binutils code are:
R_LARCH_GOT64_HI20 79
R_LARCH_GOT64_LO12 80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@xry111 hasn't approved, why merge? |
See #58 for a fix of "details" for PC-relative relocs. |
gcc-13 has been pretty stable over the weeks I have been using it, so keyword one latest gcc-13 snapshot for wider testing. This should bring the entire loong world to make use of the new-style relocs [1] [2]. Currently the loong kernel cannot be natively built with such a toolchain combination, but a fix is in the works [3]. Because no Gentoo kernel source package has been keyworded ~loong, and the current userbase can be effectively notified in other ways (the Telegram Loongson user group for example), I decided to proceed with the keywording to enable widespread testing of the fresh loong code. The various toolchain projects all cut their releases just recently so we should have plenty of time to polish things before the next big release. [1]: loongson/LoongArch-Documentation#57 [2]: https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=6d13722a97cee3fd397e116bde3bcedbb1e220be;hp=5d471bd907be60e9858b22cdf4fd10ddc0f6ee1a [3]: https://lore.kernel.org/loongarch/CAAhV-H7oQkGVqZV_s7tXjDGBL9yQ+CsUkCv7tC+pWuW2MXe9LA@mail.gmail.com/T/#me74ccdafb0d98d5d13fa2a82356ec5dff1a49a89 Signed-off-by: WANG Xuerui <[email protected]>
LoongArch ELF psABI spec update: loongson/LoongArch-Documentation#57 Corresponding binutils implementation: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=6d13722a97cee3fd397e116bde3bcedbb1e220be https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=9801120721c3a702ce3bd50433ef920f92a83502 For #54222 Change-Id: I51e72294205847a69c01d741a3126248f7a7e41c Reviewed-on: https://go-review.googlesource.com/c/go/+/420982 Reviewed-by: Meng Zhuo <[email protected]> Run-TryBot: Meng Zhuo <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: abner chenc <[email protected]>
|
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xiaotian Wu <[email protected]>
Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xiaotian Wu <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB -------------------------------- These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB -------------------------------- These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Tested-by: WANG Xuerui <[email protected]> Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB -------------------------------- These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
LoongArch inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I5OHOB -------------------------------- These relocation types are used by GNU binutils >= 2.40 and GCC >= 13. Add their definitions so we will be able to use them in later patches. Link: loongson/LoongArch-Documentation#57 Signed-off-by: Xi Ruoyao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
No description provided.