X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fobjcopy.c;h=839d27bc17b4fb68687b5a73bc33689257bda7e4;hb=80fccad2d4ce82a2ed9a5d8d081eb2daefa09f9d;hp=96233986c3e01b5c1ed1e2f4439a0b2e4b619b7f;hpb=2f01ffbf77c3bfbcddba30c77ceb324fb2757ee8;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 96233986c3..839d27bc17 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -377,6 +377,7 @@ extern unsigned long bfd_external_machine; /* Forward declarations. */ static void setup_section (bfd *, asection *, void *); +static void setup_bfd_headers (bfd *, bfd *); static void copy_section (bfd *, asection *, void *); static void get_sections (bfd *, asection *, void *); static int compare_section_lma (const void *, const void *); @@ -410,7 +411,7 @@ copy_usage (FILE *stream, int exit_status) -G --keep-global-symbol Localize all symbols except \n\ -W --weaken-symbol Force symbol to be marked as a weak\n\ --weaken Force all global symbols to be marked as weak\n\ - -w --wildcard Permit wildcard in symbol comparasion\n\ + -w --wildcard Permit wildcard in symbol comparison\n\ -x --discard-all Remove all non-global symbols\n\ -X --discard-locals Remove any compiler-generated symbols\n\ -i --interleave Only copy one out of every bytes\n\ @@ -485,7 +486,7 @@ strip_usage (FILE *stream, int exit_status) --only-keep-debug Strip everything but the debug information\n\ -N --strip-symbol= Do not copy symbol \n\ -K --keep-symbol= Only copy symbol \n\ - -w --wildcard Permit wildcard in symbol comparasion\n\ + -w --wildcard Permit wildcard in symbol comparison\n\ -x --discard-all Remove all non-global symbols\n\ -X --discard-locals Remove any compiler-generated symbols\n\ -v --verbose List all object files modified\n\ @@ -1178,6 +1179,8 @@ copy_object (bfd *ibfd, bfd *obfd) any output is done. Thus, we traverse all sections multiple times. */ bfd_map_over_sections (ibfd, setup_section, obfd); + setup_bfd_headers (ibfd, obfd); + if (add_sections != NULL) { struct section_add *padd; @@ -1808,6 +1811,32 @@ find_section_rename (bfd * ibfd ATTRIBUTE_UNUSED, sec_ptr isection, return old_name; } +/* Once each of the sections is copied, we may still need to do some + finalization work for private section headers. Do that here. */ + +static void +setup_bfd_headers (bfd *ibfd, bfd *obfd) +{ + const char *err; + + /* Allow the BFD backend to copy any private data it understands + from the input section to the output section. */ + if (! bfd_copy_private_header_data (ibfd, obfd)) + { + err = _("private header data"); + goto loser; + } + + /* All went well. */ + return; + +loser: + non_fatal (_("%s: error in %s: %s"), + bfd_get_filename (ibfd), + err, bfd_errmsg (bfd_get_error ())); + status = 1; +} + /* Create a section in OBFD with the same name and attributes as ISECTION in IBFD. */