public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: WANG Xuerui <i.swmail@xen0n.name>
To: Xi Ruoyao <xry111@xry111.site>, WANG Xuerui <i.swmail@xen0n.name>,
	liuzhensong <liuzhensong@loongson.cn>,
	binutils@sourceware.org
Cc: xuchenghua@loongson.cn, mengqinggang@loongson.cn,
	Fangrui Song <maskray@google.com>
Subject: Re: [PATCH 1/5 v1] LoongArch: bfd: Add new reloc types.
Date: Mon, 18 Jul 2022 20:11:27 +0800	[thread overview]
Message-ID: <417f93f5-64ca-9eb1-c338-b55edfd8eb83@xen0n.name> (raw)
In-Reply-To: <62de74c5cfc7e558f82025ccffe5547d58bff172.camel@xry111.site>

On 2022/7/18 19:33, Xi Ruoyao wrote:
> On Mon, 2022-07-18 at 18:06 +0800, WANG Xuerui wrote:
>> (Adding Ruoyao and MaskRay to CC, who might be interested in this
>> development as well, as it concerns the linker implementation.)
> I've already subscribed binutils@sourceware.org in order not to be
> passed by.
>
>> I think I've voiced my concerns over the naming of these ops multiple
>> times already; the primary comment ([1]; in English) was posted back in
>> May but no one in your team responded.
>>
>> Reproducing the content (and adjusting a little) here:
>>
>>
>> Overall in a good direction (and IMHO the direction everyone should have
>> taken in the first place), thanks!
>>
> Yes, we've been paying additional costs using those "stack based
> relocation".  I'd like to know why they were proposed in first place?
> (Not accusing anyone, just my curiosity: AFAIK no other targets ever
> used such a stack for relocation.)
As previously pointed out on this list, rx and rl78 both use stack-based 
relocs. (Both come from Renesas, so I do think it's delibrate design 
decision, but of course the original Renesas justification is most 
probably buried in history.) I explained this in 
https://github.com/loongson/binutils-gdb/issues/134 before.
>
> /* snip */
>
>
>> FYI, I did make a list of my suggested names for these reloc types
>> ("BFD_RELOC_LARCH_" abbreviated to "B_R_L_"):
>>
>> Original name           Suggested name
>> -------------           --------------
>> B_R_L_B16               B_R_L_PCREL_SK16 *1
>> B_R_L_B21               B_R_L_PCREL_SD5K16
>> B_R_L_B26               B_R_L_PCREL_SD10K16
>> B_R_L_ABS_LO12          B_R_L_ABS_0_SK12
>> B_R_L_ABS_HI20          B_R_L_ABS_12_SJ20
>> B_R_L_ABS64_LO20        B_R_L_ABS_32_SJ20
>> B_R_L_ABS64_HI12        B_R_L_ABS_52_SK12
>> B_R_L_PCALA_LO12        B_R_L_PCALA_0_SK12 *2
>> B_R_L_PCALA_HI20        B_R_L_PCALA_12_SJ20
>> B_R_L_PCALA64_LO20      B_R_L_PCALA_32_SJ20 *3
>> B_R_L_PCALA64_HI12      B_R_L_PCALA_52_SK12
>> B_R_L_GOT_PC_LO12       B_R_L_GOT_PCALA_0_SK12 *4
>> B_R_L_GOT_PC_HI20       B_R_L_GOT_PCALA_12_SJ20
>> B_R_L_GOT64_PC_LO20     B_R_L_GOT_PCALA_32_SJ20
>> B_R_L_GOT64_PC_HI12     B_R_L_GOT_PCALA_52_SK12
>> B_R_L_GOT64_LO12        B_R_L_GOT_ABS_0_SK12 *5
>> B_R_L_GOT64_HI20        B_R_L_GOT_ABS_12_SJ20
>> B_R_L_GOT64_LO20        B_R_L_GOT_ABS_32_SJ20
>> B_R_L_GOT64_HI12        B_R_L_GOT_ABS_52_SK12
>> B_R_L_TLS_LE_LO12       B_R_L_TLS_LE_ABS_0_SK12
>> B_R_L_TLS_LE_HI20       B_R_L_TLS_LE_ABS_12_SJ20
>> B_R_L_TLS_LE64_LO20     B_R_L_TLS_LE_ABS_32_SJ20
>> B_R_L_TLS_LE64_HI12     B_R_L_TLS_LE_ABS_52_SK12
>> B_R_L_TLS_IE_PC_LO12    B_R_L_TLS_IE_PCALA_0_SK12
>> B_R_L_TLS_IE_PC_HI20    B_R_L_TLS_IE_PCALA_12_SJ20
>> B_R_L_TLS_IE64_PC_LO20  B_R_L_TLS_IE_PCALA_32_SJ20
>> B_R_L_TLS_IE64_PC_HI12  B_R_L_TLS_IE_PCALA_52_SK12
>> B_R_L_TLS_IE64_LO12     B_R_L_TLS_IE_ABS_0_SK12
>> B_R_L_TLS_IE64_HI20     B_R_L_TLS_IE_ABS_12_SJ20
>> B_R_L_TLS_IE64_LO20     B_R_L_TLS_IE_ABS_32_SJ20
>> B_R_L_TLS_IE64_HI12     B_R_L_TLS_IE_ABS_52_SK12
>> B_R_L_TLS_LD_PC_HI20    B_R_L_TLS_LD_PCALA_12_SJ20 *6
>> B_R_L_TLS_LD64_HI20     B_R_L_TLS_LD_ABS_12_SJ20
>> B_R_L_TLS_GD_PC_HI20    B_R_L_TLS_GD_PCALA_12_SJ20
>> B_R_L_TLS_GD64_HI20     B_R_L_TLS_GD_ABS_12_SJ20
> It's overall better, but those "J, K" etc are cryptic IMHO.  And for
> "B_R_L_B16" I think "B_R_L_PCREL_SK16" fails to express that the offset
> should be shifted right by 2, so I'd keep B_R_L_B16 (and similarly,
> B_R_L_B21 and B_R_L_B26) like the PCALA case.
>
The slot names come from 
https://github.com/loongson/LoongArch-Documentation/pull/56 (to 
non-Chinese speakers: English translation still TODO, but hopefully at 
least the ABNF and the few tables should be intelligible even without 
translation).

