This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] riscv: remove DL_RO_DYN_SECTION
- From: Jim Wilson <jimw at sifive dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: David Abdurachmanov <david dot abdurachmanov at gmail dot com>, GNU C Library <libc-alpha at sourceware dot org>, Jim Wilson <jimw at sifive dot com>, Palmer Dabbelt <palmer at sifive dot com>, DJ Delorie <dj at delorie dot com>
- Date: Tue, 9 Apr 2019 16:21:02 -0700
- Subject: Re: [PATCH] riscv: remove DL_RO_DYN_SECTION
- References: <firstname.lastname@example.org> <email@example.com>
On Tue, Apr 9, 2019 at 4:42 AM Florian Weimer <firstname.lastname@example.org> wrote:
> * David Abdurachmanov:
Do you or your employer have copyright assignments? For a trivial
patch like this, a copyright assignment shouldn't be necessary, but
would be necessary if you want to contribute more patches.
> > While working on enabling D front-end (GDC) in GCC we noticed that druntime
> > was segfaulting if it is linked dynamically. This was tracked to
> > DL_RO_DYN_SECTION.
My analysis of this when it first came up...
I believe this was blindly copied from MIPS, and that no one on the
RISC-V side will know why it is there, because it was blindly copied
Looking at the MIPS SVR4 ABI, I see
.dynamic This is the same as the generic ABI section of the same type, but
the MIPS-specific version does not include the SHF_WRITE at-
I don't see any other reason in the spec for this to be read-only, but
making it read-only probably improves program security. I don't see
an equivalent statement in the RISC-V ABI.
Looking at bfd/elfxx-mips.c _bfd_mips_elf_create_dynamic_sections(), we see code
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
| SEC_LINKER_CREATED | SEC_READONLY);
/* The psABI requires a read-only .dynamic section, but the VxWorks
EABI doesn't. */
s = bfd_get_linker_section (abfd, ".dynamic");
if (s != NULL)
if (! bfd_set_section_flags (abfd, s, flags))
that forces .dynamic to be read-only everywhere except vxworks. I
don't see equivalent code in the RISC-V bfd port.
Looking at ld, in emulparams/, there are multiple mips scripts that
set TEXT_DYNAMIC, which forces .dynamic into the text segment instead
of the data segment. This is then unset in the vxworks scripts.
Interestingly, hppa also sets TEXT_DYNAMIC, but the hppa support in
glibc is probably not well maintained. Anyways, there is no
equivalent code for RISC-V.
So it appears unnecessary for the RISC-V glibc port.
If MIPS dynamic linking support is ever added to the druntime library,
then it will need the same change that you made for RISC-V, so in that
case it would not be a RISC-V specific change. However, there aren't
a lot of people doing MIPS development work anymore, so this may never
PS Since I wrote my analysis, MIPS has been resurrected, so maybe
someone will care about that again.