summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2000-05-09 01:00:47 +0000
committerAlan Modra <amodra@bigpond.net.au>2000-05-09 01:00:47 +0000
commit23413ed7c160f5ba08e588502b1ef56897ac24ad (patch)
tree1a8ed8f9918070d4963810f6edf9c51c922a46c9
parent2b66792ec44268546ad69b37f7ab0c9235c8392d (diff)
downloadgdb-23413ed7c160f5ba08e588502b1ef56897ac24ad.tar.gz
Fix some nits shown up by objcopy.
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/elf.c49
2 files changed, 40 insertions, 16 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 838fd95fea3..b877c08f33c 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2000-05-09 Alan Modra <alan@linuxcare.com.au>
+
+ * elf.c (bfd_section_from_shdr): Don't set use_rela_p if rela
+ section is empty.
+ (copy_private_bfd_data): Allow for space possibly taken up by elf
+ headers when calculating segment physical address from lma.
+
2000-05-08 Alan Modra <alan@linuxcare.com.au>
* versados.c (versados_scan): Init stringlen and pass_2_done.
diff --git a/bfd/elf.c b/bfd/elf.c
index 8830ff099cc..c210638beff 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -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;
}
@@ -3726,7 +3727,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)
@@ -3792,21 +3793,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
@@ -3839,7 +3851,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