From: Jinyang He <hejinyang@loongson.cn>
To: Fangrui Song <i@maskray.me>, Xi Ruoyao <xry111@xry111.site>
Cc: binutils@sourceware.org, mengqinggang@loongson.cn,
Zhensong Liu <liuzhensong@loongson.cn>,
i.swmail@xen0n.name, maskray@google.com,
Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: Re: [PATCH v2 1/5] LoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64
Date: Sat, 29 Jun 2024 21:56:10 +0800 [thread overview]
Message-ID: <9e2e6b1e-b893-aaa2-2646-17d5190d045c@loongson.cn> (raw)
In-Reply-To: <DS7PR12MB576568EB1C62FAAB019BBC73CBD02@DS7PR12MB5765.namprd12.prod.outlook.com>
在 2024/6/29 1:04, Fangrui Song 写道:
> On Thu, Jun 27, 2024 at 6:53 PM Jinyang He <hejinyang@loongson.cn> wrote:
>> On 2024-06-28 01:19, Xi Ruoyao wrote:
>>
>>> On Thu, 2024-06-27 at 20:39 +0800, Xi Ruoyao wrote:
>>>>> I'd like to do this rejection earlier in `check_relocs` than
>>>>> `relocate_section`. Generally loongarch32 do not produce R_LARCH_64,
>>>>> so this rejection should be efficient only for R_LARCH_32 on
>>>>> loongarch64.
>>>> Ok, in V3 I'll use the same approach as RISC-V then.
>>> And after some thinking: R_LARCH_64 on loongarch32 should be fine. On
>>> little-endian hardware *(uint64 *)pc += load_addr should be same as
>>> *(uint32 *)pc += load_addr unless the latter wraps, but if it wraps
>>> Glibc dynamic linker should complain anyway.
>>>
>>> RISC-V also converts R_RISCV_64 to R_RISCV_RELATIVE for rv32.
>> Yes, you're right. I think we cannot avoid asm like `.8byte .L1` or
>> `.8byte .L1 - .L2`, so emiting 64bits static reloc type on loongarch32
>> makes sense.
>>
> x86-32, aarch32, ppc32, and s390 ports do not support `.quad .L1`.
> mips32 and riscv32 accept `.quad .L1`, which might be a mistake.
>
> Why cannot '.8byte .L1` be avoided?
Thank you for providing the detailed list. To be frankly, I sometimes see
how RISCV does and think how LoongArch should do. I'm sorry for lack
of in-depth thinking.
I think users may handwrite asm codes for 32-bits and 64 bits machines.
If we accept it, we can reduce the error. Users need to understand that
the value is 8 bytes as they excepted rather than the arch bits size.
Compilers such as gcc should not generate these asm codes.
If it is a clear mistake, I think we should fix it.
Thanks.
next prev parent reply other threads:[~2024-06-29 13:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 10:04 [PATCH v2 0/5] LoongArch: Add DT_RELR (packing relative relocs) support Xi Ruoyao
2024-06-26 10:04 ` [PATCH v2 1/5] LoongArch: Reject R_LARCH_32 from becoming a runtime reloc in ELFCLASS64 Xi Ruoyao
2024-06-27 10:58 ` Jinyang He
2024-06-27 12:39 ` Xi Ruoyao
2024-06-27 17:19 ` Xi Ruoyao
2024-06-28 1:53 ` Jinyang He
2024-06-28 17:04 ` Fangrui Song
2024-06-29 13:56 ` Jinyang He [this message]
2024-06-30 2:55 ` Xi Ruoyao
2024-06-26 10:04 ` [PATCH v2 2/5] LoongArch: Fix bad reloc with mixed visibility ifunc symbols in shared libraries Xi Ruoyao
2024-06-28 9:40 ` Jinyang He
2024-06-28 12:39 ` Xi Ruoyao
2024-06-26 10:04 ` [PATCH v2 3/5] LoongArch: Make protected function symbols local for -shared Xi Ruoyao
2024-06-26 10:04 ` [PATCH v2 4/5] LoongArch: Add DT_RELR support Xi Ruoyao
2024-06-27 7:21 ` mengqinggang
2024-06-27 10:13 ` Xi Ruoyao
2024-06-27 7:27 ` mengqinggang
2024-06-27 10:16 ` Xi Ruoyao
2024-06-26 10:04 ` [PATCH v2 5/5] LoongArch: Add DT_RELR tests Xi Ruoyao
2024-06-27 7:11 ` mengqinggang
2024-06-27 10:14 ` 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=9e2e6b1e-b893-aaa2-2646-17d5190d045c@loongson.cn \
--to=hejinyang@loongson.cn \
--cc=binutils@sourceware.org \
--cc=i.swmail@xen0n.name \
--cc=i@maskray.me \
--cc=liuzhensong@loongson.cn \
--cc=maskray@google.com \
--cc=mengqinggang@loongson.cn \
--cc=szabolcs.nagy@arm.com \
--cc=xry111@xry111.site \
/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).