]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
LoongArch: Default to a maximum page size of 64KiB
authorWANG Xuerui <git@xen0n.name>
Sat, 19 Oct 2024 14:11:52 +0000 (22:11 +0800)
committerliuzhensong <liuzhensong@loongson.cn>
Tue, 10 Dec 2024 01:14:30 +0000 (09:14 +0800)
As per the spec (Section 7.5.10, LoongArch Reference Manual Vol. 1),
LoongArch machines are not limited in page size choices, and currently
page sizes of 4KiB, 16KiB and 64KiB are supported by mainline Linux.
While 16KiB is the most common, the current BFD code says it is the
maximum; this is not correct, and as an effect, almost all existing
binaries are incompatible with a 64KiB kernel because the sections are
not sufficiently aligned, while being totally fine otherwise.
This is needlessly complicating integration testing [1].

This patch fixes the inconsistency, and also brings BFD behavior in line
with that of LLD [2].

[1] https://github.com/loongson-community/discussions/issues/47
[2] https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/lld/ELF/Arch/LoongArch.cpp#L174-L183

bfd/
* elfnn-loongarch.c (ELF_MAXPAGESIZE): Bump to 64KiB.
(ELF_MINPAGESIZE): Define as 4KiB.
(ELF_COMMONPAGESIZE): Define as 16KiB.

ld/
* testsuite/ld-loongarch-elf/64_pcrel.d: Update assertions after
changing the target max page size to 64KiB.
* testsuite/ld-loongarch-elf/data-got.d: Likewise.
* testsuite/ld-loongarch-elf/desc-relex.d: Likewise.
* testsuite/ld-loongarch-elf/relax-align-ignore-start.d: Likewise.
* testsuite/ld-loongarch-elf/tlsdesc_abs.d: Make the fuzzy match work
as intended by not checking exact instruction words.
* testsuite/ld-loongarch-elf/tlsdesc_extreme.d: Likewise.

Signed-off-by: WANG Xuerui <git@xen0n.name>
bfd/ChangeLog
bfd/elfnn-loongarch.c
ld/ChangeLog
ld/testsuite/ld-loongarch-elf/64_pcrel.d
ld/testsuite/ld-loongarch-elf/data-got.d
ld/testsuite/ld-loongarch-elf/desc-relax.d
ld/testsuite/ld-loongarch-elf/relax-align-ignore-start.d
ld/testsuite/ld-loongarch-elf/tlsdesc_abs.d
ld/testsuite/ld-loongarch-elf/tlsdesc_extreme.d

index 83605903ee4943b634e7781ceebe0adb9ad0e049..3879b81ae481ece95c326d84409a1fd17bcac0d4 100644 (file)
@@ -1,3 +1,9 @@
+2024-10-18  WANG Xuerui <git@xen0n.name>
+
+       * elfnn-loongarch.c (ELF_MAXPAGESIZE): Bump to 64KiB.
+       (ELF_MINPAGESIZE): Define as 4KiB.
+       (ELF_COMMONPAGESIZE): Define as 16KiB.
+
 2024-07-20  Nick Clifton  <nickc@redhat.com>
 
        * 2.43 branch point.
index 7451153270fa6fdf7a38934f38e2f80aa9286bca..2ce5f73ae8043ca77b1926f4e863f2f817f79baf 100644 (file)
@@ -6270,7 +6270,9 @@ elf_loongarch64_hash_symbol (struct elf_link_hash_entry *h)
 #define ELF_ARCH bfd_arch_loongarch
 #define ELF_TARGET_ID LARCH_ELF_DATA
 #define ELF_MACHINE_CODE EM_LOONGARCH
-#define ELF_MAXPAGESIZE 0x4000
+#define ELF_MINPAGESIZE 0x1000
+#define ELF_MAXPAGESIZE 0x10000
+#define ELF_COMMONPAGESIZE 0x4000
 #define bfd_elfNN_bfd_reloc_type_lookup loongarch_reloc_type_lookup
 #define bfd_elfNN_bfd_link_hash_table_create                             \
   loongarch_elf_link_hash_table_create
index 55c8d7793e1156bf7773e1facb2a41d6aa69262c..991514553141679c1b35f6f9c9903ef645bdafde 100644 (file)
@@ -1,3 +1,14 @@
+2024-10-18  WANG Xuerui <git@xen0n.name>
+
+       * testsuite/ld-loongarch-elf/64_pcrel.d: Update assertions after
+       changing the target max page size to 64KiB.
+       * testsuite/ld-loongarch-elf/data-got.d: Likewise.
+       * testsuite/ld-loongarch-elf/desc-relex.d: Likewise.
+       * testsuite/ld-loongarch-elf/relax-align-ignore-start.d: Likewise.
+       * testsuite/ld-loongarch-elf/tlsdesc_abs.d: Make the fuzzy match work
+       as intended by not checking exact instruction words.
+       * testsuite/ld-loongarch-elf/tlsdesc_extreme.d: Likewise.
+
 2024-07-20  Nick Clifton  <nickc@redhat.com>
 
        * 2.43 branch point.