As for the PCREL and implicit shifts, maybe a planned extension of the 
slot syntax could help. I plan to submit an Assembly Language Convention 
after the Instruction Format Convention gets reviewed and merged, and 
with this new convention such an extension is necessary anyway for 
accommodating the current assembly syntax as described by the ISA 
manual, able to express the <<2's and +1's for the PC-manipulating and 
ALSL insns.

For example, let's say the extension works like this: ordinary slot 
syntax, plus "p", plus an postprocess operator, with "s\d+" for "imm 
slot = assembly operand >> N", and "p\d+" for "imm slot = assembly 
operand + N". Then we could say "B_R_L_PCREL_SK16PS2" and have all the 
niceties. (In an ideal world, the LoongArch opcodes implementation 
should be modified to use this convention too, so for example it will be 
something like "DJSk16ps2" for JIRL, "JDSk16ps2" for BLT (notice the 
reversed operand order) and "DJKUa2pp1" for ALSL insns.


  reply	other threads:[~2022-07-18 12:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18  8:43 liuzhensong
2022-07-18  8:43 ` [PATCH 2/5 v1] LoongArch:opcodes: " liuzhensong
2022-07-18  8:43 ` [PATCH 3/5 v1] LoongArch: gas: " liuzhensong
2022-07-18  8:43 ` [PATCH 4/5 v1] LoongArch: Move ifunc info to rela.dyn from rela.plt liuzhensong
2022-07-18 11:45   ` Xi Ruoyao
2022-07-18 16:27   ` Xi Ruoyao
2022-07-19  7:26     ` liuzhensong
2022-07-18  8:43 ` [PATCH 5/5 v1] LoongArch: Delete R_LARCH_NONE from dynamic info liuzhensong
2022-07-18 10:06 ` [PATCH 1/5 v1] LoongArch: bfd: Add new reloc types WANG Xuerui
2022-07-18 11:33   ` Xi Ruoyao
2022-07-18 12:11     ` WANG Xuerui [this message]
2022-07-18 12:18       ` WANG Xuerui
2022-07-19  3:57       ` Fangrui Song
2022-07-20  7:47         ` liuzhensong
2022-07-20  2:07       ` liuzhensong
2022-07-20  4:03         ` WANG Xuerui
2022-07-20  5:19           ` Xi Ruoyao
2022-07-20 12:54           ` liuzhensong
2022-07-19  7:32   ` liuzhensong
2022-07-20  2:42   ` liuzhensong
2022-07-19  4:29 ` Xi Ruoyao
2022-07-19  5:40   ` Xi Ruoyao
2022-07-19  6:31     ` 刘振松
2022-07-19  6:34       ` Xi Ruoyao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=417f93f5-64ca-9eb1-c338-b55edfd8eb83@xen0n.name \
    --to=i.swmail@xen0n.name \
    --cc=binutils@sourceware.org \
    --cc=liuzhensong@loongson.cn \
    --cc=maskray@google.com \
    --cc=mengqinggang@loongson.cn \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).