Skip to content

Instantly share code, notes, and snippets.

@xry111
Last active January 22, 2024 11:51
Show Gist options
  • Save xry111/b0b8f2ef2fd4a98eb8dd62232bba6f85 to your computer and use it in GitHub Desktop.
Save xry111/b0b8f2ef2fd4a98eb8dd62232bba6f85 to your computer and use it in GitHub Desktop.
diff --git a/gas/NEWS b/gas/NEWS
index cf4e8ff7c95..d699a78b50d 100644
--- a/gas/NEWS
+++ b/gas/NEWS
@@ -66,6 +66,37 @@ Changes in 2.42:
* The BPF assembler now allows using both hash (#) and double slash (//) to
begin line comments.
+* Add support for LoongArch v1.10 new instructions: estimated reciprocal
+ instructions, sub-word atomic instructions, atomic CAS instructions,
+ 16-byte store-conditional instruction, load-linked instructions with
+ acquire semantics, and store-conditional instructions with release
+ semantics.
+
+* The %call36 relocation operator, along with the pseudo-instructions
+ call36 and tail36, are now usable with the LoongArch "medium" code
+ model, allowing text sections up to 128 GiB.
+
+* TLS descriptors (TLSDESC) is now supported on LoongArch. This includes
+ the following new relocation operators: %desc_pc_hi20, %desc_pc_lo12,
+ %desc_ld, and %desc_call, and the la.tls.desc pseudo-instruction.
+
+* TLS LE relaxation is now supported on LoongArch. New relocation
+ operators %le_hi20_r, %le_lo12r, and %le_add_r are now available, with
+ la.tls.le now making use of them.
+
+* Add support for LoongArch branch relaxation: a conditional branch with
+ destination out of its immediate operand range, but still within
+ a "b"'s range, is now assembled as an inverted branch and a "b". This
+ works around the unreliable branch offset estimation of the compiler
+ when .align directive is encoded into a long NOP sequence with an
+ R_LARCH_RELAX by the assembler.
+
+* Add support for encoding three-expression .align directives on LoongArch
+ with R_LARCH_ALIGN.
+
+* Symbol or label names in LoongArch assembly can now be spelled with
+ double-quotes.
+
Changes in 2.41:
* Add support for the KVX instruction set.
diff --git a/ld/NEWS b/ld/NEWS
index c3ebe320e5e..a5a5b9faee2 100644
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -29,6 +29,17 @@ Changes in 2.42:
--enable-error-rwx-segments=[yes|no] configure options to set the default for
converting warnings into errors.
+* On LoongArch, various linker relaxation bugs are fixed; the most notable
+ of which is BZ 30944 (incorrect .balign semantics).
+
+* On LoongArch, the LoongArch ABI v2.30 (LoongArch ELF psABI v20231219) is
+ now implemented. This includes new relocation types, and changed
+ semantics for PC-relative relocations handling the higher half of 64-bit
+ offsets.
+
+* On LoongArch, link-time TLS optimization and TLS relaxation are now
+ supported.
+
Changes in 2.41:
* The linker now accepts a command line option of --remap-inputs
@xen0n
Copy link

xen0n commented Jan 22, 2024

I've touched the GAS news a bit to make it more consistent with the surrounding text (note that much of the text is not 100% "natural" English expression either):

* Add support for LoongArch v1.10 new instructions: estimated reciprocal
  instructions, sub-word atomic instructions, atomic CAS instructions,
  16-byte store-conditional instruction, load-linked instructions with
  acquire semantics, and store-conditional instructions with release
  semantics.

* The %call36 relocation operator, along with the pseudo-instructions
  call36 and tail36, are now usable with the LoongArch "medium" code
  model, allowing text sections up to 256 GiB.

* TLS descriptors (TLSDESC) is now supported on LoongArch. This includes
  the following new relocation operators: %desc_pc_hi20, %desc_pc_lo12,
  %desc_ld, and %desc_call, and the la.tls.desc pseudo-instruction.

* TLS LE relaxation is now supported on LoongArch. New relocation
  operators %le_hi20_r, %le_lo12r, and %le_add_r are now available, with
  la.tls.le now making use of them.

* Add support for LoongArch branch relaxation: a conditional branch with
  destination out of its immediate operand range, but still within
  a "b"'s range, is now assembled as an inverted branch and a "b". This
  allows more code to fit in the default "normal" code model.

* Add support for encoding three-expression .align directives on LoongArch
  with R_LARCH_ALIGN.

* Symbol or label names in LoongArch assembly can now be spelled with
  double-quotes.

@xry111
Copy link
Author

xry111 commented Jan 22, 2024

  • The %call36 relocation operator, along with the pseudo-instructions
    call36 and tail36, are now usable with the LoongArch "medium" code
    model, allowing text sections up to 256 GiB.

It seems 128 GiB? 2**38 = 256 GiB but it's signed.

@xry111
Copy link
Author

xry111 commented Jan 22, 2024

  • Add support for LoongArch branch relaxation: a conditional branch with
    destination out of its immediate operand range, but still within
    a "b"'s range, is now assembled as an inverted branch and a "b". This
    allows more code to fit in the default "normal" code model.

This is not related to code model. GCC should estimate the upper limit of the jump offsets and do the expansion if the offset may be large, but with relaxation and .align the estimation of GCC is unreliable.

@xen0n
Copy link

xen0n commented Jan 22, 2024

And for the ld part:

* On LoongArch, various linker relaxation bugs are fixed; the most notable
  of which is BZ 30944 (incorrect .balign semantics).

* On LoongArch, the LoongArch ABI v2.30 (LoongArch ELF psABI v20231219) is
  now implemented. This includes new relocation types, and changed semantics
  for PC-relative relocations handling the higher half of 64-bit offsets.

* On LoongArch, TLS relaxation is now supported.

(notice the "TLS transition" part is most likely Chinglish by the original committer, which I didn't have time to fix for them. Please re-check for certainty though.)

@xen0n
Copy link

xen0n commented Jan 22, 2024

  • The %call36 relocation operator, along with the pseudo-instructions
    call36 and tail36, are now usable with the LoongArch "medium" code
    model, allowing text sections up to 256 GiB.

It seems 128 GiB? 2**38 = 256 GiB but it's signed.

You're right!

@xen0n
Copy link

xen0n commented Jan 22, 2024

  • Add support for LoongArch branch relaxation: a conditional branch with
    destination out of its immediate operand range, but still within
    a "b"'s range, is now assembled as an inverted branch and a "b". This
    allows more code to fit in the default "normal" code model.

This is not related to code model. GCC should estimate the upper limit of the jump offsets and do the expansion if the offset may be large, but with relaxation and .align the estimation of GCC is unreliable.

Feel free to adjust then!

@xry111
Copy link
Author

xry111 commented Jan 22, 2024

And for the ld part:

* On LoongArch, various linker relaxation bugs are fixed; the most notable
  of which is BZ 30944 (incorrect .balign semantics).

* On LoongArch, the LoongArch ABI v2.30 (LoongArch ELF psABI v20231219) is
  now implemented. This includes new relocation types, and changed semantics
  for PC-relative relocations handling the higher half of 64-bit offsets.

* On LoongArch, TLS relaxation is now supported.

(notice the "TLS transition" part is most likely Chinglish by the original committer, which I didn't have time to fix for them. Please re-check for certainty though.)

Fangrui uses "Link-time TLS optimization" in his famous article but this phrase may be confused with "LTO" IMO...

@xen0n
Copy link

xen0n commented Jan 22, 2024

And for the ld part:

* On LoongArch, various linker relaxation bugs are fixed; the most notable
  of which is BZ 30944 (incorrect .balign semantics).

* On LoongArch, the LoongArch ABI v2.30 (LoongArch ELF psABI v20231219) is
  now implemented. This includes new relocation types, and changed semantics
  for PC-relative relocations handling the higher half of 64-bit offsets.

* On LoongArch, TLS relaxation is now supported.

(notice the "TLS transition" part is most likely Chinglish by the original committer, which I didn't have time to fix for them. Please re-check for certainty though.)

Fangrui uses "Link-time TLS optimization" in his famous article but this phrase may be confused with "LTO" IMO...

It's okay as long as it's not being referred to as "LTO"...

@xry111
Copy link
Author

xry111 commented Jan 22, 2024

gist updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment