aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2004-04-17 11:18:47 +0000
committerAlan Modra <amodra@gmail.com>2004-04-17 11:18:47 +0000
commitd48bdb9974fb7967790238ab3d888381eb84a4ee (patch)
tree010a4ce07f17d7ba91f935792af543eef7883748
parent350c2e5bea420a23d1d9399fd2ba65a85016491c (diff)
downloadgdb-d48bdb9974fb7967790238ab3d888381eb84a4ee.zip
gdb-d48bdb9974fb7967790238ab3d888381eb84a4ee.tar.gz
gdb-d48bdb9974fb7967790238ab3d888381eb84a4ee.tar.bz2
* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Use the first non-zero
filepos for the SizeOfHeaders field. (_bfd_XXi_swap_scnhdr_out): Correct section flags lossage on reloc overflow. (_bfd_XXi_swap_sym_in): Remove redundant section flags assignment.
-rw-r--r--bfd/ChangeLog8
-rw-r--r--bfd/peXXigen.c19
2 files changed, 19 insertions, 8 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f128442..a5c3bd1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,11 @@
+2004-04-17 Brian Ford <ford@vss.fsi.com>
+
+ * peXXigen.c (_bfd_XXi_swap_aouthdr_out): Use the first non-zero
+ filepos for the SizeOfHeaders field.
+ (_bfd_XXi_swap_scnhdr_out): Correct section flags lossage on reloc
+ overflow.
+ (_bfd_XXi_swap_sym_in): Remove redundant section flags assignment.
+
2004-04-16 Alan Modra <amodra@bigpond.net.au>
* simple.c (bfd_simple_get_relocated_section_contents): Don't
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 598aa7c..d7f3750 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -198,7 +198,6 @@ _bfd_XXi_swap_sym_in (abfd, ext1, in1)
sec->lineno_count = 0;
sec->userdata = NULL;
sec->next = (asection *) NULL;
- sec->flags = 0;
sec->alignment_power = 2;
sec->flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD;
@@ -658,14 +657,19 @@ _bfd_XXi_swap_aouthdr_out (abfd, in, out)
{
asection *sec;
+ bfd_vma hsize = 0;
bfd_vma dsize = 0;
- bfd_vma isize = SA(abfd->sections->filepos);
+ bfd_vma isize = 0;
bfd_vma tsize = 0;
for (sec = abfd->sections; sec; sec = sec->next)
{
int rounded = FA(sec->_raw_size);
+ /* The first non-zero section filepos is the header size.
+ Sections without contents will have a filepos of 0. */
+ if (hsize == 0)
+ hsize = sec->filepos;
if (sec->flags & SEC_DATA)
dsize += rounded;
if (sec->flags & SEC_CODE)
@@ -682,10 +686,10 @@ _bfd_XXi_swap_aouthdr_out (abfd, in, out)
aouthdr_in->dsize = dsize;
aouthdr_in->tsize = tsize;
- extra->SizeOfImage = isize;
+ extra->SizeOfHeaders = hsize;
+ extra->SizeOfImage = SA(hsize) + isize;
}
- extra->SizeOfHeaders = abfd->sections->filepos;
H_PUT_16 (abfd, aouthdr_in->magic, aouthdr_out->standard.magic);
#define LINKER_VERSION 256 /* That is, 2.56 */
@@ -983,7 +987,6 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out)
};
pe_required_section_flags * p;
- int flags = scnhdr_int->s_flags;
/* We have defaulted to adding the IMAGE_SCN_MEM_WRITE flag, but now
we know exactly what this specific section wants so we remove it
@@ -998,12 +1001,12 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out)
{
if (strcmp (scnhdr_int->s_name, ".text")
|| (bfd_get_file_flags (abfd) & WP_TEXT))
- flags &= ~IMAGE_SCN_MEM_WRITE;
- flags |= p->must_have;
+ scnhdr_int->s_flags &= ~IMAGE_SCN_MEM_WRITE;
+ scnhdr_int->s_flags |= p->must_have;
break;
}
- H_PUT_32 (abfd, flags, scnhdr_ext->s_flags);
+ H_PUT_32 (abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
}
if (coff_data (abfd)->link_info