This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gold patch] PR gold/13023: Fix problem with assignments to dot in linker scripts


PR 13023 complains about gold not handling assignments to dot
correctly. If an absolute value is assigned to dot within an output
section, the value should be treated as an offset relative to the
start of the section. This patch fixes that, and also fixes a related
problem where a dot-relative assignment to a symbol (e.g., "L0 = .")
would produce an absolute symbol rather than a symbol defined in that
section.

I've added a flag to eval_maybe_dot() so that it knows whether we're
assigning to the dot symbol in an output section, and adjusts absolute
values appropriately. I also had to pass in dot_section to
set_if_absolute() so that we can set the values for dot-relative
symbols during the set_section_addresses phase along with actual
absolute symbols.

I've updated script_test_2 to test this case, and also verified that
the test attached to the PR now works.

Tested on x86_64. OK to commit?

-cary


	PR gold/13023
	* expression.cc (Expression::eval_with_dot): Add
	is_section_dot_assignment parameter.
	(Expression::eval_maybe_dot): Likewise.  Adjust value when rhs is
	absolute and assigning to dot within a section.
	* script-sections.cc
	(Output_section_element_assignment::set_section_addresses): Pass
	dot_section to set_if_absolute.
	(Output_section_element_dot_assignment::finalize_symbols): Pass TRUE
	as is_section_dot_assignment flag to eval_with_dot.
	(Output_section_element_dot_assignment::set_section_addresses):
	Likewise.
	* script.cc (Symbol_assignment::set_if_absolute): Add dot_section
	parameter.  Also set value if relative to dot_section; set the
	symbol's output_section.
	* script.h (Expression::eval_with_dot): Add is_section_dot_assignment
	parameter.  Adjust all callers.
	(Expression::eval_maybe_dot): Likewise.
	(Symbol_assignment::set_if_absolute): Add dot_section parameter.
	Adjust all callers.
	* testsuite/script_test_2.t: Test assignment of an absolute value
	to dot within an output section element.

Attachment: gold-pr13023-patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]