diff options
author | Alan Modra <amodra@gmail.com> | 2020-09-12 10:49:13 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-01-18 23:07:40 +1030 |
commit | 326adec374dd43086dbf9bb2b8f18d547389e678 (patch) | |
tree | 4ec75ed52a3113978a6a585d2270d25ca20f2865 /ld/ldlang.c | |
parent | d3d7d1ba3bbf899bd318a6d4e63ba24534ad5e86 (diff) | |
download | gdb-326adec374dd43086dbf9bb2b8f18d547389e678.zip gdb-326adec374dd43086dbf9bb2b8f18d547389e678.tar.gz gdb-326adec374dd43086dbf9bb2b8f18d547389e678.tar.bz2 |
PR26378, sections initialised only by linker scripts are always read/write
This changes the initialisation of output sections so that it is
possible to create read-only sections fed only from linker script
BYTE, SHORT, LONG or QUAD. That currently isn't possible even for one
of the well-known ELF sections like .rodata, because once a section is
marked read/write that sticks. On the other hand if we start
read-only, well-known ELF sections end up read/write as appropriate.
For example .tdata will still be SHF_ALLOC + SHF_WRITE + SHF_TLS.
PR 26378
* ldlang.c (map_input_to_output_sections): Start with a read-only
section for data statements.
* testsuite/ld-elf/size-2.d: Adjust to suit.
Diffstat (limited to 'ld/ldlang.c')
-rw-r--r-- | ld/ldlang.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ld/ldlang.c b/ld/ldlang.c index 4ae9cec..8014e7a 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -4225,7 +4225,7 @@ map_input_to_output_sections break; } if (os->bfd_section == NULL) - init_os (os, flags); + init_os (os, flags | SEC_READONLY); else os->bfd_section->flags |= flags; break; |