diff options
author | Nick Clifton <nickc@redhat.com> | 2006-01-18 11:01:09 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2006-01-18 11:01:09 +0000 |
commit | 6e2c86ac4d7527225b37dba354e534ed03af747a (patch) | |
tree | 9ff1ae877b4f60bd79746acfec636921db4223b1 /binutils | |
parent | d5259aacd1b5c656cd8faa3a95f23e02f6de1ca1 (diff) | |
download | gdb-6e2c86ac4d7527225b37dba354e534ed03af747a.zip gdb-6e2c86ac4d7527225b37dba354e534ed03af747a.tar.gz gdb-6e2c86ac4d7527225b37dba354e534ed03af747a.tar.bz2 |
PR binutils/1391
* objcopy.c (copy_object): For PE format targets set the VMA of a newly
created gnu_debuglink section to a non-zero, aligned, contiguous value.
* Makefile.am (objcopy.c): Add a dependency upon libbfd.h.
* Makefile.in: Regenerate.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 9 | ||||
-rw-r--r-- | binutils/Makefile.am | 2 | ||||
-rw-r--r-- | binutils/Makefile.in | 2 | ||||
-rw-r--r-- | binutils/objcopy.c | 46 |
4 files changed, 56 insertions, 3 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index b73144f..999ebd8 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,12 @@ +2006-01-18 Nick Clifton <nickc@redhat.com> + + PR binutils/1391 + * objcopy.c (copy_object): For PE format targets set the VMA of a + newly created gnu_debuglink section to a non-zero, aligned, + contiguous value. + * Makefile.am (objcopy.c): Add a dependency upon libbfd.h. + * Makefile.in: Regenerate. + 2006-01-17 Andreas Schwab <schwab@suse.de> PR binutils/1486 diff --git a/binutils/Makefile.am b/binutils/Makefile.am index cda12e1..45b04e3 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -458,7 +458,7 @@ objcopy.o: objcopy.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ budbg.h $(INCDIR)/filenames.h $(INCDIR)/fnmatch.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ - $(INCDIR)/bfdlink.h + $(INCDIR)/bfdlink.h $(BFDDIR)/libbfd.h objdump.o: objdump.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h ../bfd/bfdver.h $(INCDIR)/progress.h \ bucomm.h config.h $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h \ diff --git a/binutils/Makefile.in b/binutils/Makefile.in index e541799..64efd08 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -1210,7 +1210,7 @@ objcopy.o: objcopy.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h $(INCDIR)/libiberty.h \ budbg.h $(INCDIR)/filenames.h $(INCDIR)/fnmatch.h $(BFDDIR)/elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ - $(INCDIR)/bfdlink.h + $(INCDIR)/bfdlink.h $(BFDDIR)/libbfd.h objdump.o: objdump.c ../bfd/bfd.h $(INCDIR)/ansidecl.h \ $(INCDIR)/symcat.h ../bfd/bfdver.h $(INCDIR)/progress.h \ bucomm.h config.h $(INCDIR)/bin-bugs.h $(INCDIR)/fopen-same.h \ diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 2ab3d06..1d19fa8 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1,6 +1,6 @@ /* objcopy.c -- copy object file from input to output, optionally massaging it. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005 + 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -30,6 +30,7 @@ #include "fnmatch.h" #include "elf-bfd.h" #include <sys/stat.h> +#include "libbfd.h" /* A list of symbols to explicitly strip out, or to keep. A linked list is good enough for a small number from the command line, but @@ -1362,6 +1363,49 @@ copy_object (bfd *ibfd, bfd *obfd) bfd_nonfatal (gnu_debuglink_filename); return FALSE; } + + /* Special processing for PE format files. We + have no way to distinguish PE from COFF here. */ + if (bfd_get_flavour (obfd) == bfd_target_coff_flavour) + { + bfd_vma debuglink_vma; + asection * highest_section; + asection * sec; + + /* The PE spec requires that all sections be adjacent and sorted + in ascending order of VMA. It also specifies that debug + sections should be last. This is despite the fact that debug + sections are not loaded into memory and so in theory have no + use for a VMA. + + This means that the debuglink section must be given a non-zero + VMA which makes it contiguous with other debug sections. So + walk the current section list, find the section with the + highest VMA and start the debuglink section after that one. */ + for (sec = obfd->sections, highest_section = NULL; + sec != NULL; + sec = sec->next) + if (sec->vma > 0 + && (highest_section == NULL + || sec->vma > highest_section->vma)) + highest_section = sec; + + if (highest_section) + debuglink_vma = BFD_ALIGN (highest_section->vma + + highest_section->size, + /* FIXME: We ought to be using + COFF_PAGE_SIZE here or maybe + bfd_get_section_alignment() (if it + was set) but since this is for PE + and we know the required alignment + it is easier just to hard code it. */ + 0x1000); + else + /* Umm, not sure what to do in this case. */ + debuglink_vma = 0x1000; + + bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma); + } } if (bfd_count_sections (obfd) == 0) |