* elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on

section file offset for !SEC_LOAD sections.
This commit is contained in:
Alan Modra 2002-03-23 13:14:33 +00:00
parent 0e10145828
commit dba143efb3
2 changed files with 19 additions and 11 deletions

View file

@ -1,3 +1,8 @@
2002-03-23 Alan Modra <amodra@bigpond.net.au>
* elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on
section file offset for !SEC_LOAD sections.
2002-03-21 Richard Earnshaw <rearnsha@arm.com> 2002-03-21 Richard Earnshaw <rearnsha@arm.com>
* elf32-arm.h (elf32_arm_final_link_relocate case R_ARM_GOTOFF) * elf32-arm.h (elf32_arm_final_link_relocate case R_ARM_GOTOFF)

View file

@ -655,9 +655,9 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name)
Note - we used to check the p_paddr field as well, and Note - we used to check the p_paddr field as well, and
refuse to set the LMA if it was 0. This is wrong refuse to set the LMA if it was 0. This is wrong
though as a perfectly valid, initialised segment can though, as a perfectly valid initialised segment can
have a p_paddr of zero. Some architectures, eg ARM, have a p_paddr of zero. Some architectures, eg ARM,
place special significance one the address 0 and place special significance on the address 0 and
executables need to be able to have a segment which executables need to be able to have a segment which
covers this address. */ covers this address. */
if (phdr->p_type == PT_LOAD if (phdr->p_type == PT_LOAD
@ -668,15 +668,18 @@ _bfd_elf_make_section_from_shdr (abfd, hdr, name)
|| (phdr->p_offset + phdr->p_filesz || (phdr->p_offset + phdr->p_filesz
>= hdr->sh_offset + hdr->sh_size))) >= hdr->sh_offset + hdr->sh_size)))
{ {
/* We used to do a relative adjustment here, but if ((flags & SEC_LOAD) == 0)
that doesn't work if the segment is packed with newsect->lma += phdr->p_paddr - phdr->p_vaddr;
code from multiple VMAs. Instead we calculate else
the LMA absoultely, based on the LMA of the /* We used to use the same adjustment for SEC_LOAD
segment (it is assumed that the segment will sections, but that doesn't work if the segment
contain sections with contiguous LMAs, even if is packed with code from multiple VMAs.
the VMAs are not). */ Instead we calculate the section LMA based on
newsect->lma = phdr->p_paddr the segment LMA. It is assumed that the
+ hdr->sh_offset - phdr->p_offset; segment will contain sections with contiguous
LMAs, even if the VMAs are not. */
newsect->lma = (phdr->p_paddr
+ hdr->sh_offset - phdr->p_offset);
break; break;
} }
} }