* [binutils-gdb] Fix: Output section type does not been applied to section forced output by `. = .` assignment
@ 2023-09-27 12:22 Nick Clifton
0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2023-09-27 12:22 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=193327db9fdd4e37aaf66612532871d756e0760f
commit 193327db9fdd4e37aaf66612532871d756e0760f
Author: Hsinyuan Xavier <TheLastLin@hotmail.com>
Date: Wed Sep 27 13:21:43 2023 +0100
Fix: Output section type does not been applied to section forced output by `. = .` assignment
PR 30875
* ldlang.c (get_os_init_flag): New function. (exp_init_os, map_input_to_output_sections): Use it.
Diff:
---
ld/ChangeLog | 6 ++++++
ld/ldlang.c | 20 ++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 99029f1e186..3e41bdc294e 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2023-09-27 Hsinyuan Xavier <TheLastLin@hotmail.com>
+
+ PR 30875
+ * ldlang.c (get_os_init_flag): New function.
+ (exp_init_os, map_input_to_output_sections): Use it.
+
2023-07-24 Johannes Schauer Marin Rodrigues <josch@debian.org>
* pe-dll.c (fill_edata): If inserting a timestamp, use the value
diff --git a/ld/ldlang.c b/ld/ldlang.c
index f7760fed69b..b40b4a5a0ed 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2443,6 +2443,20 @@ init_os (lang_output_section_statement_type *s, flagword flags)
"section alignment");
}
+static flagword
+get_os_init_flag (lang_output_section_statement_type * os)
+{
+ if (os != NULL)
+ switch (os->sectype)
+ {
+ case readonly_section: return SEC_READONLY;
+ case noload_section: return SEC_NEVER_LOAD;
+ default: break;
+ }
+
+ return 0;
+}
+
/* Make sure that all output sections mentioned in an expression are
initialized. */
@@ -2486,7 +2500,7 @@ exp_init_os (etree_type *exp)
os = lang_output_section_find (exp->name.name);
if (os != NULL && os->bfd_section == NULL)
- init_os (os, 0);
+ init_os (os, get_os_init_flag (os));
}
}
break;
@@ -4262,14 +4276,16 @@ map_input_to_output_sections
if (os != NULL && os->bfd_section == NULL)
init_os (os, 0);
break;
+
case lang_assignment_statement_enum:
if (os != NULL && os->bfd_section == NULL)
- init_os (os, 0);
+ init_os (os, get_os_init_flag (os));
/* Make sure that any sections mentioned in the assignment
are initialized. */
exp_init_os (s->assignment_statement.exp);
break;
+
case lang_address_statement_enum:
/* Mark the specified section with the supplied address.
If this section was actually a segment marker, then the
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-27 12:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 12:22 [binutils-gdb] Fix: Output section type does not been applied to section forced output by `. = .` assignment Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).