diff options
author | Nick Clifton <nickc@redhat.com> | 2024-09-30 14:41:11 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2024-09-30 14:41:11 +0100 |
commit | 7ecf0250f7f0868f3b828ffadd47d0e5f2dbd875 (patch) | |
tree | 14ea6e716632df8b904e1b8509ef949d97d8569f /ld/ldelf.c | |
parent | 4339a3ffc39af599305bd992536dd379ac8390ca (diff) | |
download | binutils-7ecf0250f7f0868f3b828ffadd47d0e5f2dbd875.zip binutils-7ecf0250f7f0868f3b828ffadd47d0e5f2dbd875.tar.gz binutils-7ecf0250f7f0868f3b828ffadd47d0e5f2dbd875.tar.bz2 |
Improve the placement of orphan note sections.
PR 32219
Diffstat (limited to 'ld/ldelf.c')
-rw-r--r-- | ld/ldelf.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -2118,7 +2118,7 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint) { ".bss", SEC_ALLOC, 0, 0, 0, 0 }, - { 0, + { NULL, SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_DATA, 0, 0, 0, 0 }, { ".interp", @@ -2328,7 +2328,18 @@ ldelf_place_orphan (asection *s, const char *secname, int constraint) && (elfinput ? sh_type == SHT_NOTE : startswith (secname, ".note"))) - place = &hold[orphan_interp]; + { + /* PR 32219: Check that the .interp section + exists before attaching orphans to it. */ + if (lang_output_section_find (hold[orphan_interp].name)) + place = &hold[orphan_interp]; + /* Next best place: after .rodata. */ + else if (lang_output_section_find (hold[orphan_rodata].name)) + place = &hold[orphan_rodata]; + /* Last attempt: the .text section. */ + else + place = &hold[orphan_text]; + } else if ((flags & (SEC_LOAD | SEC_HAS_CONTENTS | SEC_THREAD_LOCAL)) == 0) place = &hold[orphan_bss]; else if ((flags & SEC_SMALL_DATA) != 0) |