Browse Source
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.master
committed by
liuzhensong
5 changed files with 31 additions and 0 deletions
@ -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 |
||||
|
|
||||
@ -0,0 +1,9 @@ |
|||||
|
.text |
||||
|
.global sym |
||||
|
sym: nop |
||||
|
|
||||
|
.section .data,"aw" |
||||
|
.dword sym |
||||
|
|
||||
|
.section .discard,"aw" |
||||
|
.dword sym |
||||
@ -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) } |
||||
|
} |
||||
Loading…
Reference in new issue