aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-04 21:14:19 +1030
committerAlan Modra <amodra@gmail.com>2020-03-05 09:48:04 +1030
commitbaf09cba8f97be8044f7422cb31b1cb3f23e2762 (patch)
treec77d7fde7e0d7150e2ecc75753c616de57bb74bd
parent46f9f93119daaa8eceb7233a17759e10e858c9fd (diff)
downloadgdb-baf09cba8f97be8044f7422cb31b1cb3f23e2762.zip
gdb-baf09cba8f97be8044f7422cb31b1cb3f23e2762.tar.gz
gdb-baf09cba8f97be8044f7422cb31b1cb3f23e2762.tar.bz2
PR25570, ld duplicate "warning: changing start of section"
Note that because we should report a signed delta from the previous VMA it isn't possible to use ngettext. ngettext only supports unsigned long values. So byte/bytes goes from the message. PR 25570 * ldlang.c (lang_sizing_iteration): New static var. (lang_size_sections_1): Warn about no memory region only on first iteration. Warn about changing start address on first iteration then any delta from that on subsequent iterations. Report a signed delta. (one_lang_size_sections_pass): Increment lang_sizing_iteration.
-rw-r--r--ld/ChangeLog10
-rw-r--r--ld/ldlang.c33
2 files changed, 30 insertions, 13 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 94fe79f..b634dd8 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,13 @@
+2020-03-05 Alan Modra <amodra@gmail.com>
+
+ PR 25570
+ * ldlang.c (lang_sizing_iteration): New static var.
+ (lang_size_sections_1): Warn about no memory region only on first
+ iteration. Warn about changing start address on first iteration
+ then any delta from that on subsequent iterations. Report a signed
+ delta.
+ (one_lang_size_sections_pass): Increment lang_sizing_iteration.
+
2020-03-03 Nick Clifton <nickc@redhat.com>
PR 25588
diff --git a/ld/ldlang.c b/ld/ldlang.c
index be9ac36..6ffa7af 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -131,10 +131,13 @@ struct lang_nocrossrefs *nocrossref_list;
struct asneeded_minfo **asneeded_list_tail;
static ctf_file_t *ctf_output;
- /* Functions that traverse the linker script and might evaluate
- DEFINED() need to increment this at the start of the traversal. */
+/* Functions that traverse the linker script and might evaluate
+ DEFINED() need to increment this at the start of the traversal. */
int lang_statement_iteration = 0;
+/* Count times through one_lang_size_sections_pass after mark phase. */
+static int lang_sizing_iteration = 0;
+
/* Return TRUE if the PATTERN argument is a wildcard pattern.
Although backslashes are treated specially if a pattern contains
wildcards, we do not consider the mere presence of a backslash to
@@ -5554,7 +5557,7 @@ lang_size_sections_1
&& (strcmp (lang_memory_region_list->name_list.name,
DEFAULT_MEMORY_REGION) != 0
|| lang_memory_region_list->next != NULL)
- && expld.phase != lang_mark_phase_enum)
+ && lang_sizing_iteration == 1)
{
/* By default this is an error rather than just a
warning because if we allocate the section to the
@@ -5586,19 +5589,21 @@ lang_size_sections_1
if (section_alignment > 0)
{
bfd_vma savedot = newdot;
- newdot = align_power (newdot, section_alignment);
+ bfd_vma diff = 0;
+ newdot = align_power (newdot, section_alignment);
dotdelta = newdot - savedot;
- if (dotdelta != 0
+
+ if (lang_sizing_iteration == 1)
+ diff = dotdelta;
+ else if (lang_sizing_iteration > 1)
+ diff = newdot - os->bfd_section->vma;
+ if (diff != 0
&& (config.warn_section_align
- || os->addr_tree != NULL)
- && expld.phase != lang_mark_phase_enum)
- einfo (ngettext ("%P: warning: changing start of "
- "section %s by %lu byte\n",
- "%P: warning: changing start of "
- "section %s by %lu bytes\n",
- (unsigned long) dotdelta),
- os->name, (unsigned long) dotdelta);
+ || os->addr_tree != NULL))
+ einfo (_("%P: warning: "
+ "start of section %s changed by %ld\n"),
+ os->name, (long) diff);
}
bfd_set_section_vma (os->bfd_section, newdot);
@@ -6036,6 +6041,8 @@ void
one_lang_size_sections_pass (bfd_boolean *relax, bfd_boolean check_regions)
{
lang_statement_iteration++;
+ if (expld.phase != lang_mark_phase_enum)
+ lang_sizing_iteration++;
lang_size_sections_1 (&statement_list.head, abs_output_section,
0, 0, relax, check_regions);
}