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 /bfd | |
parent | b98da8583a500419c976bcfd56b80b02b1afceff (diff) | |
download | gdb-fb266c9083b42d6287b2fe93a82ffe663d8f4640.zip gdb-fb266c9083b42d6287b2fe93a82ffe663d8f4640.tar.gz gdb-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 'bfd')
-rw-r--r-- | bfd/elfnn-loongarch.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 1895699..1b5009e 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -1368,6 +1368,8 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) for (p = h->dyn_relocs; p != NULL; p = p->next) { + if (discarded_section (p->sec)) + continue; asection *sreloc = elf_section_data (p->sec)->sreloc; sreloc->size += p->count * sizeof (ElfNN_External_Rela); } |