diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2016-09-29 12:58:29 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2016-09-29 12:58:40 -0700 |
commit | 93dc595d7659a8cf224a9fc33aa9071f38328334 (patch) | |
tree | ca3ecb2f8119d7437396be2cb8e90920bc193dbc /ld/emultempl | |
parent | bb805577d2b212411fb7b0a2d01644567fac4e8d (diff) | |
download | gdb-93dc595d7659a8cf224a9fc33aa9071f38328334.zip gdb-93dc595d7659a8cf224a9fc33aa9071f38328334.tar.gz gdb-93dc595d7659a8cf224a9fc33aa9071f38328334.tar.bz2 |
Don't merge 2 sections with different SHF_EXCLUDE
SEC_EXCLUDE is ignored when doing a relocatable link. But we can't
merge 2 input sections with the same name when only one of them has
SHF_EXCLUDE.
PR ld/20528
* emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Don't
merge 2 sections with different SHF_EXCLUDE.
* testsuite/ld-elf/pr20528a.d: New file.
* testsuite/ld-elf/pr20528a.s: Likewise.
* testsuite/ld-elf/pr20528b.d: Likewise.
* testsuite/ld-elf/pr20528b.s: Likewise.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/elf32.em | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index 8461b1d..2815a3e 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -1907,9 +1907,16 @@ gld${EMULATION_NAME}_place_orphan (asection *s, lang_insert_orphan to create a new output section. */ constraint = SPECIAL; + /* SEC_EXCLUDE is cleared when doing a relocatable link. But + we can't merge 2 input sections with the same name when only + one of them has SHF_EXCLUDE. */ if (os->bfd_section != NULL && (os->bfd_section->flags == 0 - || (((s->flags ^ os->bfd_section->flags) + || ((!bfd_link_relocatable (&link_info) + || (((elf_section_flags (s) + ^ elf_section_flags (os->bfd_section)) + & SHF_EXCLUDE) == 0)) + && ((s->flags ^ os->bfd_section->flags) & (SEC_LOAD | SEC_ALLOC)) == 0 && _bfd_elf_match_sections_by_type (link_info.output_bfd, os->bfd_section, |