gold patch committed (Was: Re: Help needed to track down bug: linking Linux kernel with gold creates unbootable kernel)

Ian Lance Taylor iant@google.com
Fri Apr 23 04:49:00 GMT 2010


John Reiser <jreiser@bitwagon.com> writes:

>> Linux kernel linker scripts needs to align .rodata section to 2MB:
>>
>> . = ALIGN((1<<  21));
>>
>> Since gold can only align to 4K, gold can't be used on Linux
>> kernel.
>
> The linker script statement ". = ALIGN((1<<  21));" requires alignment
> to 2 MiB.  If gold "can only align to 4 KiB", then gold must emit an
> error message upon processing input that requires a larger alignment.
> It is a bug that current gold does not emit such a message for this case.

The problem is that the alignment requested by the linker script is
not reflected in the linker output.  That actually appears to be true
of the GNU linker as well.  Logically, an alignment requested in the
linker script should be reflected in the program segments.

I committed this patch to make an alignment requested in the linker
script be reflected in the p_align field of the generated program
headers.  I don't know if this actually fixes the problem, but it
seems like the right thing to do.

Ian


2010-04-22  Ian Lance Taylor  <iant@google.com>

	* expression.cc (Expression::Expression_eval_info): Add
	result_alignment_pointer field.
	(Expression::eval_with_dot): Add result_alignment_pointer
	parameter.  Change all callers.
	(Expression::eval_maybe_dot): Likewise.
	(class Binary_expression): Add alignment_pointer parameter to
	left_value and right_value.  Change all callers.
	(BINARY_EXPRESSION): Set result alignment.
	(class Trinary_expression): Add alignment_pointer parameter to
	arg2_value and arg3_value.  Change all callers.
	(Trinary_cond::value): Set result alignment.
	(Max_expression::value, Min_expression::value): Likewise.
	(Align_expression::value): Likewise.
	* script-sections.cc (class Sections_element): Add dot_alignment
	parameter to set_section_addresses virtual function.  Update
	instantiations.
	(class Output_section_element): Likewise.
	(Script_sections::create_segments): Add dot_alignment parameter.
	Change all callers.
	(Script_sections::create_segments_from_phdrs_clause): Likewise.
	(Script_sections::set_phdrs_clause_addresses): Likewise.
	* script-sections.h: Update declarations.
	* script.h: Update declarations.
	* output.h (Output_segment::set_minimum_p_align): Don't decrease
	min_p_align.
	* testsuite/script_test_3.t: Set large alignment.
	* testsuite/script_test_3.sh: Make sure that at least one LOAD
	segment has expected alignment.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-diff
Size: 28992 bytes
Desc: align
URL: <https://sourceware.org/pipermail/binutils/attachments/20100423/356a1397/attachment.bin>


More information about the Binutils mailing list