* ld.texi: Document new output section type.
* ldgram.y: Add new token.
* ldlang.c: Handle the new flag.
* ldlang.h: Add readonly_section to list of section types.
* ldlex.l: Add a new identifier.
* testsuite/ld-scripts/output-section-types.t: New example linker script.
* testsuite/ld-scripts/output-section-types.d: Test driver.
* testsyute/ld-scripts/script.exp: Run the new test.
@item NOLOAD
The section should be marked as not loadable, so that it will not be
loaded into memory when the program is run.
+@item READONLY
+The section should be marked as read-only.
@item DSECT
@itemx COPY
@itemx INFO
%token REGION_ALIAS
%token LD_FEATURE
%token NOLOAD DSECT COPY INFO OVERLAY
+%token READONLY
%token DEFINED TARGET_K SEARCH_DIR MAP ENTRY
%token <integer> NEXT
%token SIZEOF ALIGNOF ADDR LOADADDR MAX_K MIN_K
| COPY { sectype = noalloc_section; }
| INFO { sectype = noalloc_section; }
| OVERLAY { sectype = noalloc_section; }
+ | READONLY { sectype = readonly_section; }
;
atype:
case noalloc_section:
flags &= ~SEC_ALLOC;
break;
+ case readonly_section:
+ flags |= SEC_READONLY;
+ break;
case noload_section:
flags &= ~SEC_LOAD;
flags |= SEC_NEVER_LOAD;
case noalloc_section:
flags = SEC_HAS_CONTENTS;
break;
+ case readonly_section:
+ flags |= SEC_READONLY;
+ break;
case noload_section:
if (bfd_get_flavour (link_info.output_bfd)
== bfd_target_elf_flavour)
first_overlay_section,
overlay_section,
noload_section,
- noalloc_section
+ noalloc_section,
+ readonly_section
};
/* This structure holds a list of program headers describing
<BOTH,SCRIPT>"SORT_BY_INIT_PRIORITY" { RTOKEN(SORT_BY_INIT_PRIORITY); }
<BOTH,SCRIPT>"SORT_NONE" { RTOKEN(SORT_NONE); }
<EXPRESSION,BOTH,SCRIPT>"NOLOAD" { RTOKEN(NOLOAD);}
+<EXPRESSION,BOTH,SCRIPT>"READONLY" { RTOKEN(READONLY);}
<EXPRESSION,BOTH,SCRIPT>"DSECT" { RTOKEN(DSECT);}
<EXPRESSION,BOTH,SCRIPT>"COPY" { RTOKEN(COPY);}
<EXPRESSION,BOTH,SCRIPT>"INFO" { RTOKEN(INFO);}
--- /dev/null
+#ld: -Toutput-section-types.t
+#source: align2a.s
+#objdump: -h
+#target: [is_elf_format]
+
+#...
+ . \.rom.*
+[ ]+ALLOC, READONLY
+ . \.ro.*
+[ ]+CONTENTS, ALLOC, LOAD, READONLY, DATA
+ . \.over.*
+[ ]+CONTENTS, READONLY
+#pass
--- /dev/null
+SECTIONS {
+ .rom (NOLOAD) : { LONG(1234); }
+ .ro (READONLY) : { LONG(5678); }
+ .over (OVERLAY) : { LONG(0123); }
+ /DISCARD/ : { *(*) }
+
+}
run_dump_test "align-with-input"
run_dump_test "pr20302"
+run_dump_test "output-section-types"
run_dump_test "segment-start" {{name (default)}}
run_dump_test "segment-start" {{name (overridden)} \