Skip to contentSkip to conversation

Bug in MIPS linker scripts?

U-Boot-Users Robert Deliën 1 participant 1 message Dec 14, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

I believe I have found a nasty bug in my target's linker script. And since all MIPS targets use copies of more-or-less the same linker script, I think all MIPS targets suffer from this bug.

It's alignment dependent whether the bug will cause a problem or not. The symptoms can vary from hang-ups in find_cmd for any command to a hang-up if the first command in the command table is used (usually bdinfo).

The cause of this problem is the 'Update GOT' part in the function relocate in cpu/mips/start.S. Depending on alignment, this update part will update a number of entries too many, corrupting whatever is next in memory: The command table.

The cause of the problem is a misalignment between the _gp linker variable and the actual '.'. This is what's in board/mipstarget/u-boot.lds now:

	. = ALIGN(4);
	.sdata  : { *(.sdata) }

	_gp = ALIGN(16);

	__got_start = .;
	.got  : { *(.got) }
	__got_end = .;

	.sdata  : { *(.sdata) }

	__u_boot_cmd_start = .;

And this is what it's supposed to be:

	. = ALIGN(4);
	.sdata  : { *(.sdata) }

	. = ALIGN(16);
	_gp = .;
 
	__got_start = .;
	.got  : { *(.got) }
	__got_end = .;

	.sdata  : { *(.sdata) }

	__u_boot_cmd_start = .;

Who can give me any comments?

With kind regards,

Robert.