diff options
author | Alan Modra <amodra@gmail.com> | 2002-03-23 13:14:33 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-03-23 13:14:33 +0000 |
commit | dba143efb31cb98d480dc790bb9cde79b846fa32 (patch) | |
tree | 095d83dd0eb78581b11bbac70c41dff0132d9161 /bfd/elf.c | |
parent | 0e101458287815d449beaaad59b6610e4709ee96 (diff) | |
download | gdb-dba143efb31cb98d480dc790bb9cde79b846fa32.zip gdb-dba143efb31cb98d480dc790bb9cde79b846fa32.tar.gz gdb-dba143efb31cb98d480dc790bb9cde79b846fa32.tar.bz2 |
* elf.c (_bfd_elf_make_section_from_shdr): Don't set lma based on
section file offset for !SEC_LOAD sections.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 25 |
1 files changed, 14 insertions, 11 deletions
@@ -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 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, - 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 covers this address. */ 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 >= hdr->sh_offset + hdr->sh_size))) { - /* We used to do a relative adjustment here, but - that doesn't work if the segment is packed with - code from multiple VMAs. Instead we calculate - the LMA absoultely, based on the LMA of the - segment (it is assumed that the segment will - contain sections with contiguous LMAs, even if - the VMAs are not). */ - newsect->lma = phdr->p_paddr - + hdr->sh_offset - phdr->p_offset; + if ((flags & SEC_LOAD) == 0) + newsect->lma += phdr->p_paddr - phdr->p_vaddr; + else + /* We used to use the same adjustment for SEC_LOAD + sections, but that doesn't work if the segment + is packed with code from multiple VMAs. + Instead we calculate the section LMA based on + the segment LMA. It is assumed that the + 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; } } |