* elf.c: Formatting.

(IS_SOLARIS_PT_INTERP): Add p_paddr and p_memsz checks.
	(INCLUDE_SECTION_IN_SEGMENT): Remove IS_SOLARIS_PT_INTERP.
	(copy_private_bfd_data): Set p_vaddr on broken Solaris PT_INTERP
	segments.
This commit is contained in:
Alan Modra 2002-07-08 08:13:37 +00:00
parent e9168c1e2b
commit aecc8f8acd
2 changed files with 57 additions and 37 deletions

View File

@ -1,3 +1,11 @@
2002-07-08 Alan Modra <amodra@bigpond.net.au>
* elf.c: Formatting.
(IS_SOLARIS_PT_INTERP): Add p_paddr and p_memsz checks.
(INCLUDE_SECTION_IN_SEGMENT): Remove IS_SOLARIS_PT_INTERP.
(copy_private_bfd_data): Set p_vaddr on broken Solaris PT_INTERP
segments.
2002-07-07 Mark Mitchell <mark@codesourcery.com>
Alan Modra <amodra@bigpond.net.au>

View File

@ -4533,15 +4533,15 @@ copy_private_bfd_data (ibfd, obfd)
the given segment. VMA addresses are compared. */
#define IS_CONTAINED_BY_VMA(section, segment) \
(section->vma >= segment->p_vaddr \
&& (section->vma + section->_raw_size) \
<= (SEGMENT_END (segment, segment->p_vaddr)))
&& (section->vma + section->_raw_size \
<= (SEGMENT_END (segment, segment->p_vaddr))))
/* Returns true if the given section is contained within
the given segment. LMA addresses are compared. */
#define IS_CONTAINED_BY_LMA(section, segment, base) \
(section->lma >= base \
&& (section->lma + section->_raw_size) \
<= SEGMENT_END (segment, base))
&& (section->lma + section->_raw_size \
<= SEGMENT_END (segment, base)))
/* Returns true if the given section is contained within the
given segment. Filepos addresses are compared in an elf
@ -4556,14 +4556,16 @@ copy_private_bfd_data (ibfd, obfd)
&& bfd_get_format (ibfd) == bfd_core \
&& s->vma == 0 && s->lma == 0 \
&& (bfd_vma) s->filepos >= p->p_offset \
&& (bfd_vma) s->filepos + s->_raw_size \
<= p->p_offset + p->p_filesz)
&& ((bfd_vma) s->filepos + s->_raw_size \
<= p->p_offset + p->p_filesz))
/* The complicated case when p_vaddr is 0 is to handle the Solaris
linker, which generates a PT_INTERP section with p_vaddr and
p_memsz set to 0. */
#define IS_SOLARIS_PT_INTERP(p, s) \
(p->p_vaddr == 0 \
&& p->p_paddr == 0 \
&& p->p_memsz == 0 \
&& p->p_filesz > 0 \
&& (s->flags & SEC_HAS_CONTENTS) != 0 \
&& s->_raw_size > 0 \
@ -4579,10 +4581,9 @@ copy_private_bfd_data (ibfd, obfd)
3. There is an output section associated with it,
4. The section has not already been allocated to a previous segment. */
#define INCLUDE_SECTION_IN_SEGMENT(section, segment, bed) \
(((((segment->p_paddr \
((((segment->p_paddr \
? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \
: IS_CONTAINED_BY_VMA (section, segment)) \
|| IS_SOLARIS_PT_INTERP (segment, section)) \
&& (section->flags & SEC_ALLOC) != 0) \
|| IS_COREFILE_NOTE (segment, section) \
|| (IS_CONTAINED_BY_FILEPOS (section, segment, bed) \
@ -4596,7 +4597,8 @@ copy_private_bfd_data (ibfd, obfd)
/* Returns true iff seg1 and seg2 overlap. */
#define SEGMENT_OVERLAPS(seg1, seg2) \
(!(SEGMENT_AFTER_SEGMENT (seg1, seg2) || SEGMENT_AFTER_SEGMENT (seg2, seg1)))
(!(SEGMENT_AFTER_SEGMENT (seg1, seg2) \
|| SEGMENT_AFTER_SEGMENT (seg2, seg1)))
/* Initialise the segment mark field. */
for (section = ibfd->sections; section != NULL; section = section->next)
@ -4605,7 +4607,7 @@ copy_private_bfd_data (ibfd, obfd)
/* Scan through the segments specified in the program header
of the input BFD. For this first scan we look for overlaps
in the loadable segments. These can be created by weird
parameters to objcopy. */
parameters to objcopy. Also, fix some solaris weirdness. */
for (i = 0, segment = elf_tdata (ibfd)->phdr;
i < num_segments;
i++, segment++)
@ -4613,6 +4615,16 @@ copy_private_bfd_data (ibfd, obfd)
unsigned int j;
Elf_Internal_Phdr *segment2;
if (segment->p_type == PT_INTERP)
for (section = ibfd->sections; section; section = section->next)
if (IS_SOLARIS_PT_INTERP (segment, section))
{
/* Mininal change so that the normal section to segment
assigment code will work. */
segment->p_vaddr = section->vma;
break;
}
if (segment->p_type != PT_LOAD)
continue;