index 2ea063b75542dab239650a148547f8563551944d..1f4664ea4d7b12aa9f9252c51d0721efc26bb41f 100644 (file)
@@ -1,4 +1,4 @@
 #...
-.*0xffffbffc.*
+.*0xfffefffc.*
 .*0xffffffff.*
 #pass
index a754478a655324fe7b0477b4f0e29ac1ae6a8e0e..4a26c72d46dc778ab2cd68644a8fb3a7d427ceac 100644 (file)
@@ -8,7 +8,7 @@
 #skip: loongarch32-*-*
 
 #...
-  GNU_RELRO      0x003c10 0x0000000000007c10 0x0000000000007c10 0x0003f0 0x0003f0 R   0x1
+  GNU_RELRO      0x00fc10 0x000000000001fc10 0x000000000001fc10 0x0003f0 0x0003f0 R   0x1
 #...
    01     .dynamic .got .got.plt .data 
 #...
index c885953c7273b2fd1b25fb1803120b905b9dbd67..48f2d1e389c5278ab3aab5d0ec9d3646962d76ce 100644 (file)
@@ -9,7 +9,7 @@
 Disassembly of section .text:
 
 0+188 <.*>:
- 188:  18020844        pcaddi          \$a0, 4162
+ 188:  18080844        pcaddi          \$a0, 16450
  18c:  28c00081        ld.d            \$ra, \$a0, 0
  190:  4c000021        jirl            \$ra, \$ra, 0
  194:  0010888c        add.d           \$t0, \$a0, \$tp
index 939cf427b4bebde8a2386da26013cb9d962eb210..70763ff0fc808d5b0bd272e4f0e09bb7fe3e7d99 100644 (file)
@@ -12,5 +12,5 @@ Disassembly of section bbb:
 0000000120000080 <bbb>:
 [      ]+120000080:[   ]+4c000020[     ]+ret
 Disassembly of section ccc:
-0000000120000090 <__bss_start-0x4004>:
+0000000120000090 <__bss_start-0x10004>:
 [      ]+120000090:[   ]+4c000020[     ]+ret
index 62f5a2a077b7ef426feb27f679ded7cc407e6d7e..7e23454bac7683cc1c2c544ed35c8a7d1fad7d7e 100644 (file)
@@ -9,15 +9,15 @@
 Disassembly of section .text:
 
 0+120000100 <.*>:
-   120000100:  14400084        lu12i.w         \$a0, .*
-   120000104:  03850084        ori             \$a0, \$a0, .*
-   120000108:  16000024        lu32i.d         \$a0, .*
+   120000100:  ........        lu12i.w         \$a0, .*
+   120000104:  ........        ori             \$a0, \$a0, .*
+   120000108:  ........        lu32i.d         \$a0, .*
    12000010c:  03000084        lu52i.d         \$a0, \$a0, 0
    120000110:  28c00081        ld.d            \$ra, \$a0, 0
    120000114:  4c000021        jirl            \$ra, \$ra, 0
-   120000118:  14400084        lu12i.w         \$a0, .*
-   12000011c:  03850084        ori             \$a0, \$a0, .*
-   120000120:  16000024        lu32i.d         \$a0, .*
+   120000118:  ........        lu12i.w         \$a0, .*
+   12000011c:  ........        ori             \$a0, \$a0, .*
+   120000120:  ........        lu32i.d         \$a0, .*
    120000124:  03000084        lu52i.d         \$a0, \$a0, 0
    120000128:  28c00081        ld.d            \$ra, \$a0, 0
    12000012c:  4c000021        jirl            \$ra, \$ra, 0
index 5517999733d1a0c4264115db668f8167974ac5ed..fbc1d945d711c353890168a4a83b1d46330513b6 100644 (file)
@@ -9,15 +9,15 @@
 Disassembly of section .text:
 
 0+120000100 <.*>:
-   120000100:  1a000084        pcalau12i       \$a0, .*
-   120000104:  02c52001        li.d            \$ra, .*
+   120000100:  ........        pcalau12i       \$a0, .*
+   120000104:  ........        li.d            \$ra, .*
    120000108:  16000001        lu32i.d         \$ra, 0
    12000010c:  03000021        lu52i.d         \$ra, \$ra, 0
    120000110:  00108484        add.d           \$a0, \$a0, \$ra
    120000114:  28c00081        ld.d            \$ra, \$a0, 0
    120000118:  4c000021        jirl            \$ra, \$ra, 0
-   12000011c:  1a000084        pcalau12i       \$a0, .*
-   120000120:  02c5200d        li.d            \$t1, .*
+   12000011c:  ........        pcalau12i       \$a0, .*
+   120000120:  ........        li.d            \$t1, .*
    120000124:  1600000d        lu32i.d         \$t1, 0
    120000128:  030001ad        lu52i.d         \$t1, \$t1, 0
    12000012c:  0010b484        add.d           \$a0, \$a0, \$t1