public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1 0/5] LoongArch tls le model linker relaxation support.
@ 2023-12-01  9:07 changjiachen
  2023-12-01  9:07 ` [PATCH v1 1/5] LoongArch: bfd: Add support for tls le relax changjiachen
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: changjiachen @ 2023-12-01  9:07 UTC (permalink / raw)
  To: binutils
  Cc: xuchenghua, chenglulu, liuzhensong, xry111, i.swmail, maskray,
	cailulu, luweining, wanglei, hejinyang, Lazy_Linux, changjiachen

This is the v1 version of patches to support loongarch linker tls le model relax.

This support does three main things:

1. Modify LoongArch tls le model assembly instruction sequence.

This change is mainly implemented in gcc. Due to the characteristics 
of st.w instruction in Loongarch and the unique addressing mode of 
tls le model, in order to implement tls le model linker relax, it is 
decided to change the tls le model instruction sequence.

The specific changes are as follows:

example: __thread int a = 1;

old insn sequence:

lu12i.w $r12,%le_hi20_r(a)
ori     $r12,$r12,%le_lo12_r(a)
add.d   $r12,$r12,$r2,%le_add_r(a)
li.w	$r13,$r0,1
stptr.w $r13,$r12,0

new insn sequence:

lu12i.w $r12,%le_hi20_r(a)
add.d   $r12,$r12,$r2,%le_add_r(a)
li.w    $r13,$r0,1
st.w    $r13,$r12,%le_lo12_r(a)

2. Added LoongArch three relocations related to tls le model relax.

In order to ensure forward compatibility of binutils versions and 
implement tls le model relax, it was decided to add three relocation items.

The relocation items are as follows:

R_LARCH_TLS_LE_HI20_R
R_LARCH_TLS_LE_LO12_R
R_LARCH_TLS_LE_ADD_R

3. Implement Loongarch tls le model relax in ld.

This change will add a loongarch_relax_tls_le function to relax tls le model.

The instructions before and after relax change as follows:

example: __thread int a = 1;

before relax insn:

lu12i.w	 $t0, 0
add.d	 $t0, $t0, $tp
li.w	 $t1, 1
st.w	 $t1, $t0, 0

after relax insn:

li.w     $t1, 1
st.w     $t1, $tp, 0

changjiachen (5):
  LoongArch: bfd: Add support for tls le relax.
  LoongArch: include: Add support for tls le relax.
  LoongArch: opcodes: Add support for tls le relax.
  LoongArch: gas: Add support for tls le relax.
  LoongArch: ld: Add support for tls le relax.

 bfd/bfd-in2.h                                 |   4 +
 bfd/elfnn-loongarch.c                         |  74 +++++++++
 bfd/elfxx-loongarch.c                         |  50 ++++++
 bfd/libbfd.h                                  |   3 +
 bfd/reloc.c                                   |   6 +
 gas/config/tc-loongarch.c                     |  12 +-
 gas/testsuite/gas/loongarch/reloc.d           |  18 +++
 gas/testsuite/gas/loongarch/reloc.s           |  11 ++
 include/elf/loongarch.h                       |  13 ++
 ld/testsuite/ld-loongarch-elf/old-tls-le.s    |  19 +++
 .../relax-bound-check-tls-le.s                |  48 ++++++
 .../ld-loongarch-elf/relax-check-tls-le.s     |  43 ++++++
 ld/testsuite/ld-loongarch-elf/relax-tls-le.s  |  17 ++
 ld/testsuite/ld-loongarch-elf/relax.exp       | 146 +++++++++++++++++-
 .../tls-relax-compatible-check-old.s          |  39 +++++
 opcodes/loongarch-opc.c                       |   1 +
 16 files changed, 501 insertions(+), 3 deletions(-)
 create mode 100644 ld/testsuite/ld-loongarch-elf/old-tls-le.s
 create mode 100644 ld/testsuite/ld-loongarch-elf/relax-bound-check-tls-le.s
 create mode 100644 ld/testsuite/ld-loongarch-elf/relax-check-tls-le.s
 create mode 100644 ld/testsuite/ld-loongarch-elf/relax-tls-le.s
 create mode 100644 ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-old.s

-- 
2.40.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-12-04  4:37 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01  9:07 [PATCH v1 0/5] LoongArch tls le model linker relaxation support changjiachen
2023-12-01  9:07 ` [PATCH v1 1/5] LoongArch: bfd: Add support for tls le relax changjiachen
2023-12-01  9:07 ` [PATCH v1 2/5] LoongArch: include: " changjiachen
2023-12-01  9:07 ` [PATCH v1 3/5] LoongArch: opcodes: " changjiachen
2023-12-01  9:47   ` Xi Ruoyao
2023-12-01  9:07 ` [PATCH v1 4/5] LoongArch: gas: " changjiachen
2023-12-01  9:07 ` [PATCH v1 5/5] LoongArch: ld: " changjiachen
2023-12-01  9:56 ` [PATCH v1 0/5] LoongArch tls le model linker relaxation support Xi Ruoyao
2023-12-02  1:55 ` Jinyang He
2023-12-02  2:49   ` chenglulu
2023-12-04  4:37   ` 常佳琛

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).