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.
This commit is contained in:
Alan Modra 2020-03-04 21:14:19 +10:30
parent 46f9f93119
commit baf09cba8f
2 changed files with 30 additions and 13 deletions

View File

@ -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

View File

@ -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);
}