projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dynrelro section for read-only dynamic symbols copied into executable
[deliverable/binutils-gdb.git]
/
bfd
/
elfnn-riscv.c
diff --git
a/bfd/elfnn-riscv.c
b/bfd/elfnn-riscv.c
index db4b7821df1620953de0509b33aeae89b0a7bfc4..69907bd241f103b7efbb1d2ea6e238032e2fe1fd 100644
(file)
--- a/
bfd/elfnn-riscv.c
+++ b/
bfd/elfnn-riscv.c
@@
-862,7
+862,7
@@
riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
struct riscv_elf_link_hash_entry * eh;
struct riscv_elf_dyn_relocs *p;
bfd *dynobj;
struct riscv_elf_link_hash_entry * eh;
struct riscv_elf_dyn_relocs *p;
bfd *dynobj;
- asection *s;
+ asection *s
, *srel
;
htab = riscv_elf_hash_table (info);
BFD_ASSERT (htab != NULL);
htab = riscv_elf_hash_table (info);
BFD_ASSERT (htab != NULL);
@@
-965,16
+965,26
@@
riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
to copy the initial value out of the dynamic object and into the
runtime process image. We need to remember the offset into the
.rel.bss section we are going to use. */
to copy the initial value out of the dynamic object and into the
runtime process image. We need to remember the offset into the
.rel.bss section we are going to use. */
+ if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ {
+ s = htab->elf.sdynrelro;
+ srel = htab->elf.sreldynrelro;
+ }
+ else
+ {
+ s = htab->elf.sdynbss;
+ srel = htab->elf.srelbss;
+ }
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
{
if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
{
-
htab->elf.srelbss
->size += sizeof (ElfNN_External_Rela);
+
srel
->size += sizeof (ElfNN_External_Rela);
h->needs_copy = 1;
}
if (eh->tls_type & ~GOT_NORMAL)
return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdyntdata);
h->needs_copy = 1;
}
if (eh->tls_type & ~GOT_NORMAL)
return _bfd_elf_adjust_dynamic_copy (info, h, htab->sdyntdata);
- return _bfd_elf_adjust_dynamic_copy (info, h,
htab->elf.sdynbs
s);
+ return _bfd_elf_adjust_dynamic_copy (info, h, s);
}
/* Allocate space in .plt, .got and associated reloc sections for
}
/* Allocate space in .plt, .got and associated reloc sections for
@@
-1328,7
+1338,8
@@
riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
if (s == htab->elf.splt
|| s == htab->elf.sgot
|| s == htab->elf.sgotplt
if (s == htab->elf.splt
|| s == htab->elf.sgot
|| s == htab->elf.sgotplt
- || s == htab->elf.sdynbss)
+ || s == htab->elf.sdynbss
+ || s == htab->elf.sdynrelro)
{
/* Strip this section if we don't need it; see the
comment below. */
{
/* Strip this section if we don't need it; see the
comment below. */
@@
-2389,6
+2400,7
@@
riscv_elf_finish_dynamic_symbol (bfd *output_bfd,
if (h->needs_copy)
{
Elf_Internal_Rela rela;
if (h->needs_copy)
{
Elf_Internal_Rela rela;
+ asection *s;
/* This symbols needs a copy reloc. Set it up. */
BFD_ASSERT (h->dynindx != -1);
/* This symbols needs a copy reloc. Set it up. */
BFD_ASSERT (h->dynindx != -1);
@@
-2396,7
+2408,11
@@
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;
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;
- riscv_elf_append_rela (output_bfd, htab->elf.srelbss, &rela);
+ if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+ s = htab->elf.sreldynrelro;
+ else
+ s = htab->elf.srelbss;
+ riscv_elf_append_rela (output_bfd, s, &rela);
}
/* Mark some specially defined symbols as absolute. */
}
/* Mark some specially defined symbols as absolute. */
@@
-3213,6
+3229,7
@@
riscv_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
#define elf_backend_plt_alignment 4
#define elf_backend_want_plt_sym 1
#define elf_backend_got_header_size (ARCH_SIZE / 8)
#define elf_backend_plt_alignment 4
#define elf_backend_want_plt_sym 1
#define elf_backend_got_header_size (ARCH_SIZE / 8)
+#define elf_backend_want_dynrelro 1
#define elf_backend_rela_normal 1
#define elf_backend_default_execstack 0
#define elf_backend_rela_normal 1
#define elf_backend_default_execstack 0
This page took
0.024611 seconds
and
4
git commands to generate.