This is the mail archive of the binutils@sources.redhat.com 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]

Re: PATCH: IA64 linker relaxation bug


On Tue, 2003-11-04 at 16:10, H. J. Lu wrote:
> The problem is lang_do_assignments assigns 0x6000000000004fa0 and
> lang_size_sections assigns 0x6000000000000430. The final one is
> 0x6000000000000430.

> I am testing this patch. Does this make any senses?

It would help if you gave some reason why you think it makes sense.  I
couldn't make any sense of it, as it seemed like you were just adding
another arbitrary relaxation pass at the end.

The real problem seems to me to be the fact that lang_do_assignments is
computing a different value than lang_size_sections.  I tracked this
down to a problem with _raw_size.  The first thing we do is call
lang_reset_memory_regions which clears _raw_size.  Then we call
lang_do_assignments.  After each section, it sets dot to
       dot = os->bfd_section->vma + os->bfd_section->_raw_size / opb;
but since we already cleared _raw_size, this means dot is set to the
address of the start of the section rather than the address of the end
of the section.  The result is that any symbol which is between
sections, and whose value depends on dot, gets the wrong address during
lang_do_assignment.

As far as I can tell, the values cleared by lang_reset_memory_regions
are not used in lang_do_assignments, other than _raw_size, so the right
solution is to move the lang_reset_memory_regions call after the
lang_do_assignments call.  This does solve the problem.

While looking at this, I noticed that we are accidentally running two
relax_finalize passes instead of the expected one.  This is because
elfNN_ia64_relax_section sets relax_again to true, and the relation loop
blindly gives us another iteration.  It seems reasonable to fix the ia64
port to not ask for another relaxation round in this case.  This part I
am not as sure about, but it does seem to make sense.

I also noticed that we always run the relax_finalize pass, even though
the ia64 port is the only one that uses it.  Perhaps we need some target
flag or hook to indicate which targets need this extra relaxation pass. 
I did not try to solve this problem.

The patch I came up with follows in an attachment.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

Attachment: tmp.relax.patch
Description: Text document


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