From: Reva Cuthbertson <reva@cup.hp.com>
To: schwab@suse.de
Cc: amodra@bigpond.net.au, sje@cup.hp.com,
binutils@sources.redhat.com, reva@cup.hp.com
Subject: Re: copy_private_bfd_data in bfd/elf.c question
Date: Tue, 16 Jul 2002 16:04:00 -0000 [thread overview]
Message-ID: <3D348D79.247E4141@cup.hp.com> (raw)
Hello,
I am still looking at code in copy_private_bfd_data()
which is causing problems with strip and objcopy on
IA-64 HP-UX. When the binutils version of strip and
objcopy are used on HP-UX, the resulting program gets
a segmentation violation when it is executed. As Andreas
pointed out in:
http://sources.redhat.com/ml/binutils/2002-06/msg00762.html
the cause for the segmentation violation was because strip
and objcopy were changing the offset of the .hash section. The
change in offset happens in assign_file_positions_for_segments()
which uses the segment's p_paddr field to calcuate the new position.
Unfortunately, the new position is not correctly aligned which
causes the segmentation violation.
The HP Linker sets the p_paddr field of all of the segments to 0.
There is code in copy_private_bfd_data() which detects this and
tries to "fix" things. From the comments, it appears that this is
done because the Solaris linker also sets p_paddr to 0. The
code in copy_private_bfd_data() is the following:
/* The Solaris native linker always sets p_paddr to 0.
We try to catch that case here, and set it to the
correct value. */
if (segment->p_paddr == 0
&& segment->p_vaddr != 0
&& isec == 0
&& output_section->lma != 0
&& (output_section->vma == (segment->p_vaddr
+ (map->includes_filehdr
? iehdr->e_ehsize
: 0)
+ (map->includes_phdrs
? (iehdr->e_phnum
* iehdr->e_phentsize)
: 0))))
map->p_paddr = segment->p_vaddr;
I am not sure why this code was needed for Solaris but
it needs to be disabled for HP-UX on IA-64. According to my
ELF Document it says that the p_paddr field of the program
header (segment) is reserved for systems with physical addressing.
HP-UX is not such a system and therefore I believe that p_paddr should
be left as 0. (It probably should be left as 0 for all systems which
do not do physical addressing, but that is another matter). In
any case, I tried to work around the fact that p_paddr is
recalculated by playing with section alignment but I ran into further
problems in assign_file_positons_for_segments(). I believe
the real fix is to disable setting p_paddr in copy_private_bfd_data().
I do have a fix for this which works on HP-UX. However, the
fix involves a compile-time check and I understand that compile-time
checks are discouraged in bfd. Is there a runtime check that
would do the same thing or do I need my own version of
copy_private_bfd_data()? Here is what I want to do:
#ifndef NO_PHYSICAL_ADDRESSING
/* The Solaris native linker always sets p_paddr to 0.
We try to catch that case here, and set it to the
correct value. */
if (segment->p_paddr == 0
&& segment->p_vaddr != 0
&& isec == 0
&& output_section->lma != 0
&& (output_section->vma == (segment->p_vaddr
+ (map->includes_filehdr
? iehdr->e_ehsize
: 0)
+ (map->includes_phdrs
? (iehdr->e_phnum
*
iehdr->e_phentsize)
: 0))))
map->p_paddr = segment->p_vaddr;
#endif
/* Match up the physical address of the segment with the
LMA address of the output section. */
if (IS_CONTAINED_BY_LMA (output_section, segment,
map->p_paddr)
|| IS_CONTAINED_BY_FILEPOS (section, segment, bed)
#ifndef NO_PHYSICAL_ADDRESSING
|| IS_COREFILE_NOTE (segment, section))
#else
|| IS_COREFILE_NOTE (segment, section)
|| IS_CONTAINED_BY_VMA (output_section, segment))
#endif
{
if (matching_lma == 0)
matching_lma = output_section->lma;
/* We assume that if the section fits within the
segment
then it does not overlap any other section within
that
segment. */
map->sections[isec ++] = output_section;
}
else if (suggested_lma == 0)
suggested_lma = output_section->lma;
}
}
Is there an acceptable way to do this?
Thanks so much!
Reva Cuthbertson
reva@cup.hp.com
next reply other threads:[~2002-07-16 21:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-16 16:04 Reva Cuthbertson [this message]
[not found] ` <m3vg7cvz6j.fsf@north-pole.nickc.cambridge.redhat.com>
[not found] ` <3D3C766C.91969D78@cup.hp.com>
2002-07-23 5:13 ` Nick Clifton
-- strict thread matches above, loose matches on Subject: below --
2002-07-23 9:13 Steve Ellcey
2002-07-23 9:43 ` Daniel Jacobowitz
2002-07-23 11:00 ` Nick Clifton
2002-06-28 16:06 Reva Cuthbertson
2002-06-29 10:30 ` Andreas Schwab
2002-07-08 14:16 ` Reva Cuthbertson
2002-06-24 8:49 Steve Ellcey
2002-06-21 8:26 Steve Ellcey
2002-06-21 9:28 ` Andreas Schwab
2002-06-22 4:56 ` Alan Modra
2002-06-22 12:23 ` Andreas Schwab
2002-06-22 22:05 ` Alan Modra
2002-06-22 22:11 ` Alan Modra
2002-06-20 10:14 Steve Ellcey
2002-06-20 20:54 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D348D79.247E4141@cup.hp.com \
--to=reva@cup.hp.com \
--cc=amodra@bigpond.net.au \
--cc=binutils@sources.redhat.com \
--cc=schwab@suse.de \
--cc=sje@cup.hp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).