diff options
author | Alan Modra <amodra@gmail.com> | 2023-02-22 17:37:26 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2023-02-23 12:58:53 +1030 |
commit | 3a574cce26ee7dca6d6cd4c756dec57a5c0b9c99 (patch) | |
tree | 918c2cb37101dfe0433283c5afc332df3b979008 /bfd | |
parent | 81ff113f7852558610855261551410455886cb08 (diff) | |
download | gdb-3a574cce26ee7dca6d6cd4c756dec57a5c0b9c99.zip gdb-3a574cce26ee7dca6d6cd4c756dec57a5c0b9c99.tar.gz gdb-3a574cce26ee7dca6d6cd4c756dec57a5c0b9c99.tar.bz2 |
Test SEC_HAS_CONTENTS in relax routines
More places that generally expect instructions, so not zeros.
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes): Exclude
sections without SEC_HAS_CONTENTS set.
* elf-m10200.c (mn10200_elf_relax_section): Likewise.
* elf32-arc.c (arc_elf_relax_section): Likewise.
* elf32-avr.c (elf32_avr_relax_section): Likewise.
* elf32-cr16.c (elf32_cr16_relax_section): Likewise.
* elf32-crx.c (elf32_crx_relax_section): Likewise.
* elf32-epiphany.c (epiphany_elf_relax_section): Likewise.
* elf32-ft32.c (ft32_elf_relax_section): Likewise.
* elf32-h8300.c (elf32_h8_relax_section): Likewise.
* elf32-ip2k.c (ip2k_elf_relax_section): Likewise.
* elf32-m32c.c (m32c_elf_relax_section): Likewise.
* elf32-m68hc11.c (m68hc11_elf_relax_section): Likewise.
* elf32-msp430.c (msp430_elf_relax_section): Likewise.
* elf32-pru.c (pru_elf32_relax_section): Likewise.
* elf32-rl78.c (rl78_elf_relax_section): Likewise.
* elf32-rx.c (elf32_rx_relax_section): Likewise.
* elf32-sh.c (sh_elf_relax_section): Likewise.
(sh_elf_relax_delete_bytes): Likewise.
* elf32-v850.c (v850_elf_relax_section): Likewise.
* elf64-alpha.c (elf64_alpha_relax_section): Likewise.
* elf64-ia64-vms.c (elf64_ia64_relax_section): Likewise.
* elfnn-ia64.c (elfNN_ia64_relax_section): Likewise.
* elfnn-riscv.c (_bfd_riscv_relax_section): Likewise.
* elfxx-mips.c (_bfd_mips_elf_relax_section): Likewise.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/coff-sh.c | 2 | ||||
-rw-r--r-- | bfd/elf-m10200.c | 3 | ||||
-rw-r--r-- | bfd/elf32-arc.c | 3 | ||||
-rw-r--r-- | bfd/elf32-avr.c | 3 | ||||
-rw-r--r-- | bfd/elf32-cr16.c | 3 | ||||
-rw-r--r-- | bfd/elf32-crx.c | 3 | ||||
-rw-r--r-- | bfd/elf32-epiphany.c | 3 | ||||
-rw-r--r-- | bfd/elf32-ft32.c | 3 | ||||
-rw-r--r-- | bfd/elf32-h8300.c | 3 | ||||
-rw-r--r-- | bfd/elf32-ip2k.c | 3 | ||||
-rw-r--r-- | bfd/elf32-m32c.c | 3 | ||||
-rw-r--r-- | bfd/elf32-m68hc11.c | 3 | ||||
-rw-r--r-- | bfd/elf32-msp430.c | 6 | ||||
-rw-r--r-- | bfd/elf32-pru.c | 6 | ||||
-rw-r--r-- | bfd/elf32-rl78.c | 3 | ||||
-rw-r--r-- | bfd/elf32-rx.c | 3 | ||||
-rw-r--r-- | bfd/elf32-sh.c | 2 | ||||
-rw-r--r-- | bfd/elf32-v850.c | 1 | ||||
-rw-r--r-- | bfd/elf64-alpha.c | 4 | ||||
-rw-r--r-- | bfd/elf64-ia64-vms.c | 5 | ||||
-rw-r--r-- | bfd/elfnn-ia64.c | 5 | ||||
-rw-r--r-- | bfd/elfnn-riscv.c | 3 | ||||
-rw-r--r-- | bfd/elfxx-mips.c | 3 |
23 files changed, 51 insertions, 25 deletions
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index 314b796..50e9043 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -717,6 +717,7 @@ sh_relax_section (bfd *abfd, *again = false; if (bfd_link_relocatable (link_info) + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0) return true; @@ -1364,6 +1365,7 @@ sh_relax_delete_bytes (bfd *abfd, bfd_byte *ocontents; if (o == sec + || (o->flags & SEC_HAS_CONTENTS) == 0 || (o->flags & SEC_RELOC) == 0 || o->reloc_count == 0) continue; diff --git a/bfd/elf-m10200.c b/bfd/elf-m10200.c index 24be1cb..d7376cb 100644 --- a/bfd/elf-m10200.c +++ b/bfd/elf-m10200.c @@ -577,8 +577,9 @@ mn10200_elf_relax_section (bfd *abfd, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index c5331ed..78dfd6e 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -2972,8 +2972,9 @@ arc_elf_relax_section (bfd *abfd, asection *sec, section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c index c01355a..7027191 100644 --- a/bfd/elf32-avr.c +++ b/bfd/elf32-avr.c @@ -2522,8 +2522,9 @@ elf32_avr_relax_section (bfd *abfd, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-cr16.c b/bfd/elf32-cr16.c index 32507da..caaf3bd 100644 --- a/bfd/elf32-cr16.c +++ b/bfd/elf32-cr16.c @@ -1718,8 +1718,9 @@ elf32_cr16_relax_section (bfd *abfd, asection *sec, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-crx.c b/bfd/elf32-crx.c index f041e48..811440d 100644 --- a/bfd/elf32-crx.c +++ b/bfd/elf32-crx.c @@ -973,8 +973,9 @@ elf32_crx_relax_section (bfd *abfd, asection *sec, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-epiphany.c b/bfd/elf32-epiphany.c index f05ef14..da874da 100644 --- a/bfd/elf32-epiphany.c +++ b/bfd/elf32-epiphany.c @@ -213,8 +213,9 @@ epiphany_elf_relax_section (bfd *abfd, asection *sec, if this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-ft32.c b/bfd/elf32-ft32.c index 07036b3..ce4946a 100644 --- a/bfd/elf32-ft32.c +++ b/bfd/elf32-ft32.c @@ -1092,8 +1092,9 @@ ft32_elf_relax_section (bfd *abfd, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c index f08ab3f..3039b82 100644 --- a/bfd/elf32-h8300.c +++ b/bfd/elf32-h8300.c @@ -706,8 +706,9 @@ elf32_h8_relax_section (bfd *abfd, asection *sec, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-ip2k.c b/bfd/elf32-ip2k.c index 5f63d91..cb1ab0e 100644 --- a/bfd/elf32-ip2k.c +++ b/bfd/elf32-ip2k.c @@ -1096,8 +1096,9 @@ ip2k_elf_relax_section (bfd *abfd, if this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index e9308ff..129d6a9 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -1459,8 +1459,9 @@ m32c_elf_relax_section (bfd *abfd, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-m68hc11.c b/bfd/elf32-m68hc11.c index 11a58f0..67a8dad 100644 --- a/bfd/elf32-m68hc11.c +++ b/bfd/elf32-m68hc11.c @@ -709,8 +709,9 @@ m68hc11_elf_relax_section (bfd *abfd, asection *sec, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-msp430.c b/bfd/elf32-msp430.c index 4475baf..e77ca39 100644 --- a/bfd/elf32-msp430.c +++ b/bfd/elf32-msp430.c @@ -2014,8 +2014,10 @@ msp430_elf_relax_section (bfd * abfd, asection * sec, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 - || sec->reloc_count == 0 || (sec->flags & SEC_CODE) == 0) + || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 + || (sec->flags & SEC_CODE) == 0) return true; if (debug_relocs) diff --git a/bfd/elf32-pru.c b/bfd/elf32-pru.c index d7bbbe1..2bb4cb7 100644 --- a/bfd/elf32-pru.c +++ b/bfd/elf32-pru.c @@ -1354,8 +1354,10 @@ pru_elf32_relax_section (bfd *abfd, asection *sec, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 - || sec->reloc_count == 0 || (sec->flags & SEC_CODE) == 0) + || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 + || (sec->flags & SEC_CODE) == 0) return true; symtab_hdr = & elf_tdata (abfd)->symtab_hdr; diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index 6adc495..c7a94f2 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -2106,8 +2106,9 @@ rl78_elf_relax_section (bfd *abfd, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index e3dde13..d14c238 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -2038,8 +2038,9 @@ elf32_rx_relax_section (bfd *abfd, this section does not have relocs, or if this is not a code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 246f9f5..fdcc587 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -468,6 +468,7 @@ sh_elf_relax_section (bfd *abfd, asection *sec, *again = false; if (bfd_link_relocatable (link_info) + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0) return true; @@ -1154,6 +1155,7 @@ sh_elf_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, bfd_byte *ocontents; if (o == sec + || (o->flags & SEC_HAS_CONTENTS) == 0 || (o->flags & SEC_RELOC) == 0 || o->reloc_count == 0) continue; diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 681526c..4ce5499 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -3440,6 +3440,7 @@ v850_elf_relax_section (bfd *abfd, *again = false; if (bfd_link_relocatable (link_info) + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0) return true; diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 875bf69..81d58c8 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -3726,8 +3726,8 @@ elf64_alpha_relax_section (bfd *abfd, asection *sec, *again = false; if (bfd_link_relocatable (link_info) - || ((sec->flags & (SEC_CODE | SEC_RELOC | SEC_ALLOC)) - != (SEC_CODE | SEC_RELOC | SEC_ALLOC)) + || ((sec->flags & (SEC_CODE | SEC_RELOC | SEC_ALLOC | SEC_HAS_CONTENTS)) + != (SEC_CODE | SEC_RELOC | SEC_ALLOC | SEC_HAS_CONTENTS)) || sec->reloc_count == 0) return true; diff --git a/bfd/elf64-ia64-vms.c b/bfd/elf64-ia64-vms.c index 9fb1a93..1866a57 100644 --- a/bfd/elf64-ia64-vms.c +++ b/bfd/elf64-ia64-vms.c @@ -370,8 +370,9 @@ elf64_ia64_relax_section (bfd *abfd, asection *sec, /* Nothing to do if there are no relocations or there is no need for the current pass. */ - if ((sec->flags & SEC_RELOC) == 0 - || sec->reloc_count == 0 + if (sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (link_info->relax_pass == 0 && sec->skip_relax_pass_0) || (link_info->relax_pass == 1 && sec->skip_relax_pass_1)) return true; diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c index c1f49bd..a2d60e7 100644 --- a/bfd/elfnn-ia64.c +++ b/bfd/elfnn-ia64.c @@ -370,8 +370,9 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec, /* Nothing to do if there are no relocations or there is no need for the current pass. */ - if ((sec->flags & SEC_RELOC) == 0 - || sec->reloc_count == 0 + if (sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (link_info->relax_pass == 0 && sec->skip_relax_pass_0) || (link_info->relax_pass == 1 && sec->skip_relax_pass_1)) return true; diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index c2604de..355ddb2 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -4776,8 +4776,9 @@ _bfd_riscv_relax_section (bfd *abfd, asection *sec, if (bfd_link_relocatable (info) || sec->sec_flg0 - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (info->disable_target_specific_optimizations && info->relax_pass == 0) /* The exp_seg_relro_adjust is enum phase_enum (0x4), diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 5b66cb8..74a4d0d 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -13975,8 +13975,9 @@ _bfd_mips_elf_relax_section (bfd *abfd, asection *sec, code section. */ if (bfd_link_relocatable (link_info) - || (sec->flags & SEC_RELOC) == 0 || sec->reloc_count == 0 + || (sec->flags & SEC_RELOC) == 0 + || (sec->flags & SEC_HAS_CONTENTS) == 0 || (sec->flags & SEC_CODE) == 0) return true; |