diff options
author | Alan Modra <amodra@gmail.com> | 2000-05-09 00:43:44 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2000-05-09 00:43:44 +0000 |
commit | 72730e0ced64fe3a9864aff8de6bb688c3eaa64f (patch) | |
tree | 39978af761e9f05847a3683048bfbd3749520876 /bfd/elf.c | |
parent | b9791fcdd66ab49ffb0948b4c0f0e7b9b224f15a (diff) | |
download | gdb-72730e0ced64fe3a9864aff8de6bb688c3eaa64f.zip gdb-72730e0ced64fe3a9864aff8de6bb688c3eaa64f.tar.gz gdb-72730e0ced64fe3a9864aff8de6bb688c3eaa64f.tar.bz2 |
Fix some nits shown up by objcopy.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r-- | bfd/elf.c | 49 |
1 files changed, 33 insertions, 16 deletions
@@ -1354,8 +1354,9 @@ bfd_section_from_shdr (abfd, shindex) target_sect->rel_filepos = hdr->sh_offset; /* In the section to which the relocations apply, mark whether its relocations are of the REL or RELA variety. */ - elf_section_data (target_sect)->use_rela_p - = (hdr->sh_type == SHT_RELA); + if (hdr->sh_size != 0) + elf_section_data (target_sect)->use_rela_p + = (hdr->sh_type == SHT_RELA); abfd->flags |= HAS_RELOC; return true; } @@ -3744,7 +3745,7 @@ copy_private_bfd_data (ibfd, obfd) more to do. */ isec = 0; - matching_lma = false; + matching_lma = 0; suggested_lma = 0; for (j = 0, s = ibfd->sections; s != NULL; s = s->next) @@ -3810,21 +3811,32 @@ copy_private_bfd_data (ibfd, obfd) free (sections); continue; } - else if (matching_lma != 0) - { - /* At least one section fits inside the current segment. - Keep it, but modify its physical address to match the - LMA of the first section that fitted. */ - - m->p_paddr = matching_lma; - } else { - /* None of the sections fitted inside the current segment. - Change the current segment's physical address to match - the LMA of the first section. */ + if (matching_lma != 0) + { + /* At least one section fits inside the current segment. + Keep it, but modify its physical address to match the + LMA of the first section that fitted. */ + + m->p_paddr = matching_lma; + } + else + { + /* None of the sections fitted inside the current segment. + Change the current segment's physical address to match + the LMA of the first section. */ + + m->p_paddr = suggested_lma; + } + + /* Offset the segment physical address from the lma to allow + for space taken up by elf headers. */ + if (m->includes_filehdr) + m->p_paddr -= iehdr->e_ehsize; - m->p_paddr = suggested_lma; + if (m->includes_phdrs) + m->p_paddr -= iehdr->e_phnum * iehdr->e_phentsize; } /* Step Three: Loop over the sections again, this time assigning @@ -3857,7 +3869,12 @@ copy_private_bfd_data (ibfd, obfd) { /* If the first section in a segment does not start at the beginning of the segment, then something is wrong. */ - if (os->lma != m->p_paddr) + if (os->lma != (m->p_paddr + + (m->includes_filehdr + ? iehdr->e_ehsize : 0) + + (m->includes_phdrs + ? iehdr->e_phnum * iehdr->e_phentsize + : 0))) abort (); } else |