aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2017-02-28 08:06:02 +1030
committerAlan Modra <amodra@gmail.com>2017-02-28 17:03:30 +1030
commit3137ed4276c7bcbab65d18c6274145a6efd9f03f (patch)
tree364a33eec178120ae11106b524730a0f7a50f4ba
parent6ad77d075598bb0ba6c60a594454250d217019e5 (diff)
downloadgdb-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.
-rw-r--r--bfd/ChangeLog26
-rw-r--r--bfd/elf32-arm.c2
-rw-r--r--bfd/elf32-cris.c2
-rw-r--r--bfd/elf32-hppa.c2
-rw-r--r--bfd/elf32-i386.c2
-rw-r--r--bfd/elf32-metag.c2
-rw-r--r--bfd/elf32-microblaze.c2
-rw-r--r--bfd/elf32-nios2.c2
-rw-r--r--bfd/elf32-or1k.c2
-rw-r--r--bfd/elf32-ppc.c2
-rw-r--r--bfd/elf32-s390.c2
-rw-r--r--bfd/elf32-tic6x.c2
-rw-r--r--bfd/elf32-tilepro.c2
-rw-r--r--bfd/elf64-ppc.c2
-rw-r--r--bfd/elf64-s390.c2
-rw-r--r--bfd/elf64-x86-64.c2
-rw-r--r--bfd/elflink.c9
-rw-r--r--bfd/elfnn-aarch64.c2
-rw-r--r--bfd/elfnn-riscv.c2
-rw-r--r--bfd/elfxx-mips.c2
-rw-r--r--bfd/elfxx-sparc.c2
-rw-r--r--bfd/elfxx-tilegx.c2
22 files changed, 50 insertions, 25 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a791fd0..5a61bd5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,31 @@
2017-02-28 Alan Modra <amodra@gmail.com>
+ * 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.
+
+2017-02-28 Alan Modra <amodra@gmail.com>
+
* reloc.c (BFD_RELOC_PPC_16DX_HA): New.
* elf64-ppc.c (ppc64_elf_howto_raw <R_PPC64_16DX_HA>): New howto.
(ppc64_elf_reloc_type_lookup): Translate new bfd reloc.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 8171b0b..0a78595 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -16311,7 +16311,7 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd,
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY);
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->root.sdynrelro)
s = htab->root.sreldynrelro;
else
s = htab->root.srelbss;
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index a69c7e4..97b8cc3 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -2275,7 +2275,7 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
&& (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak));
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->root.sdynrelro)
s = htab->root.sreldynrelro;
else
s = htab->root.srelbss;
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index d5b911c..1deebf4 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -4432,7 +4432,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd,
+ eh->root.u.def.section->output_section->vma);
rela.r_addend = 0;
rela.r_info = ELF32_R_INFO (eh->dynindx, R_PARISC_COPY);
- if ((eh->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (eh->root.u.def.section == htab->etab.sdynrelro)
sec = htab->etab.sreldynrelro;
else
sec = htab->etab.srelbss;
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index b564d67..24beba3 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -5666,7 +5666,7 @@ do_glob_dat:
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_386_COPY);
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index 40a2baf..c45d719 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -3229,7 +3229,7 @@ elf_metag_finish_dynamic_symbol (bfd *output_bfd,
+ eh->root.u.def.section->output_section->vma);
rel.r_addend = 0;
rel.r_info = ELF32_R_INFO (eh->dynindx, R_METAG_COPY);
- if ((eh->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (eh->root.u.def.section == htab->etab.sdynrelro)
s = htab->etab.sreldynrelro;
else
s = htab->etab.srelbss;
diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c
index 52c60ef..7765fe8 100644
--- a/bfd/elf32-microblaze.c
+++ b/bfd/elf32-microblaze.c
@@ -3269,7 +3269,7 @@ microblaze_elf_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_MICROBLAZE_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c
index 3e4706f..d07ef67 100644
--- a/bfd/elf32-nios2.c
+++ b/bfd/elf32-nios2.c
@@ -5280,7 +5280,7 @@ nios2_elf32_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_NIOS2_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->root.sdynrelro)
s = htab->root.sreldynrelro;
else
s = htab->root.srelbss;
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 8e0ef72..224cbb8 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -1949,7 +1949,7 @@ or1k_elf_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_OR1K_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->root.sdynrelro)
s = htab->root.sreldynrelro;
else
s = htab->root.srelbss;
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index b98e60d..0f3eb68 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -10366,7 +10366,7 @@ ppc_elf_finish_dynamic_symbol (bfd *output_bfd,
if (ppc_elf_hash_entry (h)->has_sda_refs)
s = htab->relsbss;
- else if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ else if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index e5cb3b4..fd1bc13 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -3827,7 +3827,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_390_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf32-tic6x.c b/bfd/elf32-tic6x.c
index 08361d9..f65e24f 100644
--- a/bfd/elf32-tic6x.c
+++ b/bfd/elf32-tic6x.c
@@ -1876,7 +1876,7 @@ elf32_tic6x_finish_dynamic_symbol (bfd * output_bfd,
+ h->root.u.def.section->output_offset);
rel.r_info = ELF32_R_INFO (h->dynindx, R_C6000_COPY);
rel.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c
index 660b112..fb06a47 100644
--- a/bfd/elf32-tilepro.c
+++ b/bfd/elf32-tilepro.c
@@ -3813,7 +3813,7 @@ tilepro_elf_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF32_R_INFO (h->dynindx, R_TILEPRO_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 28fbbb8..e7d4792 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -15463,7 +15463,7 @@ ppc64_elf_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_PPC64_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
srel = htab->elf.sreldynrelro;
else
srel = htab->elf.srelbss;
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index edc9b86..b5fd05f 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -3623,7 +3623,7 @@ elf_s390_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = ELF64_R_INFO (h->dynindx, R_390_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index a058eca..e0e6c16 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -6189,7 +6189,7 @@ do_glob_dat:
+ h->root.u.def.section->output_offset);
rela.r_info = htab->r_info (h->dynindx, R_X86_64_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
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;
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 6ea2d35..d632b3c 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -8946,7 +8946,7 @@ do_glob_dat:
+ h->root.u.def.section->output_offset);
rela.r_info = ELFNN_R_INFO (h->dynindx, AARCH64_R (COPY));
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->root.sdynrelro)
s = htab->root.sreldynrelro;
else
s = htab->root.srelbss;
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 732a989..ff25ebd 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2412,7 +2412,7 @@ riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
rela.r_offset = sec_addr (h->root.u.def.section) + h->root.u.def.value;
rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index c184d2e..723853f 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -11328,7 +11328,7 @@ _bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.value);
rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_COPY);
rel.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->root.sdynrelro)
srel = htab->root.sreldynrelro;
else
srel = htab->root.srelbss;
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index f66525e..80fda1b 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -4568,7 +4568,7 @@ _bfd_sparc_elf_finish_dynamic_symbol (bfd *output_bfd,
+ h->root.u.def.section->output_offset);
rela.r_info = SPARC_ELF_R_INFO (htab, NULL, h->dynindx, R_SPARC_COPY);
rela.r_addend = 0;
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;
diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c
index eb12695..76dfcd8 100644
--- a/bfd/elfxx-tilegx.c
+++ b/bfd/elfxx-tilegx.c
@@ -4198,7 +4198,7 @@ tilegx_elf_finish_dynamic_symbol (bfd *output_bfd,
/* This symbols needs a copy reloc. Set it up. */
BFD_ASSERT (h->dynindx != -1);
- if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ if (h->root.u.def.section == htab->elf.sdynrelro)
s = htab->elf.sreldynrelro;
else
s = htab->elf.srelbss;