sparc gold support...

Ian Lance Taylor iant@google.com
Wed Apr 2 21:03:00 GMT 2008


David Miller <davem@davemloft.net> writes:

> Ok, next problem is archive handling on systems that
> trap on unaligned accesses.
>
> Offsets within and archive into members can have all kinds of odd
> offsets.  The object file reader infrastructure in gold assumes it can
> just reference views via mmap().
>
> But if the offset is odd, this doesn't work and results on SIGBUS
> errors on platforms like Sparc.  This occurs as the ELF bits larger
> than a byte in size get dereferenced.
>
> It looks like a buffered version of the file view reader will need to
> be implemented, and used instead of mmap() if the offset is not a
> multiple of the largest core type size on the host (for sparc this
> would need to be something like sizeof(double), but generically I
> suppose something like sizeof(unsigned long long) could be used).

Thanks for the analysis.  I really should have thought of that, but it
never occurred to me.

I just committed the appended patch which should fix this.  I added an
aligned parameter to the get_view and get_lasting_view functions which
indicates whether the caller needs aligned data.  The initial file
offset is also passed down separately from the offset within the file;
this is used to see whether any alignment is required.  We then record
for each View how much the data has been shifted.  Let me know what
happens--you should be able to test it with a cross-linker running on
a SPARC host.

While testing the performance I noticed that we waste a lot of time
clearing views in an archive during a static link--or, rather, not
clearing views, as in general they are marked to be cached.  It was
actually wasting 18% of CPU time doing a static link of hello, world.
This patch includes a couple of conceptually unrelated changes to not
waste so much time doing that.

Ian


2008-04-02  Ian Lance Taylor  <iant@google.com>

	* fileread.cc (File_read::find_view): Add byteshift and vshifted
	parameters.  Update for new key type to views_.  Change all
	callers.
	(File_read::read): Adjust for byteshift in returned view.
	(File_read::add_view): New function, broken out of
	find_and_make_view.
	(File_read::make_view): New function, broken out of
	find_and_make_view.
	(File_read::find_or_make_view): Add offset and aligned
	parameters.  Rewrite accordingly.  Change all callers.
	(File_read::get_view): Add offset and aligned parameters.  Adjust
	for byteshift in return value.
	(File_read::get_lasting_view): Likewise.
	* fileread.h (class File_read): Update declarations.
	(class File_read::View): Add byteshift_ field.  Add byteshift to
	constructor.  Add byteshift method.
	* archive.h (Archive::clear_uncached_views): New function.
	(Archive::get_view): Add aligned parameter.  Change all callers.
	* object.h (Object::get_view): Add aligned parameter.  Change all
	callers.
	(Object::get_lasting_view): Likewise.

	* fileread.cc (File_read::release): Don't call clear_views if
	there are multiple objects.
	* fileread.h (File_read::clear_uncached_views): New function.
	* archive.cc (Add_archive_symbols::run): Call clear_uncached_views
	on the archive.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.patch
Type: text/x-patch
Size: 28152 bytes
Desc: Align data in archives as required
URL: <https://sourceware.org/pipermail/binutils/attachments/20080402/796c9bb0/attachment.bin>


More information about the Binutils mailing list