public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* size_input_section calcs output_offset incorrectly for merged sections
@ 2008-01-07 17:23 Michael Eager
  2008-01-07 18:27 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Eager @ 2008-01-07 17:23 UTC (permalink / raw)
  To: binutils

I'm seeing a problem in size_input_section() when it
processes a merged section.  If the merged section is to
be included in the output, the output_offset value is
computed as:

    i->output_offset = dot - output_section_statement->bfd_section->vma;

If the section has been eliminated and is marked as SEC_EXCLUDE,
the section's output_offset value is computed as:

   i->output_offset = i->vma - output_section_statement->bfd_section->vma;

i->vma is zero, which results in output_offset being the inverse
of the output vma.  Later, during relaxation, output_offset is
added to vma resulting in an incorrect symbol address of zero.

It seems to me that output_offset should be the same in both
cases.  I've run a couple tests which work with this change.

Does this seem correct?

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: size_input_section calcs output_offset incorrectly for merged sections
  2008-01-07 17:23 size_input_section calcs output_offset incorrectly for merged sections Michael Eager
@ 2008-01-07 18:27 ` Alan Modra
  2008-01-07 23:57   ` Michael Eager
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2008-01-07 18:27 UTC (permalink / raw)
  To: Michael Eager; +Cc: binutils

On Sat, Jan 05, 2008 at 08:59:04AM -0800, Michael Eager wrote:
> It seems to me that output_offset should be the same in both
> cases.  I've run a couple tests which work with this change.
> 
> Does this seem correct?

No.  The code is correct for excluded sections in general.  You
shouldn't be using symbols from merged sections directly.  See
_bfd_merged_section_offset, _bfd_elf_rel{,a}_local_sym.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: size_input_section calcs output_offset incorrectly for merged  sections
  2008-01-07 18:27 ` Alan Modra
@ 2008-01-07 23:57   ` Michael Eager
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Eager @ 2008-01-07 23:57 UTC (permalink / raw)
  To: Alan Modra, binutils

Alan Modra wrote:
> On Sat, Jan 05, 2008 at 08:59:04AM -0800, Michael Eager wrote:
>> It seems to me that output_offset should be the same in both
>> cases.  I've run a couple tests which work with this change.
>>
>> Does this seem correct?
> 
> No.  The code is correct for excluded sections in general.  You
> shouldn't be using symbols from merged sections directly.  See
> _bfd_merged_section_offset, _bfd_elf_rel{,a}_local_sym.

Thanks.  Calling _bfd_elf_rela_local_sym worked.

-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-07  0:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-07 17:23 size_input_section calcs output_offset incorrectly for merged sections Michael Eager
2008-01-07 18:27 ` Alan Modra
2008-01-07 23:57   ` Michael Eager

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).