diff options
author | Jinyang He <hejinyang@loongson.cn> | 2023-09-15 11:52:14 +0800 |
---|---|---|
committer | liuzhensong <liuzhensong@loongson.cn> | 2024-02-27 11:58:33 +0800 |
commit | fb266c9083b42d6287b2fe93a82ffe663d8f4640 (patch) | |
tree | 99ee60765091fa516de8a18701a148cdcd6fa253 /ld/testsuite | |
parent | b98da8583a500419c976bcfd56b80b02b1afceff (diff) | |
download | binutils-fb266c9083b42d6287b2fe93a82ffe663d8f4640.zip binutils-fb266c9083b42d6287b2fe93a82ffe663d8f4640.tar.gz binutils-fb266c9083b42d6287b2fe93a82ffe663d8f4640.tar.bz2 |
Avoid unused space in .rela.dyn if sec was discarded
The relsec size is still increased although sec is discarded, which
cause a lot of unused space allocated. Avoid size increased if sec
was discarded.
bfd/ChangeLog:
* bfd/elfnn-loongarch.c: (allocate_dynrelocs): Do not increase
sreloc size when discarded_section.
ld/ChangeLog:
* ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp: Add test.
* ld/testsuite/ld-loongarch-elf/pie_discard.d: New test.
* ld/testsuite/ld-loongarch-elf/pie_discard.s: New test.
* ld/testsuite/ld-loongarch-elf/pie_discard.t: New test.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/pie_discard.d | 10 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/pie_discard.s | 9 | ||||
-rw-r--r-- | ld/testsuite/ld-loongarch-elf/pie_discard.t | 9 |
4 files changed, 29 insertions, 0 deletions
diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp index 2ad783f..3a8629a 100644 --- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp +++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp @@ -147,3 +147,4 @@ run_dump_test "underflow_b16" run_dump_test "underflow_b21" run_dump_test "underflow_b26" run_dump_test "underflow_pcrel20" +run_dump_test "pie_discard" diff --git a/ld/testsuite/ld-loongarch-elf/pie_discard.d b/ld/testsuite/ld-loongarch-elf/pie_discard.d new file mode 100644 index 0000000..7b86309 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/pie_discard.d @@ -0,0 +1,10 @@ +#source: pie_discard.s +#ld: -pie -e 0 -T pie_discard.t +#readelf: -rW + +#... +Relocation section '\.rela\.dyn' .* 1 .* +#... +.*R_LARCH_RELATIVE.* +#pass + diff --git a/ld/testsuite/ld-loongarch-elf/pie_discard.s b/ld/testsuite/ld-loongarch-elf/pie_discard.s new file mode 100644 index 0000000..82b88fc --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/pie_discard.s @@ -0,0 +1,9 @@ + .text + .global sym +sym: nop + + .section .data,"aw" + .dword sym + + .section .discard,"aw" + .dword sym diff --git a/ld/testsuite/ld-loongarch-elf/pie_discard.t b/ld/testsuite/ld-loongarch-elf/pie_discard.t new file mode 100644 index 0000000..49e52cd --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/pie_discard.t @@ -0,0 +1,9 @@ +SECTIONS +{ + . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; + .rela.dyn : { *(.rela.*) } + .text : { *(.text) } + . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE)); + .data : { *(.data) } + /DISCARD/ : { *(.discard) } +} |