diff options
author | Alan Modra <amodra@gmail.com> | 2017-02-28 08:06:02 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2017-02-28 17:03:30 +1030 |
commit | 3137ed4276c7bcbab65d18c6274145a6efd9f03f (patch) | |
tree | 364a33eec178120ae11106b524730a0f7a50f4ba /bfd/elflink.c | |
parent | 6ad77d075598bb0ba6c60a594454250d217019e5 (diff) | |
download | gdb-3137ed4276c7bcbab65d18c6274145a6efd9f03f.zip gdb-3137ed4276c7bcbab65d18c6274145a6efd9f03f.tar.gz gdb-3137ed4276c7bcbab65d18c6274145a6efd9f03f.tar.bz2 |
Don't make dynamic .data.rel.ro SEC_READONLY
I'd made this dynamic section read-only so a flag test distinguished
it from .dynbss, but like any other .data.rel.ro section it really
should be marked read-write. (It is read-only after relocation, not
before.) When using the standard linker scripts this usually doesn't
matter since the output section is among other read-write sections and
not page aligned. However, it might matter in the extraordinary case
of the dynamic section being the only .data.rel.ro section with the
output section just happening to be page aligned and a multiple of a
page in size. In that case the output section would be read-only, and
live it its own read-only PT_LOAD segment, which is incorrect.
* elflink.c (_bfd_elf_create_dynamic_sections): Don't make
dynamic .data.rel.ro read-only.
* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Compare section
rather than section flags when deciding where copy reloc goes.
* elf32-cris.c (elf_cris_finish_dynamic_symbol): Likewise.
* elf32-hppa.c (elf32_hppa_finish_dynamic_symbol): Likewise.
* elf32-i386.c (elf_i386_finish_dynamic_symbol): Likewise.
* elf32-metag.c (elf_metag_finish_dynamic_symbol): Likewise.
* elf32-microblaze.c (microblaze_elf_finish_dynamic_symbol): Likewise.
* elf32-nios2.c (nios2_elf32_finish_dynamic_symbol): Likewise.
* elf32-or1k.c (or1k_elf_finish_dynamic_symbol): Likewise.
* elf32-ppc.c (ppc_elf_finish_dynamic_symbol): Likewise.
* elf32-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
* elf32-tic6x.c (elf32_tic6x_finish_dynamic_symbol): Likewise.
* elf32-tilepro.c (tilepro_elf_finish_dynamic_symbol): Likewise.
* elf64-ppc.c (ppc64_elf_finish_dynamic_symbol): Likewise.
* elf64-s390.c (elf_s390_finish_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol): Likewise.
* elfnn-riscv.c (riscv_elf_finish_dynamic_symbol): Likewise.
* elfxx-mips.c (_bfd_mips_vxworks_finish_dynamic_symbol): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_finish_dynamic_symbol): Likewise.
* elfxx-tilegx.c (tilegx_elf_finish_dynamic_symbol): Likewise.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index a9df6bd..69b66f2 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -424,7 +424,7 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) initialize them at run time. The linker script puts the .dynbss section into the .bss section of the final image. */ s = bfd_make_section_anyway_with_flags (abfd, ".dynbss", - (SEC_ALLOC | SEC_LINKER_CREATED)); + SEC_ALLOC | SEC_LINKER_CREATED); if (s == NULL) return FALSE; htab->sdynbss = s; @@ -432,11 +432,10 @@ _bfd_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) if (bed->want_dynrelro) { /* Similarly, but for symbols that were originally in read-only - sections. */ + sections. This section doesn't really need to have contents, + but make it like other .data.rel.ro sections. */ s = bfd_make_section_anyway_with_flags (abfd, ".data.rel.ro", - (SEC_ALLOC | SEC_READONLY - | SEC_HAS_CONTENTS - | SEC_LINKER_CREATED)); + flags); if (s == NULL) return FALSE; htab->sdynrelro = s; |