aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorSteve Chamberlain <steve@cygnus>1991-03-26 22:05:50 +0000
committerSteve Chamberlain <steve@cygnus>1991-03-26 22:05:50 +0000
commitb473cf198e8952376a2b4a1e1225c1fd0251ee20 (patch)
treeb9bac63444bca7bf58510fff7db0a130eaeab168 /binutils
parent617cd5714278da0e0c57cce0f2f0c748f821788d (diff)
downloadgdb-b473cf198e8952376a2b4a1e1225c1fd0251ee20.zip
gdb-b473cf198e8952376a2b4a1e1225c1fd0251ee20.tar.gz
gdb-b473cf198e8952376a2b4a1e1225c1fd0251ee20.tar.bz2
If stripping, don't copy reloc info
Diffstat (limited to 'binutils')
-rw-r--r--binutils/copy.c64
1 files changed, 36 insertions, 28 deletions
diff --git a/binutils/copy.c b/binutils/copy.c
index 87937bd..05d9f2d 100644
--- a/binutils/copy.c
+++ b/binutils/copy.c
@@ -292,48 +292,56 @@ loser:
exit(1);
} /* setup_sections() */
+/*
+Copy all the section related data from an input section
+to an output section
+
+If stripping then don't copy any relocation info
+*/
static void
copy_sections(ibfd, isection, obfd)
bfd *ibfd;
sec_ptr isection;
bfd *obfd;
{
- static unsigned char *memhunk = NULL;
- arelent **relpp;
- int relcount;
- sec_ptr osection;
- unsigned long size;
- osection = bfd_get_section_by_name(obfd,
- bfd_section_name(ibfd, isection));
- size = bfd_section_size(ibfd, isection);
+ arelent **relpp;
+ int relcount;
+ sec_ptr osection;
+ unsigned long size;
+ osection = bfd_get_section_by_name(obfd,
+ bfd_section_name(ibfd, isection));
- if (size == 0)
- return;
+ size = bfd_section_size(ibfd, isection);
- if (strip == false && get_reloc_upper_bound(ibfd, isection) != 0) {
- relpp = (arelent **) xmalloc(get_reloc_upper_bound(ibfd, isection));
-
- relcount = bfd_canonicalize_reloc(ibfd, isection, relpp, sympp);
+ if (size == 0)
+ return;
- bfd_set_reloc(obfd, osection, relpp, relcount);
+ if (strip == true || get_reloc_upper_bound(ibfd, isection) == 0)
+ {
+ bfd_set_reloc(obfd, osection, (arelent **)NULL, 0);
+ }
+ else
+ {
+ relpp = (arelent **) xmalloc(get_reloc_upper_bound(ibfd, isection));
+ relcount = bfd_canonicalize_reloc(ibfd, isection, relpp, sympp);
+ bfd_set_reloc(obfd, osection, relpp, relcount);
}
- else {
- bfd_set_reloc(obfd, osection, (arelent **)NULL, 0);
- }
-
- if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS) {
- memhunk = (unsigned char *) xmalloc(size);
- /* now we have enough memory, just do it: */
- if (!bfd_get_section_contents(ibfd, isection, memhunk, 0, size))
- bfd_fatal(bfd_get_filename(ibfd));
- if (!bfd_set_section_contents(obfd, osection, memhunk, 0, size))
- bfd_fatal(bfd_get_filename(obfd));
- } /* only if the section has contents. */
+ if (bfd_get_section_flags(ibfd, isection) & SEC_HAS_CONTENTS)
+ {
+ unsigned char *memhunk = (unsigned char *) xmalloc(size);
+
+ if (!bfd_get_section_contents(ibfd, isection, memhunk, 0, size))
+ bfd_fatal(bfd_get_filename(ibfd));
+
+ if (!bfd_set_section_contents(obfd, osection, memhunk, 0, size))
+ bfd_fatal(bfd_get_filename(obfd));
+ free(memhunk);
+ }
+
- free(memhunk);
}
int
main(argc, argv)