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: copy_private_bfd_data in bfd/elf.c question


Andreas,

    Thanks for the response!  I just got back into the office
today and had a chance to dig further.  It appears that
in bfd, the flags for the .hash section contain both
SEC_ALLOC and SEC_LOAD.   Unfortunately, this is a problem
in assign_file_positions_for_segments() because we check
for SEC_LOAD first and we only check for SEC_ALLOC IF
SEC_LOAD was not set:

for (i = 0, secpp = m->sections; i < m->count; i++, secpp++)
 {
   asection *sec;
   flagword flags;
   bfd_size_type align;

   sec = *secpp;
   flags = sec->flags;
   align = 1 << bfd_get_section_alignment (abfd, sec);

                .
                .
                .
if (p->p_type == PT_LOAD)
     {
       bfd_signed_vma adjust;

       if ((flags & SEC_LOAD) != 0)
       {
         adjust = sec->lma - (p->p_paddr + p->p_memsz);
         if (adjust < 0)
         adjust = 0;
       }
       else if ((flags & SEC_ALLOC) != 0)
       {
         /* The section VMA must equal the file position
             modulo the page size.  FIXME: I'm not sure if
             this adjustment is really necessary.  We used to
             not have the SEC_LOAD case just above, and then
             this was necessary, but now I'm not sure.  */
         if ((abfd->flags & D_PAGED) != 0)
           adjust = (sec->vma - voff) % bed->maxpagesize;
         else
           adjust = (sec->vma - voff) % align;
        }

In this code, if the flags for the .hash section did not include SEC_LOAD,
we would have executed the "else" statement and taken alignment into
account.  However, for some reason the flags did include SEC_LOAD so
we never took alignment into account.    I don't know where the flags
for the .hash section get set in bfd.  In particular, I do not know why
the .hash section flags contain SEC_LOAD.  Does this look right?  If so,
shouldn't we take always take alignment into account when calculating
"adjust"?

Thanks!

Reva Cuthbertson
reva@cup.hp.com

Andreas Schwab wrote:

> Reva Cuthbertson <reva@cup.hp.com> writes:
>
> |> A fix that we came up with is to disable the code
> |> that sets p_paddr in copy_private_bfd_data().  We did
> |> this and it worked fine.  The other thing I noticed
> |> is that the alignment specification for .hash is 8.
> |> We never check this value when calculating file
> |> position because that is only done of the section's
> |> flags include SEC_ALLOC which is not the case with
> |> the .hash section.
>
> That looks odd.  The secion flags of .hash include SHF_ALLOC, which
> should be translated to SEC_ALLOC in BFD.  If .hash isn't SEC_ALLOC then
> something is wrong here.
>
> Andreas.
>
> --
> Andreas Schwab, SuSE Labs, schwab@suse.de
> SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
> Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."


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